Python replit DB not synced even after setting environ

Problem description:
I was attempting to make a simple send-or-receive system utilizing replit DB. However, using two different accounts on two different browsers I see that the DBs are not synced even after setting os.environ. I checked both to make sure they were on the same copy of the code yet no luck. This also occured to me (but I was oblivious) when I was creating a game with my friends and occasionally their accounts would be deleted or accounts would not be able to read other account’s DB values.

Expected behavior:
For the DBs to sync (and yes I tried rebooting the repl and refreshing page)

Actual behavior:
DBs fail to sync even after setting os.environ

Steps to reproduce:
Run the code

Bug appears at this link:
REPLIT_DB_URL is also at the link

Firefox + Chrome/Windows 11/PC

Replit DB is a per-copy of the repl thing. This includes being run through the cover page. Unless you use a DB proxy or hardcode the URL to the DB, the cover page will not access the same one as your copy.


As I said, I made the database URL hard-coded.

1 Like

I don’t really know but this code worked for me:

from replit import Database

db = Database("")

db["reading"] = "hello world"
db["c"] = 0

repl link

To get your URL, enter this in shell: echo $REPLIT_DB_URL
Then, use the following Python code:

from replit import db
db.db_url = "put your db URL here"

Finally, use the DB as normal. To keep it secret, use an environmental secret to store the DB URL.
Please note that I learned all this from @Firepup650.



from replit import Database


From reading your post, it sounds like you hardcode the URL into the Secrets tab, which is only accessible from your copy of the repl.

1 Like

i didn’t, but its working now