возвращаюсь к вопросу про aiomysql. Пытаюсь запустить под 3.7 вот такой код:
from db.schema.cfgphone import devices
async def get_engine(loop):
engine = await create_engine(host=environ.get("MYSQL_HOST", "host"), port=3306,
user=environ.get("MYSQL_USER", "user"),
password=environ.get("MYSQL_PASSWORD", "password"),
db=environ.get("MYSQL_DB", "db"), loop=loop,
echo=True)
return engine
async def test_conn(loop):
engine = await get_engine(loop)
async with engine.acquire() as conn:
async for row in conn.execute(devices.select()):
print(row)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(test_conn(loop))
получаю ошибку
db_app.py:10: RuntimeWarning: coroutine '_SAConnectionContextManager.__aiter__' was never awaited
async for row in conn.execute(devices.select()):
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
db_app.py:10: RuntimeWarning: coroutine 'SAConnection._execute' was never awaited
async for row in conn.execute(devices.select()):
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Traceback (most recent call last):
File "db_app.py", line 16, in <module>
loop.run_until_complete(test_conn(loop))
File "/usr/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
return future.result()
File "db_app.py", line 10, in test_conn
async for row in conn.execute(devices.select()):
TypeError: 'async for' received an object from __aiter__ that does not implement __anext__: coroutine