I have run into issues with keeping the objects I have 'sync'ed with the database so I can issue plain sql statements within the same transaction. This is how I have been dealing with it... from sqlalchemy import * from sqlalchemy.schema import default_engine as engine global_connect("postgres://database=crazy_db") users = Table('users', Column('user_id', Integer, primary_key = True), Column('user_name', String(16), nullable = False), Column('email_address', String(60), key='email'), Column('password', String(20), nullable = False) ) class User(object):pass User.mapper = mapper(User, users) try:users.drop() except:pass users.create() engine.begin() u = User() u.user_name = 'barry' u.user_id = 12 u.password = 'hooha' objectstore.commit(u) #issues select directly on the database c = engine.execute("select * from users where user_name='barry'") print c.fetchall() engine.commit() I know that there are some ramifications to committing/deleting objects individually, but I've been using this a bit, without any issues. Because the engine had explicitly started a transaction, all statements in this scope act in this transaction, and 'objectstore.commit(u)' simply causes the insert/update/delete statements for that object to be issued. I hope this helps. Aaron On Mar 29, 2006, at 2:44 AM, Florian Boesch wrote:
Aaron Bickell Research & Development Optio Software, Inc |
- Re: [Sqlalchemy-users] hibernate Michael Bayer
- Re: [Sqlalchemy-users] hibernate Michael Bayer
- Re: [Sqlalchemy-users] hibernate Jonathan Ellis
- Re: [Sqlalchemy-users] hibernate dmiller
- Re: [Sqlalchemy-users] hibernate Florian Boesch
- Re: [Sqlalchemy-users] hibernate Jonathan Ellis
- Re: [Sqlalchemy-users] hibernate Florian Boesch
- Re: [Sqlalchemy-users] hibernate Dennis
- Re: [Sqlalchemy-users] hibernate Michael Bayer
- Re: [Sqlalchemy-users] hibernate Florian Boesch
- Re: [Sqlalchemy-users] hibernate Aaron Bickell
- Re: [Sqlalchemy-users] hibernate HD Mail
- Re: [Sqlalchemy-users] hibernate Michael Bayer
- Re: [Sqlalchemy-users] hibernate Florian Boesch
- Re: [Sqlalchemy-users] hibernate Michael Bayer
- Re: [Sqlalchemy-users] hibernate Michael Bayer
- Re: [Sqlalchemy-users] optimistic concurrency WAS hibe... Daniel Miller
- Re: [Sqlalchemy-users] optimistic concurrency WAS ... Michael Bayer
- Re: [Sqlalchemy-users] optimistic concurrency ... Jonathan Ellis
- Re: [Sqlalchemy-users] optimistic concurre... Michael Bayer