On Feb 17, 2014, at 7:31 PM, Michael Bayer <mike...@zzzcomputing.com> wrote:

> 
> O
> from sqlalchemy import event, create_engine
> 
> eng = create_engine("postgresql+psycopg2://scott:tiger@localhost/test", 
> echo=True)
> 
> @event.listens_for(eng, "first_connect", insert=True)
> @event.listens_for(eng, "connect", insert=True)
> def setup_autocommit(dbapi_conn, rec):
>    dbapi_conn.autocommit = True
> 
> conn = eng.connect()
> print conn.execute("select 1").fetchall()


oh and also if you are on 0.8 (not 0.7), you can just send AUTOCOMMIT to 
create_engine:

eng = create_engine("postgresql+psycopg2://scott:tiger@localhost/test",
                    echo=True,
                    isolation_level='AUTOCOMMIT'
                    )

much easier


Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to