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
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.
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.