Answer the question
In order to leave comments, you need to log in
How to overcome the "psycopg2.ProgrammingError..." error?
Hey!
I keep getting an error
psycopg2.ProgrammingError: execute cannot be used while an asynchronous query is underway
def wait(conn):
while True:
state = conn.poll()
if state == psycopg2.extensions.POLL_OK:
break
elif state == psycopg2.extensions.POLL_WRITE:
select.select([], [conn.fileno()], [])
elif state == psycopg2.extensions.POLL_READ:
select.select([conn.fileno()], [], [])
else:
raise psycopg2.OperationalError("poll() returned %s" % state)
try:
aconn = psycopg2.connect(f"dbname='{db_name}' user='{db_user}' host='{db_host}' password='{db_pass}'", async_=1)
wait(aconn)
c = aconn.cursor()
except Exception as e:
print('Нет соединения с базой:', str(e))
@socketio.on('uploaddata')
def on_send(data):
id = data['id']
lablvlid = data['lablvlID']
player = data['player']
s = f"select * from cart_plcl where id='{id}' and lablvlid ='{lablvlid}' and player='{player}'"
c.execute(s)
wait(c.connection)
result = c.fetchall()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question