sqlalchemy-firebird-async 0.2.3__tar.gz → 0.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/PKG-INFO +1 -1
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/pyproject.toml +1 -1
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/src/sqlalchemy_firebird_async/compiler.py +10 -6
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/src/sqlalchemy_firebird_async/fdb.py +26 -4
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/src/sqlalchemy_firebird_async/firebirdsql.py +7 -5
- sqlalchemy_firebird_async-0.2.3/repro_cast.py +0 -25
- sqlalchemy_firebird_async-0.2.3/test_output.txt +0 -2483
- sqlalchemy_firebird_async-0.2.3/test_output_after_fix.txt +0 -2390
- sqlalchemy_firebird_async-0.2.3/test_output_final.txt +0 -2181
- sqlalchemy_firebird_async-0.2.3/test_output_full.txt +0 -1158
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/.claude/settings.local.json +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/.gitignore +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/CONTRIBUTING.md +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/LICENSE +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/README.md +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/justfile +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/pytest.ini +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/src/sqlalchemy_firebird_async/__init__.py +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/src/sqlalchemy_firebird_async/firebird_driver.py +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/src/sqlalchemy_firebird_async/types.py +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/tests/__init__.py +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/tests/conftest.py +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/tests/requirements.py +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/tests/test_basic.py +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/tests/test_compliance.py +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/tests/test_enum.py +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/tests/test_load.py +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/tests/test_terminate.py +0 -0
- {sqlalchemy_firebird_async-0.2.3 → sqlalchemy_firebird_async-0.2.5}/tests/test_types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlalchemy-firebird-async
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Asyncio support for Firebird in SQLAlchemy
|
|
5
5
|
Project-URL: Homepage, https://github.com/attid/sqlalchemy-firebird-async
|
|
6
6
|
Project-URL: Repository, https://github.com/attid/sqlalchemy-firebird-async
|
|
@@ -31,13 +31,17 @@ class PatchedFBTypeCompiler(FBTypeCompiler):
|
|
|
31
31
|
text += f" COLLATE {collation}"
|
|
32
32
|
return text
|
|
33
33
|
|
|
34
|
-
# Fix for TypeError: unsupported operand type(s) for +: 'int' and 'str'
|
|
35
34
|
if not isinstance(name, str):
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
name
|
|
35
|
+
name = getattr(type_, "__visit_name__", "VARCHAR").upper()
|
|
36
|
+
|
|
37
|
+
if hasattr(super(), "_render_firebird_string_type"):
|
|
38
|
+
return super()._render_firebird_string_type(
|
|
39
|
+
name,
|
|
40
|
+
length_override,
|
|
41
|
+
getattr(type_, "collation", None),
|
|
42
|
+
getattr(type_, "charset", None),
|
|
43
|
+
)
|
|
44
|
+
|
|
41
45
|
return super()._render_string_type(type_, name, length_override)
|
|
42
46
|
|
|
43
47
|
def visit_VARCHAR(self, type_, **kw):
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
from math import modf
|
|
2
3
|
from concurrent.futures import ThreadPoolExecutor
|
|
3
4
|
from functools import partial
|
|
5
|
+
from sqlalchemy import util
|
|
4
6
|
from sqlalchemy.util.concurrency import await_only
|
|
5
7
|
from greenlet import getcurrent
|
|
6
8
|
|
|
@@ -162,8 +164,8 @@ class AsyncDBAPI:
|
|
|
162
164
|
return AsyncConnection(sync_conn, loop, executor)
|
|
163
165
|
|
|
164
166
|
from sqlalchemy.pool import AsyncAdaptedQueuePool
|
|
167
|
+
from sqlalchemy_firebird.base import FBDialect
|
|
165
168
|
from sqlalchemy_firebird.base import FBExecutionContext
|
|
166
|
-
import sqlalchemy_firebird.fdb as fdb
|
|
167
169
|
from .compiler import PatchedFBCompiler, PatchedFBDDLCompiler, PatchedFBTypeCompiler
|
|
168
170
|
from .types import FBCHARCompat, FBVARCHARCompat
|
|
169
171
|
from sqlalchemy import String, DateTime, Time, TIMESTAMP, VARCHAR, CHAR
|
|
@@ -187,7 +189,7 @@ class AsyncFDBExecutionContext(FBExecutionContext):
|
|
|
187
189
|
driver_conn.begin()
|
|
188
190
|
|
|
189
191
|
|
|
190
|
-
class AsyncFDBDialect(
|
|
192
|
+
class AsyncFDBDialect(FBDialect):
|
|
191
193
|
name = "firebird.fdb_async"
|
|
192
194
|
driver = "fdb_async"
|
|
193
195
|
is_async = True
|
|
@@ -196,12 +198,12 @@ class AsyncFDBDialect(fdb.FBDialect_fdb):
|
|
|
196
198
|
statement_compiler = PatchedFBCompiler
|
|
197
199
|
ddl_compiler = PatchedFBDDLCompiler
|
|
198
200
|
execution_ctx_cls = AsyncFDBExecutionContext
|
|
199
|
-
ischema_names =
|
|
201
|
+
ischema_names = FBDialect.ischema_names.copy()
|
|
200
202
|
ischema_names["TEXT"] = FBCHARCompat
|
|
201
203
|
ischema_names["VARYING"] = FBVARCHARCompat
|
|
202
204
|
ischema_names["CSTRING"] = FBVARCHARCompat
|
|
203
205
|
|
|
204
|
-
colspecs =
|
|
206
|
+
colspecs = FBDialect.colspecs.copy()
|
|
205
207
|
colspecs[String] = _FBSafeString
|
|
206
208
|
colspecs[VARCHAR] = _FBSafeString
|
|
207
209
|
colspecs[CHAR] = _FBSafeString
|
|
@@ -215,6 +217,26 @@ class AsyncFDBDialect(fdb.FBDialect_fdb):
|
|
|
215
217
|
self.type_compiler_instance = PatchedFBTypeCompiler(self)
|
|
216
218
|
self.type_compiler = self.type_compiler_instance
|
|
217
219
|
|
|
220
|
+
def create_connect_args(self, url):
|
|
221
|
+
opts = url.translate_connect_args(username="user")
|
|
222
|
+
if opts.get("port"):
|
|
223
|
+
opts["host"] = "%s/%s" % (opts["host"], opts["port"])
|
|
224
|
+
del opts["port"]
|
|
225
|
+
opts.update(url.query)
|
|
226
|
+
|
|
227
|
+
util.coerce_kw_type(opts, "type_conv", int)
|
|
228
|
+
|
|
229
|
+
return ([], opts)
|
|
230
|
+
|
|
231
|
+
def _get_server_version_info(self, connection):
|
|
232
|
+
dbapi_connection = (
|
|
233
|
+
connection.connection.dbapi_connection
|
|
234
|
+
if self.using_sqlalchemy2
|
|
235
|
+
else connection.connection
|
|
236
|
+
)
|
|
237
|
+
minor, major = modf(dbapi_connection.engine_version)
|
|
238
|
+
return (int(major), int(minor * 10))
|
|
239
|
+
|
|
218
240
|
def dbapi_exception_translation(self, exception, statement, parameters, context):
|
|
219
241
|
from sqlalchemy import exc
|
|
220
242
|
|
|
@@ -6,8 +6,8 @@ from greenlet import getcurrent
|
|
|
6
6
|
|
|
7
7
|
import firebirdsql
|
|
8
8
|
import firebirdsql.aio as aio
|
|
9
|
-
|
|
10
|
-
from .compiler import PatchedFBTypeCompiler
|
|
9
|
+
from sqlalchemy_firebird.base import FBDialect
|
|
10
|
+
from .compiler import PatchedFBCompiler, PatchedFBDDLCompiler, PatchedFBTypeCompiler
|
|
11
11
|
from sqlalchemy import String
|
|
12
12
|
from .types import _FBSafeString
|
|
13
13
|
|
|
@@ -134,14 +134,16 @@ class AsyncPyfbDBAPI:
|
|
|
134
134
|
return firebirdsql.Binary(value)
|
|
135
135
|
|
|
136
136
|
|
|
137
|
-
class AsyncFirebirdSQLDialect(
|
|
137
|
+
class AsyncFirebirdSQLDialect(FBDialect):
|
|
138
138
|
name = "firebird.firebirdsql_async"
|
|
139
139
|
driver = "firebirdsql_async"
|
|
140
140
|
is_async = True
|
|
141
141
|
supports_statement_cache = False
|
|
142
142
|
poolclass = AsyncAdaptedQueuePool
|
|
143
|
+
statement_compiler = PatchedFBCompiler
|
|
144
|
+
ddl_compiler = PatchedFBDDLCompiler
|
|
143
145
|
|
|
144
|
-
colspecs =
|
|
146
|
+
colspecs = FBDialect.colspecs.copy()
|
|
145
147
|
colspecs[String] = _FBSafeString
|
|
146
148
|
|
|
147
149
|
def __init__(self, *args, **kwargs):
|
|
@@ -192,4 +194,4 @@ class AsyncFirebirdSQLDialect(fdb.FBDialect_fdb):
|
|
|
192
194
|
minor = int(parts[1]) if len(parts) > 1 else 0
|
|
193
195
|
return (major, minor)
|
|
194
196
|
except (ValueError, IndexError):
|
|
195
|
-
return (0, 0)
|
|
197
|
+
return (0, 0)
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import firebird.driver as driver
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
user = os.environ.get("ISC_USER", "sysdba")
|
|
5
|
-
password = os.environ.get("ISC_PASSWORD", "masterkey")
|
|
6
|
-
host = os.environ.get("ISC_HOST", "localhost")
|
|
7
|
-
database = os.environ.get("ISC_DATABASE", "/tmp/test.fdb")
|
|
8
|
-
|
|
9
|
-
dsn = f"{host}:{database}"
|
|
10
|
-
|
|
11
|
-
print(f"Connecting to {dsn} with user {user}...")
|
|
12
|
-
|
|
13
|
-
try:
|
|
14
|
-
con = driver.connect(dsn, user=user, password=password)
|
|
15
|
-
cur = con.cursor()
|
|
16
|
-
|
|
17
|
-
# Test CAST with TIMESTAMP(6)
|
|
18
|
-
sql = "SELECT CAST('2023-01-01 10:00:00' AS TIMESTAMP(6)) FROM RDB$DATABASE"
|
|
19
|
-
print(f"Executing: {sql}")
|
|
20
|
-
cur.execute(sql)
|
|
21
|
-
print("Success!")
|
|
22
|
-
|
|
23
|
-
con.close()
|
|
24
|
-
except Exception as e:
|
|
25
|
-
print(f"Failed: {e}")
|