Complete cross-database backup/restore
[edit]In web2py you can backup/restore an entire database, across database engine, from the shell with two command:
- have a model that connects to the sqliite db
run
python web2py -S yourapp -Min the shell type
db.export_to_csv_file(open('somefile.csv','wb'))quit, edit the model to connect to the other db instead
from the shell type
python web2py -S yourapp -Min the shell type
db.import_from_csv_file(open('somefile.csv','rb'))
Done. Id's may be different but references will be preserved and will not be broken.
Requires web2py 1.64.4
Caveats and UUID
When importing the new records will be appended to the database if this is not empty. If a table contains a field called "uuid", this field will be used to identify duplicates and an imported record has the same "uuid" as an existing record the previous record is updated.