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)