On Tue, Oct 27, 2009 at 16:52 -0400, Michael Bayer wrote: > > Wolodja Wentland wrote: > > * Is there an even better way to do this? ;-) > create_engine() for PG supports an "isolation_level" parameter. But it > only does the four levels PG provides, it doesn't yet have a hook for > Psycopg2's "autocommit" mode.
I will keep that in mind for other problems, but it is not applicable here. > > * Is it necessary to set the isolation level to the value it had > > before I set it to ISOLATION_LEVEL_AUTOCOMMIT to make sure that no > > connection uses ISOLATION_LEVEL_AUTOCOMMIT in the future without > > explicitly setting that? > > the way you have it, yes. Alternatively, you can call detach() on the > connection you returned and it will be de-associated from the connection > pool. Otherwise I would absolutely use try/finally above so that the > isolation level is returned to normal if the CREATE DATABASE fails. Yes, I will definately use try: ... finally: here. What was I thinking? I might just write a context manager for that. > > * Why the .connection.connection ? I remember that I had to write just > > one .connection in the past. > it should only need to be conn.connection. That returns a wrapper that > will pass all method calls down to the psycopg2 connection. would be > interested to know the error otherwise. There is no error actually. The time when I used just one connection I just copied code from somewhere else. This evening I digged into the connection object in the interpreter and found the .set_isolation_level method only within the second .connection so I adapted my code to reflect that. So the first .connection is the SA one and the second the one provided by psycopg2? > > And one more word... This is the fastest mailing list I have ever used. > > Thank you so much for reacting so fast on this ML, thank you very much > > for SA and thanks for the solution to my problem! > youre welcome I mean it. This is amazing! No wonder #sqlalchemy is so dead. Which really is a pity BTW. Are you on IRC as well? Wolodja
signature.asc
Description: Digital signature