[Zope-DB] cannot commit and nothing is written

Federico Di Gregorio fog@debian.org
15 Oct 2001 10:49:27 +0200


hi,

first of all, i think that adapter-specific messages better go to the
adapter mailing list, in that case http://lists.initd.org/. also, the
correct name is psycopg, not pycong. anyway, here's the answer...

On Mon, 2001-10-15 at 10:04, Florian Schuler wrote:
[snip]
> It seems to work. The Debug message of pycong says:
> 
> [15758] psyco_curs_execute(): operation = >insert into mailingliste
> values
> (11,10,0,'fschuler@braunconsulting.de','fschuler@braunconsulting.de','N/
> A','11.10.2001','16:21:46','Das ist eine TestMassage mit List ID im
> header',1);<
> [15758] psyco_curs_execute(): operation->refcnt = 1
> [15758] _psyco_curs_execute(): connection at 0x81072b0 OK
> [15758] _psyco_curs_execute(): query = >insert into mailingliste values
> (11,10,0,'fschuler@braunconsulting.de','fschuler@braunconsulting.de','N/
> A','11.10.2001','16:21:46','Das ist eine TestMassage mit List ID im
> header',1);<
> [15758] _psyco_curs_execute(): query executed
> [15758] _psyco_curs_execute(): command returned OK (no tuples)
> Traceback (innermost last):
>   File "pop.py", line 202, in ?
>     c1.commit()
> psycopg.Error: serialized connection: cannot commit on this cursor

you are committing on a _cursor_. the dbapi specifies you should commit
on the _connection_. if you want to use the extended api provided by
psycopg you should use not-serialized connections:

conn = psycopg.connect(DSN, serialize=0)
curs = conn.cursor()
...
curs.commit()

note that if you run single thread or you plan to use just 1 cursor,
using a serialized connection is a little bit faster because involves
less overhead. example:

conn = psycopg.connect(DSN)
curs = conn.cursor()
...
conn.commit()    % conn, not curs!
^^^^

hope this helps,
federico

-- 
Federico Di Gregorio
Debian GNU/Linux Developer & Italian Press Contact        fog@debian.org
INIT.D Developer                                           fog@initd.org
  Try the Joy of TeX [http://www.tug.org]
                                      -- brought to you by One Line Spam