On Tue, Apr 22, 2008 at 6:00 PM, <[EMAIL PROTECTED]> wrote: > > > On Tuesday 22 April 2008 19:54:16 Lukasz Szybalski wrote: > > Hello again, > > So now that I have mssql connection ready and data filtered out and > > processed I need to save it to a different database. > > > > mssql -> process data -> save to mysql > > > > I am wondering how should I create a second database connection? In > > second database I will create a table and populate the records. > > > > # First database > > e = > > sqlalchemy.create_engine("mssql://user:[EMAIL PROTECTED]:1433/dbname?dr > >iver=TDS&odbc_options='TDS_Version=8.0'") #e.echo=True > > metadata=sqlalchemy.MetaData(e) > > > > #session stuff > > from sqlalchemy.orm import sessionmaker > > Session = sessionmaker(bind=e, autoflush=True, transactional=True) > > session = Session() > > > > #table stuff > > class th(object): > > pass > > th_table = sqlalchemy.Table('xxxx', metadata, autoload=True) > > mapper(th,th_table) > > > > # database number 2. Is this the way I should create second > > database connection/session/mapper? > > e2 = sqlalchemy.create_engine('mysql://user:[EMAIL PROTECTED]/dbname') > > > > Do I create new metadata? > > metadata2=sqlalchemy.MetaData(e2) > > And then new session2? > > Session2 = sessionmaker(bind=e2, autoflush=True, > > transactional=True) What does this line do? > > session = Session() > > > > Is the above correct way of doing this? > > I would like to keep these connections separate so there will be no > > confusion of what I am using. > > > > Thanks, > > Lucas > > well... u dont really need 2nd metadata, and u dont need any > session/mappers/etc ORM-stuff at all. re-bind the metadata to new > engine, then metadata.createall(), and then for each record in each > table in metadata, tbl.select via src_engine, tbl.insert via > dst_engine > > but u can try this way too.. >
these are 2 different databases... one is all autoload and two is completely new and will not have any tables from 1. Lucas --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---