I am new to async await and trying to use it for getting response from a SQL db query method defined at an end point
@router.get('/queryDAS')
async def fetch_das_db():
response = await DASDBData().get_all()
logger.info("---ASYNCRONOUS----")
return (json.dumps(response))
but all I get is this error : response = await DASDBData().get_all() TypeError: object list can't be used in 'await' expression
def get_all(self):
"""Get all new data.
@returns:
Return list of dictionaries with team information.
"""
result=[]
statement = """SELECT *
FROM CAE_APPR_ITEM_RESPONSE WHERE ROWNUM <= 500
"""
logger.debug(statement)
cur = self.connection.create_connection().cursor()
cur.execute(statement)
for row in cur:
print(row)
result.append(row)
#return (200,result)
return result
I thought that the message "---ASYNCHRONOUS---" would be printed first as the get_all method would go inside the event_loop but it didnt get printed as well