-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Retry SQLAlchemy engine creation for adapters without JSON SerDe…
… support (#1949) * fix: Retry SQLAlchemy engine creation for adapters without JSON SerDe support * Add test * Fix for SQLAlchemy 1
- Loading branch information
1 parent
0fb0c1b
commit fca070e
Showing
4 changed files
with
67 additions
and
7 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from __future__ import annotations | ||
|
||
import typing as t | ||
|
||
from sqlalchemy.engine.default import DefaultDialect | ||
|
||
if t.TYPE_CHECKING: | ||
from types import ModuleType | ||
|
||
|
||
class CustomSQLDialect(DefaultDialect): | ||
"""Custom SQLite dialect that supports JSON.""" | ||
|
||
name = "myrdbms" | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
@classmethod | ||
def import_dbapi(cls): | ||
"""Import the sqlite3 DBAPI.""" | ||
import sqlite3 | ||
|
||
return sqlite3 | ||
|
||
@classmethod | ||
def dbapi(cls) -> ModuleType: # type: ignore[override] | ||
"""Return the DBAPI module. | ||
NOTE: This is a legacy method that will stop being used by SQLAlchemy at some point. | ||
""" # noqa: E501 | ||
return cls.import_dbapi() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters