Skip to content

Commit 0308865

Browse files
mdesmethashhar
authored andcommitted
Expose query_id property on dbapi.Cursor
1 parent f4d0ed1 commit 0308865

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

tests/integration/test_dbapi_integration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def test_select_query(trino_connection):
7777
assert columns["node_version"] == "varchar"
7878
assert columns["coordinator"] == "boolean"
7979
assert columns["state"] == "varchar"
80+
assert cur.query_id is not None
81+
assert cur.stats is not None
8082

8183

8284
def test_select_query_result_iteration(trino_connection):

trino/dbapi.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import math
2222
import uuid
2323
from decimal import Decimal
24-
from typing import Any, List, Optional # NOQA for mypy types
24+
from typing import Any, Dict, List, Optional # NOQA for mypy types
2525

2626
import trino.client
2727
import trino.exceptions
@@ -289,6 +289,12 @@ def stats(self):
289289
return self._query.stats
290290
return None
291291

292+
@property
293+
def query_id(self) -> Optional[str]:
294+
if self._query is not None:
295+
return self._query.query_id
296+
return None
297+
292298
@property
293299
def warnings(self):
294300
if self._query is not None:

0 commit comments

Comments
 (0)