Ask coding questions

← Back to all posts
sqlite3 data loss
MatthewWang (8)

I am currently attempting to use sqlite3 to have a database for a Discord bot. The code works perfectly fine except that at random times throughout the day the database will roll back on itself and lose several hours' and sometimes even days' worth of data. It's been very frustrating because when SQL statements are executed, everything seems normal until I check back hours later and discover that the data was rolled back. I'd like to know how I can resolve this problem so that the database does not lose data

Here are the two functions I use for my database with example calls at the bottom

(Database is not created here because I just copied/pasted the functions and examples from another repl)

Comments
hotnewtop
alanchen12 (28)

Any file system db on repl does not work!

This is because repl always keeps a snapshot of things before you left, and when you get back onto the repl it reverts to the snapshot that you were on last, therefore reverting your data.

Vandesm14 (2656)

File changes made by a program will not persist and are unreliable. The only way to use a database on repl.it is to use Repl DB or an external database like Firebase or Mongo

KareMcBob (1)

I've got the same problem. Does anyone have any updates a year later?