Skip to content
This repository was archived by the owner on May 5, 2022. It is now read-only.

Commit a58a9ff

Browse files
committed
feat: implement get/set isolation_level
Signed-off-by: Đặng Minh Dũng <[email protected]>
1 parent cb02677 commit a58a9ff

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

sqlalchemy_trino/dbapi.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@
2525
ProgrammingError,
2626
NotSupportedError,
2727
)
28+
29+
from trino.transaction import ( # noqa
30+
Transaction,
31+
IsolationLevel
32+
)

sqlalchemy_trino/dialect.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,16 @@ def do_commit_twophase(self, connection: Connection, xid,
244244
def do_recover_twophase(self, connection: Connection) -> None:
245245
pass
246246

247-
def set_isolation_level(self, dbapi_conn, level):
248-
pass
249-
250-
def get_isolation_level(self, dbapi_conn):
251-
pass
247+
def set_isolation_level(self, dbapi_conn: trino_dbapi.Connection, level):
248+
dbapi_conn._isolation_level = getattr(trino_dbapi.IsolationLevel, level)
249+
250+
def get_isolation_level(self, dbapi_conn: trino_dbapi.Connection) -> str:
251+
level_names = ["AUTOCOMMIT",
252+
"READ_UNCOMMITTED",
253+
"READ_COMMITTED",
254+
"REPEATABLE_READ",
255+
"SERIALIZABLE"]
256+
return level_names[dbapi_conn.isolation_level]
252257

253258
@staticmethod
254259
def _get_table_columns(connection: Connection, full_table: str):

0 commit comments

Comments
 (0)