Below is the definition for my get request. The first request returns data successfully. The successive requests error out with error : asyncpg.exceptions._base.InterfaceError: cannot perform operation: another operation is in progress
@app.route("/getreportdetails/")
async def data():
sql = f"select * " \
f"from get_report_details "
report_data = await query(sql)
I am connecting to postgres database using asyncpg. Here is the code.
pool = None
async def get_pool():
pool = await asyncpg.create_pool(**config.servers.db_credentials)
return pool
async def query(sql):
global pool
print(sql)
if pool is None:
pool = await get_pool()
async with pool.acquire() as connection:
async with connection.transaction():
result = await connection.fetch(sql)
print(result)
return result