Skip to content
Sign upLog in
← Back to Community

Database not saving

Profile icon
Xpym4uk

(Aio)Sqlite3 database resetting when the programm restarting.
I need to do it not resetting, because i making bot for telegram with value system. On repl.it on each restart bot resetting database to first state file. Please help :(

Voters
Profile icon
Xpym4uk
Comments
hotnewtop
Profile icon
OldWizard209

Why don't u use replit's database?

Profile icon
Xpym4uk

@OldWizard209
i need to use values by their owners, like "Select VALUE from OWNER". It needs to make for every user many single values

Profile icon
OldWizard209

Yeah, you can still use the replit database. But you can save a list as a value to the key, and access the elements from there.

And the reason why your database is resetting is everytime the code runs, you are creating a new connection to the db. Create a connection only if a db has not already been created.

@Xpym4uk

Profile icon
Xpym4uk

@OldWizard209
Ok thanks

Profile icon
xfinnbar

@Xpym4uk
You can also use MongoDB atlas, which allows more advanced queries.

Profile icon
Xpym4uk

@OldWizard209
no, not working. If i delete creating connection i cannot get/set/delete table values in database

Profile icon
aLEGEND

@Xpym4uk
Try using await connection.close() once you have finished working with the database