sqlalchemy_aio
sqlalchemy_aio copied to clipboard
execute() never returns if DB is empty
While testing, I found a curious behaviour:
result = await conn.execute(data.select().where(data.c.owner == ctx.author.id))
This works properly if there is data, both when data is found and when not found.
However, if the DB is not initialized, it will hang. It never returns, neither with a success nor with a failure.
(using sqlite, btw.)
Please provide an MCVE.
I tried variants of this and wasn't able to reproduce:
import asyncio
import os
from sqlalchemy_aio import ASYNCIO_STRATEGY
from sqlalchemy import Column, Integer, MetaData, Table, create_engine
from sqlalchemy.schema import CreateTable
meta = MetaData()
data = Table('data', meta, Column('owner', Integer))
async def main():
try:
os.unlink('test.db')
except FileNotFoundError:
pass
engine = create_engine('sqlite:///test.db', strategy=ASYNCIO_STRATEGY)
async with engine.connect() as conn:
await conn.execute(CreateTable(data))
result = await conn.execute(data.select().where(data.c.owner == 1))
print(result)
if __name__ == '__main__':
asyncio.run(main())