From: | Federico Di Gregorio <federico(dot)digregorio(at)dndg(dot)it> |
---|---|
To: | Jacob Kaplan-Moss <jacob(at)jacobian(dot)org> |
Cc: | psycopg(at)postgresql(dot)org |
Subject: | Re: autocommit and Django |
Date: | 2011-06-23 07:08:42 |
Message-ID: | 4E02E67A.7090900@dndg.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On 22/06/11 23:59, Jacob Kaplan-Moss wrote:
> On Wed, Jun 22, 2011 at 4:47 PM, Federico Di Gregorio
> <federico(dot)digregorio(at)dndg(dot)it> wrote:
>> It is just half of the fix. You can't assume that switching to
>> autocommit will do an implicit ROLLBACK for you. This worked until now
>> by chance (and because some drivers share the same logic and even some
>> code) but will break with new drivers or when old drivers decide to
>> "fix" the switch as we did for psycopg. So, IMHO, the best thing is to
>> always call .rollback() before switching transaction level.
>
> OK, thanks.
>
> Couple more questions if you don't mind:
>
> Are there any backwards-compatability implications here? It seems not:
> if prior versions of psycopg2 implicitly issued a ROLLBACK upon
> switching to autocommit then we're just making that explicit. Nobody
> using an older version of psycopg2 will get burned by a "new"
> ROLLBACK, right?
That's correct.
> Second, is `conn.set_isolation_level(0)` the right invocation even in
> the light of the new `set_session()` API? I'd prefer to use
> `set_isolation_level` because it's backwards compatible, but if it's
> going away in some future version of psycopg2 I don't want to have a
> similar problem crop up later. Is `set_isolation_level` considered a
> stable method?
New code should use set_session() because of its cleeaner API and exact
control over session parameters. But we're _very_ careful about future
compatibility: there are just too may psycopg applications to simply
remove obsolete methods from future versions. I can say that
`set_isolation_level` will stay almost forever.
> Thanks again!
You're welcome.
federico
--
Federico Di Gregorio federico(dot)digregorio(at)dndg(dot)it
Studio Associato Di Nunzio e Di Gregorio http://dndg.it
Gli esseri umani, a volte, sono destinati, per il solo fatto di
esistere, a fare del male a qualcuno. -- Haruki Murakami
From | Date | Subject | |
---|---|---|---|
Next Message | Marco Beri | 2011-06-23 07:14:46 | Re: autocommit and Django |
Previous Message | Jacob Kaplan-Moss | 2011-06-22 21:59:03 | Re: autocommit and Django |