pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Python psycopg transaction isolation level
2+ messages / 2 participants
[nested] [flat]

* Python psycopg transaction isolation level
@ 2006-02-28 18:27 Eugene Prokopiev <prokopiev@stc.donpac.ru>
  2006-02-28 19:07 ` Re: Python psycopg transaction isolation level Michael Fuhr <mike@fuhr.org>
  0 siblings, 1 reply; 2+ messages in thread

From: Eugene Prokopiev @ 2006-02-28 18:27 UTC (permalink / raw)
  To: pgsql-interfaces

Hi,

I have a simple python script:

connection = psycopg.connect("host="+server+" dbname="+database+" 
user="+login+" password="+password)
cursor_modify = connection.cursor()
cursor_modify.execute("update messages set flag=1 where flag=0")
connection.commit()

On running it sometimes I got:

psycopg.ProgrammingError: ERROR:  could not serialize access due to 
concurrent update

How can I setup isolation level for waiting end of executing other 
transaction and execute update without any error?

--
Thanks,
Eugene Prokopiev



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Python psycopg transaction isolation level
  2006-02-28 18:27 Python psycopg transaction isolation level Eugene Prokopiev <prokopiev@stc.donpac.ru>
@ 2006-02-28 19:07 ` Michael Fuhr <mike@fuhr.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Fuhr @ 2006-02-28 19:07 UTC (permalink / raw)
  To: Eugene Prokopiev <prokopiev@stc.donpac.ru>; +Cc: pgsql-interfaces

On Tue, Feb 28, 2006 at 09:27:29PM +0300, Eugene Prokopiev wrote:
> connection = psycopg.connect("host="+server+" dbname="+database+" 
> user="+login+" password="+password)
> cursor_modify = connection.cursor()
> cursor_modify.execute("update messages set flag=1 where flag=0")
> connection.commit()
> 
> On running it sometimes I got:
> 
> psycopg.ProgrammingError: ERROR:  could not serialize access due to 
> concurrent update

psycopg's default isolation level is SERIALIZABLE.  I think the way
to set the isolation level to READ COMMITTED is:

connection = psycopg.connect(...)
connection.set_isolation_level(1)

You'll find more psycopg expertise on the psycopg mailing list:

http://lists.initd.org/mailman/listinfo/psycopg

-- 
Michael Fuhr



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-02-28 19:07 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-02-28 18:27 Python psycopg transaction isolation level Eugene Prokopiev <prokopiev@stc.donpac.ru>
2006-02-28 19:07 ` Michael Fuhr <mike@fuhr.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox