I am having issues ietrating over results from SQL query with using encode databases (https://pypi.org/project/databases/) but this sqlalchemy query works fine for the celery tasks
query = session.query(orders).filter(orders.shipped == True)
I have tried the following (celery task unable to iterate over multiple rows from postgresql database with python) but does not work
def check_all_orders():
query = "SELECT * FROM orders WHERE shipped=True"
return database.fetch_all(query)
...
...
...
@app.task
async def check_orders():
query = await check_all_orders()
today = datetime.utcnow()
for q in query:
if q.last_notification is not None:
if (today - q.last_notification).total_seconds() < q.cooldown:
continue
Does anyone know what SQL statement will generate what i can iterate like it does for this sqlalchemy query?
query = session.query(orders).filter(orders.shipped == True)