All,

I want to do a two-phase commit.
Published examples are more complex than what I need.
To put it another way, I don't want to use the ORM.
Here is what I want to do:

    # This code does what I want - but is missing the two-phase
commit.
    # All session code is commented out because I am unsure how to
configure it properly.

    import sqlalchemy
    mapEngine = sqlalchemy.create_engine('postgresql://
postgres:postg...@localhost:5432/sfmaps')
    appEngine = sqlalchemy.create_engine('postgresql://
postgres:postg...@localhost:5432/mad')

    # How can a _simply_ bind my connectables to a Session?
    # The example from docs is more that I need:
Session.configure(binds={User:engine1, Account:engine2})
    #Session = sqlalchemy.sessionmaker(twophase=True)
    # of course this next line does not work - I hope to show my
intentions here
    #Session.configure(binds={mapEngine, appEngine})
    #session = Session()

    mapConn = mapEngine.raw_connection()
    appConn = appEngine.raw_connection()

    mapCursor = mapConn.cursor()
    appCursor = appConn.cursor()

    # I need to do a lot of stuff like this
    #    - using different table names
    #    - using different db procs
    mapCursor.execute('truncate table etl_test;')
    mapCursor.execute("copy etl_test_staging to 'C:/temp/
etl_test_staging.copy';")
    mapCursor.execute("copy etl_test from 'C:/temp/
etl_test_staging.copy';")
    appCursor.callproc('_etl_test', ['testing...'])

    # Once I have the magic incantations, I'll use session.commit()
instead of the connection.commit()
    # session.commit()
    mapConn.commit()
    appConn.commit()

A similar thread
    
http://groups.google.com/group/sqlalchemy/browse_thread/thread/b9e42756eb2513b0/a372495356e4eb5e?lnk=raot

Regards
Paul

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to