Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Create Deta Base DB on app start (FastApi) #218

Answered by jnsougata
Master-Y0da asked this question in Help
Discussion options

You must be logged in to vote

I guess you don't have to make the table at the startup. you can use put whenever you want. it will create the table for the user but there's a chance of overwrting the existing data so I will suggest you to use update with set inside try except block and check for exception... if the key doesn't exist go with put

for example key is my target... I use the following to create or update

    async def add_field(self, key: str, field: Field, force: bool = False) -> Dict[str, Any]:
        """
        adds a field to an existing key.
        if field already exists, old value will be overwritten.
        """
        if not force:
            return await self.update(key=key, updates=[Update.set

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
5 replies
@Master-Y0da
Comment options

@abdelhai
Comment options

@Master-Y0da
Comment options

@abdelhai
Comment options

@harshitsinghai77
Comment options

Comment options

You must be logged in to vote
1 reply
@Master-Y0da
Comment options

Answer selected by Master-Y0da
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants