Skip to content

Commit f820dcd

Browse files
mathiasrittergithub@mathias.engineer
authored andcommitted
SQLAlchemy 2.0 Compatibility
In the do_execute function of SQLAlchemy dialect, an if statement was accessing context.should_autocommit. This property has been removed in SQLAlchemy 2.0. To fix, the if statement can simply be removed as it is no longer needed.
1 parent 8affa61 commit f820dcd

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
version = str(ast.literal_eval(trino_version.group(1)))
2727

2828
kerberos_require = ["requests_kerberos"]
29-
sqlalchemy_require = ["sqlalchemy~=1.3"]
29+
sqlalchemy_require = ["sqlalchemy >= 1.3"]
3030
external_authentication_token_cache_require = ["keyring"]
3131

3232
# We don't add localstorage_require to all_require as users must explicitly opt in to use keyring.
@@ -79,7 +79,7 @@
7979
"Programming Language :: Python :: Implementation :: PyPy",
8080
"Topic :: Database :: Front-Ends",
8181
],
82-
python_requires='>=3.7',
82+
python_requires=">=3.7",
8383
install_requires=["pytz", "requests", "tzlocal"],
8484
extras_require={
8585
"all": all_require,

trino/sqlalchemy/dialect.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,6 @@ def do_execute(
363363
self, cursor: Cursor, statement: str, parameters: Tuple[Any, ...], context: DefaultExecutionContext = None
364364
):
365365
cursor.execute(statement, parameters)
366-
if context and context.should_autocommit:
367-
# SQL statement only submitted to Trino server when cursor.fetch*() is called.
368-
# For DDL (CREATE/ALTER/DROP) and DML (INSERT/UPDATE/DELETE) statement, call cursor.description
369-
# to force submit statement immediately.
370-
cursor.description # noqa
371366

372367
def do_rollback(self, dbapi_connection: trino_dbapi.Connection):
373368
if dbapi_connection.transaction is not None:

0 commit comments

Comments
 (0)