On Monday 06 August 2007 02:09:45 Paul Johnston wrote: > Hi, > > >I'm in the same process, and very interested in the answer ! > > I've found what I think is the best solution, and it sounds quite > obvious thinking about it. Define the table, do a select on the old > database and an insert on the new database. This leverages all > SQLAlchemy's cleverness in converting types, etc. and keeps the ORM > out of the picture. The code I'm using is: > > model = __import__(sys.argv[1]) > if sys.argv[2] == 'copy': > seng = create_engine(sys.argv[3]) > deng = create_engine(sys.argv[4]) > for tbl in model.metadata.table_iterator(): > deng.execute(tbl.insert(), [dict(x) for x in > seng.execute(tbl.select())]) > > All it relies on is that you call your MetaData "metadata". At the > moment, it chokes on names that contain a dash (or maybe it's ones > that use key=), but I'm sure I can workaround that. When I'm done, > I'll put this up as a recipe. > > Paul
heh, adding this raw-data-copy to the autoload.py $ python autoload.py postgres://[EMAIL PROTECTED]/db1 | python - sqlite:///db2 which copyies the structure of input db1 database into the output db2. makes quite a database-copier/migrator... svil --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---