Some of the information here may be outdated, please check the book instead
[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 -M

  • in 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 -M

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

© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by web2py - design derived from a theme by the earlybird
The content of this book is released under the Artistic License 2.0 - Modified content cannot be reproduced.