Beispiel #1
0
iri = db.persons.insert( name='Iri', age=62 )
jac = db.persons.insert( name='Jac', age=18 )
db.commit()

# Export the 'persons' database
with open( 'persons.csv', 'wb' ) as f:
	f.write( str(db(db.persons.id).select()) )

# Export only the young persons
with open( 'young-people.csv', 'wb') as f:
	people = db( db.persons.age <= 30 ).select()
	f.write( str( people ) )


# Let's make another table and export mutliple tables
db.define_table('point2d',
	Field('x',type='double'),
	Field('y',type='double')
)

db.point2d.insert( x=10, y=10 )
db.point2d.insert( x=10, y=20 )
db.point2d.insert( x=20, y=20 )
db.point2d.insert( x=20, y=10 )
db.commit()

# EXPORT all the TABLES!
with open('all-tables.csv','wb') as f:
	db.export_to_csv_file(f)