Skip to content

Commit

Permalink
Slightly amended do_execute... dialect methods to store their response
Browse files Browse the repository at this point in the history
... into the request context instance.
  • Loading branch information
amotl committed Oct 6, 2024
1 parent c673331 commit d00e690
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## Unreleased
- Propagate error traces properly, using the `error_trace` `connect_args` option,
by using `crate-1.0.0dev1`
- Use slightly amended `do_execute`, `do_execute_no_params`, `do_executemany`
to store their responses into the request context instance

## 2024/08/29 0.39.0
- Added `quote_relation_name` support utility function
Expand Down
24 changes: 24 additions & 0 deletions src/sqlalchemy_cratedb/dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,30 @@ def connect(self, host=None, port=None, *args, **kwargs):
return self.dbapi.connect(servers=servers, **kwargs)
return self.dbapi.connect(**kwargs)

def do_execute(self, cursor, statement, parameters, context=None):
"""
Slightly amended to store its response into the request context instance.
"""
result = cursor.execute(statement, parameters)
if context is not None:
context.last_result = result

def do_execute_no_params(self, cursor, statement, context=None):
"""
Slightly amended to store its response into the request context instance.
"""
result = cursor.execute(statement)
if context is not None:
context.last_result = result

def do_executemany(self, cursor, statement, parameters, context=None):
"""
Slightly amended to store its response into the request context instance.
"""
result = cursor.executemany(statement, parameters)
if context is not None:
context.last_result = result

def _get_default_schema_name(self, connection):
return "doc"

Expand Down

0 comments on commit d00e690

Please sign in to comment.