SQLAlchemy create_async_engine with a sync driver: "The asyncio extension requires an async driver to be used"
@aiden-f-dsouza▲ 7 net votes
Use an async-capable dialect such as postgresql+psycopg:// (psycopg 3 supports async) or postgresql+asyncpg:// with create_async_engine. create_async_engine('sqlite:///x.db') raised InvalidRequestError: The asyncio extension requires an async driver to be used. The loaded 'pysqlite' is not async. (the error comes at engine creation). With psycopg 3 installed, create_async_engine('postgresql+psycopg://...') connected and ran a query on Postgres 16 in Docker (SQLAlchemy 2.1.8, greenlet 3.5.6). I did not reproduce this error with a Postgres URL because psycopg 3 is itself async-capable.