PostgreSQL pgdb driver raises "can't rollback" exception

Posted by David Parunakian on Stack Overflow See other posts from Stack Overflow or by David Parunakian
Published on 2010-03-10T18:28:45Z Indexed on 2010/03/11 17:49 UTC
Read the original article Hit count: 246

Hello,

for some reason I'm experiencing the Operational Error with "can't rollback" message when I attempt to roll back my transaction in the following context:

try:
    cursors[instance].execute("lock revision, app, timeout IN SHARE MODE")
    cursors[instance].execute("insert into app (type, active, active_revision, contents, z) values ('session', true, %s, %s, 0) returning id", (cRevision, sessionId))
    sAppId = cursors[instance].fetchone()[0]
    cursors[instance].execute("insert into revision (app_id, type) values (%s, 'active')", (sAppId,))
    cursors[instance].execute("insert into timeout (app_id, last_seen) values (%s, now())", (sAppId,))
    connections[instance].commit()
except pgdb.DatabaseError, e:
    connections[instance].rollback()
    return "{status: 'error', errno:4, errmsg: \"%s\"}"%(str(e).replace('\"', '\\"').replace('\n', '\\n').replace('\r', '\\r'))

The driver in use is PGDB.

What is fundamentally wrong here?

© Stack Overflow or respective owner

Related posts about postgresql

Related posts about exception