Michael Bayer wrote: > On Jun 4, 2007, at 6:47 PM, nathan harmston wrote: > > >> What kind of overhead is associated with using the autoload flag? >> >> What kind of overhead would be associated with this over a network? >> (with a remote database). Is there a way to "dump" the structure of >> a database to a file and import this as a kind of module? >> >> > > no, theres no built in way to dump to a file and re-import. youd have > to write that yourself. please contribute it if you do so since we > get this question once a month, I would recommed using the AutoCode script from http://www.sqlalchemy.org/trac/wiki/UsageRecipes/AutoCode rather then autoload directly. It just gives that little bit more control by tweaking the autocode.py script, but also the convenience of autoload.
However, if you still want to use autoload, this is what I use to do with autoload metadata. Remember to delete the dump file when you change your database. ====================================================== from sqlalchemy import pool, create_engine, BoundMetaData, MetaData import psycopg2 as psycopg http://www.sqlalchemy.org/trac/wiki/UsageRecipes/AutoCode psycopg = pool.manage(psycopg, pool_size=10) engine = create_engine('postgres://username:[EMAIL PROTECTED]/database', strategy='threadlocal') metadata = BoundMetaData(engine) if os.path.exists('dump.metadata'): meta_load = pickle.load(file('dump.metadata', 'rb')) for table in meta_load.tables.values(): table.tometadata(meta) branch_table = Table('branch', meta, autoload=True) # define the reset of your tables. if not os.path.exists('dump.metadata'): meta_save = MetaData() for table in meta.tables.values(): table.tometadata(meta_save) pickle.dump(meta_save, file('dump.metadata', 'wb')) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---