Answer the question
In order to leave comments, you need to log in
Why did postgres query stop working in Python?
Hello.
I am using connection to Postgresql 11 via psycopg2.
The code worked fine before.
def get_switch(self):
with self.conn:
self.cursor.execute('SELECT switch FROM switches WHERE id=7')
return self.cursor.fetchone()[0]
def change_switch(self):
with self.conn:
switch = self.get_switch()
self.cursor.execute('UPDATE switches SET switch=%s WHERE id=7', (not switch,))
self.conn.commit()
in get_switch
with self.conn:
psycopg2.ProgrammingError: the connection cannot be re-entered recursively
Answer the question
In order to leave comments, you need to log in
It swears precisely at the fact that another with conn was launched inside one with conn. Check your code.
Judging by the documentation and googling reviews, this error began to be issued from version 2.9, so maybe they just ran it on an older version earlier, so they didn’t meet it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question