class AwaitRequired(InvalidRequestError):
"""Error raised by the async greenlet spawn if no async operation
- was awaited when it required one
+ was awaited when it required one.
"""
await self.conn.close()
def __init__(self, sync_engine: Engine):
+ if not sync_engine.dialect.is_async:
+ raise exc.InvalidRequestError(
+ "The asyncio extension requires an async driver to be used. "
+ f"The loaded {sync_engine.dialect.driver!r} is not async."
+ )
self.sync_engine = self._proxied = sync_engine
def begin(self):
import asyncio
from sqlalchemy import Column
+from sqlalchemy import create_engine
from sqlalchemy import delete
from sqlalchemy import event
from sqlalchemy import exc
class TextSyncDBAPI(fixtures.TestBase):
+ def test_sync_dbapi_raises(self):
+ with expect_raises_message(
+ exc.InvalidRequestError,
+ "The asyncio extension requires an async driver to be used.",
+ ):
+ create_async_engine("sqlite:///:memory:")
+
@testing.fixture
def async_engine(self):
- return create_async_engine("sqlite:///:memory:")
+ engine = create_engine("sqlite:///:memory:", future=True)
+ engine.dialect.is_async = True
+ return _async_engine.AsyncEngine(engine)
@async_test
@combinations(