I have a Flask repl with a ReplitDB database full of keys and values all organized in a structure.
Is it possible to copy that DB over to a different repl of mine? Would I use the $REPLIT_DB_URL in shell to do this?
Someone help me out. Thanks.
I have a Flask repl with a ReplitDB database full of keys and values all organized in a structure.
Is it possible to copy that DB over to a different repl of mine? Would I use the $REPLIT_DB_URL in shell to do this?
Someone help me out. Thanks.
Here is some code that should help
from replit import db, DataBase
otherDB = DataBase("<other db url>")
for key, value in db:
otherDB[key] = value
This might work, have not checked if the db object has proper inter.
This would access the original DB?
I think (not sure) this would be run on the original repl, with the other db url
being the new replβs db URL.
That makes no sense. I just want to copy the structure of the old DB in the old Repl to the new Repl.
Wait, so you want to copy the structure, not the value? Could you explain this structure and link the old repl?
Hi, I have the same issue that I want to copy all my data from one Repl to another. I used this code but I get:
Traceback (most recent call last):
File "main.py", line 4, in <module>
import transfer
File "/home/runner/myrepl/transfer.py", line 1, in <module>
from replit import db, DataBase
ImportError: cannot import name 'DataBase' from 'replit' (/home/runner/myrepl/venv/lib/python3.10/site-packages/replit/__init__.py)
Try this slightly modified code:
from replit import db
DataBase = type(db)
otherDB = DataBase("<other db url>")
for key, value in db:
otherDB[key] = value
Now I get:
Traceback (most recent call last):
File "main.py", line 4, in <module>
import transfer
File "/home/runner/myrepl/transfer.py", line 6, in <module>
for key, value in db:
ValueError: not enough values to unpack (expected 2, got 0)
How about:
from replit import db
DataBase = type(db)
otherDB = DataBase("<other db url>")
for key in db:
otherDB[key] = db[key]
That worked, thanks!