E
E
Elvinchik2021-12-06 22:22:33
Python
Elvinchik, 2021-12-06 22:22:33

Problem in psycopg2?

cursor.execute(f"SELECT id FROM property WHERE id = {member.id} and server_id = {server}")
psycopg2.errors.InFailedSqlTransaction: current transaction is aborted, commands ignored until end of transaction block
What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ScriptKiddo, 2021-12-06
@ScriptKiddo

The problem is that the previous request ended with an error and the transaction must be rolled back, or the construction with with must be used, then the transaction will be automatically rolled back if an error
occurs https://www.psycopg.org/docs/connection.html#conne...

conn = psycopg2.connect(DSN)

with conn:
    with conn.cursor() as curs:
        curs.execute(SQL1)

conn.close()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question