psycopg, transactions and multiple cursors
Alban Hertroys
alban at magproductions.nl
Mon Nov 8 08:19:19 EST 2004
Alban Hertroys wrote:
> Attached is a simplified example (the except's are a bit blunt, I know)
> of what I'm trying to do. In reality, the different cursors are
> sometimes run in differeent threads, or they're nested, which is why I
> can't use the same cursor for all queries.
I suppose the actual error message would be useful too (Doh!):
> python transaction.py
{'id': 1L}
Traceback (most recent call last):
File "transaction.py", line 40, in ?
cursor2.execute("INSERT INTO y (x_id) VALUES (%s)" % row["id"])
psycopg.IntegrityError: ERROR: insert or update on table "y" violates
foreign key constraint "$1"
DETAIL: Key (x_id)=(1) is not present in table "x".
INSERT INTO y (x_id) VALUES (1)
More information about the Python-list
mailing list