Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SHELL=/bin/bash

lint:
ruff .
ruff check .

test: lint
python ./test/test.py -v
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[tool.ruff]
line-length=120
[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"sqlalchemy_aurora_data_api/__init__.py" = ["E401", "F401"]
12 changes: 9 additions & 3 deletions sqlalchemy_aurora_data_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import json, datetime, re

from sqlalchemy import cast, func, util
from sqlalchemy import cast, func, util, text
import sqlalchemy.sql.sqltypes as sqltypes
from sqlalchemy.dialects.postgresql.base import PGDialect
from sqlalchemy.dialects.postgresql import JSON, JSONB, UUID, DATE, TIME, TIMESTAMP, ARRAY, ENUM
Expand Down Expand Up @@ -144,10 +144,16 @@ def import_dbapi(cls):
return aurora_data_api

def _detect_charset(self, connection):
return connection.execute("SHOW VARIABLES LIKE 'character_set_client'").fetchone()[1]
return connection.execute(text("SHOW VARIABLES LIKE 'character_set_client'")).fetchone()[1]

def _extract_error_code(self, exception):
return exception.args[0].value
error_str = str(exception.args[0])
match = re.search(r"Error code:\s*(\d+);\s*SQLState:\s*([A-Z0-9]+)", error_str)
error_code = None
if match:
error_code = int(match.group(1))
# sql_state = match.group(2)
return error_code


class AuroraPostgresDataAPIDialect(PGDialect):
Expand Down