Ask coding questions

← Back to all posts
Tech wizard
h
davidbonn (0)

Hello,

I'm wanting to use the built-in repl.it database and have a big question:

My understanding is that running repls may be stopped at any time. Is the database able to maintain integrity if it is stopped at some arbitrary point? How do I check for that?

I think I can manage this by only needing single assignments to the database for any operation. Will that help?

Answered by Coder100 (16789) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (16789)

The database is externally hosted. It is more reliable than a repl in terms of uptime.

That doesn't mean your data will definitely be saved. It is communicated through HTTP requests, and those can fail sometimes because of ratelimits.

The most reliable way is to save data when it needs to be. You might get ratelimited, but it's far more 'reliable' than only doing it sometimes.

davidbonn (0)

Ok, that makes things a little more clear.
So if I do:

from replit import db

# ...

db["weather/48.6,-120.2"] = { ... }

I can be reasonably certain that if the entry in question will
either not be updated at all or be updated with exactly what I specified? That sounds like what you are saying.

I can live with things not being saved, but I can't with things being garbled.

With the experiments I am running I am not grossly concerned with ratelimits.

InvisibleOne (2675)

As long as the database has had enough time, then test it should save, but if it was in the middle of saving and failed, you would loose some integrity