Some of the information here may be outdated, please check the book instead
[edit]

Currently in trunk only - will be in web2py 1.55:

You can now export and import the entire database in CSV:

db.export_to_csv_file(open('filename.csv','w'))
for table in db.tables: db[table].truncate()
db.import_from_csv_file(open('filename.csv','r'))

The CSV contains all tables. Notice that upon import, the imported records may have different ID numbers than the original ones but references will not be broken because web2py will use the new IDs and not the old IDs for references.

This is independent on the database back-end, therefore you can export, for example, from a Oracle database, and import in PostgreSQL.

Works will all web2py supported databases including the Google App Engine. In this latter case you cannot do IO on filesystem so you must use a memory mapped file:

s=StringIO.StringIO()
db.export_to_csv_file(s)    
for table in db.tables: db[table].truncate()
s.seek(0)
db.import_from_csv_file(s)
© 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.