Skip to content

Commit d00e690

Browse files
committed
Slightly amended do_execute... dialect methods to store their response
... into the request context instance.
1 parent c673331 commit d00e690

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## Unreleased
44
- Propagate error traces properly, using the `error_trace` `connect_args` option,
55
by using `crate-1.0.0dev1`
6+
- Use slightly amended `do_execute`, `do_execute_no_params`, `do_executemany`
7+
to store their responses into the request context instance
68

79
## 2024/08/29 0.39.0
810
- Added `quote_relation_name` support utility function

src/sqlalchemy_cratedb/dialect.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,30 @@ def connect(self, host=None, port=None, *args, **kwargs):
233233
return self.dbapi.connect(servers=servers, **kwargs)
234234
return self.dbapi.connect(**kwargs)
235235

236+
def do_execute(self, cursor, statement, parameters, context=None):
237+
"""
238+
Slightly amended to store its response into the request context instance.
239+
"""
240+
result = cursor.execute(statement, parameters)
241+
if context is not None:
242+
context.last_result = result
243+
244+
def do_execute_no_params(self, cursor, statement, context=None):
245+
"""
246+
Slightly amended to store its response into the request context instance.
247+
"""
248+
result = cursor.execute(statement)
249+
if context is not None:
250+
context.last_result = result
251+
252+
def do_executemany(self, cursor, statement, parameters, context=None):
253+
"""
254+
Slightly amended to store its response into the request context instance.
255+
"""
256+
result = cursor.executemany(statement, parameters)
257+
if context is not None:
258+
context.last_result = result
259+
236260
def _get_default_schema_name(self, connection):
237261
return "doc"
238262

0 commit comments

Comments
 (0)