summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/asyncio/engine.py
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2021-02-06 12:11:54 +0100
committerFederico Caselli <cfederico87@gmail.com>2021-02-06 12:11:54 +0100
commit23e088bccff02f18e4a27ef9dfc656c814695525 (patch)
tree3237cc438cc69e818474964df8feb21aa0cc566f /lib/sqlalchemy/ext/asyncio/engine.py
parentbc9221bf781adfffdddf12860d4eed7650457a0a (diff)
downloadsqlalchemy-23e088bccff02f18e4a27ef9dfc656c814695525.tar.gz
Detect non async driver on engine creation
An error is raised when creating an async engine with an incompatible dbapi. Before the error was raised only when first using the engine. Change-Id: I977952b4c03ae51f568749ad744c545197bcd887 Reference: #5920
Diffstat (limited to 'lib/sqlalchemy/ext/asyncio/engine.py')
-rw-r--r--lib/sqlalchemy/ext/asyncio/engine.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/sqlalchemy/ext/asyncio/engine.py b/lib/sqlalchemy/ext/asyncio/engine.py
index aa7e60dfb..db95ab371 100644
--- a/lib/sqlalchemy/ext/asyncio/engine.py
+++ b/lib/sqlalchemy/ext/asyncio/engine.py
@@ -527,6 +527,11 @@ class AsyncEngine(ProxyComparable, AsyncConnectable):
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):