sqlalchemy-firebirdsql 0.1.0__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.
Files changed (30) hide show
  1. sqlalchemy_firebirdsql-0.1.0/AUTHORS +30 -0
  2. sqlalchemy_firebirdsql-0.1.0/LICENSE +19 -0
  3. sqlalchemy_firebirdsql-0.1.0/PKG-INFO +162 -0
  4. sqlalchemy_firebirdsql-0.1.0/README.rst +119 -0
  5. sqlalchemy_firebirdsql-0.1.0/pyproject.toml +49 -0
  6. sqlalchemy_firebirdsql-0.1.0/setup.cfg +13 -0
  7. sqlalchemy_firebirdsql-0.1.0/sqlalchemy_firebirdsql/__init__.py +12 -0
  8. sqlalchemy_firebirdsql-0.1.0/sqlalchemy_firebirdsql/asyn.py +275 -0
  9. sqlalchemy_firebirdsql-0.1.0/sqlalchemy_firebirdsql/base.py +1719 -0
  10. sqlalchemy_firebirdsql-0.1.0/sqlalchemy_firebirdsql/ext.py +14 -0
  11. sqlalchemy_firebirdsql-0.1.0/sqlalchemy_firebirdsql/infrastructure.py +15 -0
  12. sqlalchemy_firebirdsql-0.1.0/sqlalchemy_firebirdsql/merge.py +45 -0
  13. sqlalchemy_firebirdsql-0.1.0/sqlalchemy_firebirdsql/provision.py +37 -0
  14. sqlalchemy_firebirdsql-0.1.0/sqlalchemy_firebirdsql/requirements.py +1796 -0
  15. sqlalchemy_firebirdsql-0.1.0/sqlalchemy_firebirdsql/syn.py +63 -0
  16. sqlalchemy_firebirdsql-0.1.0/sqlalchemy_firebirdsql/types.py +264 -0
  17. sqlalchemy_firebirdsql-0.1.0/sqlalchemy_firebirdsql.egg-info/PKG-INFO +162 -0
  18. sqlalchemy_firebirdsql-0.1.0/sqlalchemy_firebirdsql.egg-info/SOURCES.txt +29 -0
  19. sqlalchemy_firebirdsql-0.1.0/sqlalchemy_firebirdsql.egg-info/dependency_links.txt +1 -0
  20. sqlalchemy_firebirdsql-0.1.0/sqlalchemy_firebirdsql.egg-info/entry_points.txt +7 -0
  21. sqlalchemy_firebirdsql-0.1.0/sqlalchemy_firebirdsql.egg-info/requires.txt +2 -0
  22. sqlalchemy_firebirdsql-0.1.0/sqlalchemy_firebirdsql.egg-info/top_level.txt +1 -0
  23. sqlalchemy_firebirdsql-0.1.0/test/test_async.py +80 -0
  24. sqlalchemy_firebirdsql-0.1.0/test/test_compiler.py +726 -0
  25. sqlalchemy_firebirdsql-0.1.0/test/test_dialect.py +259 -0
  26. sqlalchemy_firebirdsql-0.1.0/test/test_ext.py +50 -0
  27. sqlalchemy_firebirdsql-0.1.0/test/test_merge.py +136 -0
  28. sqlalchemy_firebirdsql-0.1.0/test/test_query.py +741 -0
  29. sqlalchemy_firebirdsql-0.1.0/test/test_reflection.py +1228 -0
  30. sqlalchemy_firebirdsql-0.1.0/test/test_types.py +395 -0
@@ -0,0 +1,30 @@
1
+ SQLAlchemy was created by Michael Bayer.
2
+
3
+ Major contributing authors include:
4
+
5
+ - Mike Bayer
6
+ - Jason Kirtland
7
+ - Michael Trier
8
+ - Diana Clarke
9
+ - Gaetan de Menten
10
+ - Lele Gaifax
11
+ - Jonathan Ellis
12
+ - Gord Thompson
13
+ - Federico Caselli
14
+ - Philip Jenvey
15
+ - Rick Morrison
16
+ - Chris Withers
17
+ - Ants Aasma
18
+ - Sheila Allen
19
+ - Paul Johnston
20
+ - Tony Locke
21
+ - Hajime Nakagami
22
+ - Vraj Mohan
23
+ - Robert Leftwich
24
+ - Taavi Burns
25
+ - Jonathan Vanasco
26
+ - Jeff Widman
27
+ - Scott Dugas
28
+ - Dobes Vandermeer
29
+ - Ville Skytta
30
+ - Rodrigo Menezes
@@ -0,0 +1,19 @@
1
+ Copyright 2005-2026 SQLAlchemy authors and contributors <see AUTHORS file>.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,162 @@
1
+ Metadata-Version: 2.4
2
+ Name: sqlalchemy_firebirdsql
3
+ Version: 0.1.0
4
+ Summary: Firebird for SQLAlchemy
5
+ Author: F.D.Castel
6
+ Author-email: Paul Graves-DesLauriers <paul@dexmicro.com>, Hajime Nakagami <nakagami@gmail.com>
7
+ Maintainer-email: Hajime Nakagami <nakagami@gmail.com>
8
+ License: Copyright 2005-2026 SQLAlchemy authors and contributors <see AUTHORS file>.
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
11
+ this software and associated documentation files (the "Software"), to deal in
12
+ the Software without restriction, including without limitation the rights to
13
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14
+ of the Software, and to permit persons to whom the Software is furnished to do
15
+ so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Keywords: SQLAlchemy,Firebird,firebirdsql
29
+ Classifier: Development Status :: 4 - Beta
30
+ Classifier: Intended Audience :: Developers
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Programming Language :: Python
33
+ Classifier: Programming Language :: Python :: 3
34
+ Classifier: Programming Language :: Python :: Implementation :: CPython
35
+ Classifier: Topic :: Database :: Front-Ends
36
+ Classifier: Operating System :: OS Independent
37
+ Description-Content-Type: text/x-rst
38
+ License-File: LICENSE
39
+ License-File: AUTHORS
40
+ Requires-Dist: sqlalchemy>=2.0
41
+ Requires-Dist: firebirdsql
42
+ Dynamic: license-file
43
+
44
+ ============================
45
+ sqlalchemy-firebirdsql
46
+ ============================
47
+
48
+ `SQLAlchemy <https://www.sqlalchemy.org/>`_ dialect
49
+ for `Firebird <https://firebirdsql.org/en/start/>`_
50
+ using `pyfirebirdsql <https://github.com/nakagami/pyfirebirdsql>`_ .
51
+
52
+ It based on `sqlalchemy-firebird <https://github.com/pauldex/sqlalchemy-firebird>`_ , thanks.
53
+
54
+ Requirements
55
+ ++++++++++++++++
56
+
57
+ It is difficult to support many versions, so I target newer versions.
58
+
59
+ - Firebird 4.0+
60
+ - SQLAlchemy 2.0+
61
+ - Python 3.10+
62
+
63
+ Installation
64
+ ++++++++++++++++
65
+
66
+ ::
67
+
68
+ pip install sqlalchemy_firebirdsql
69
+
70
+ Connection strings
71
+ +++++++++++++++++++
72
+
73
+ A SQLAlchemy URL has the shape ``dialect+driver://username:password@host:port/database``.
74
+ For this dialect:
75
+
76
+ ::
77
+
78
+ firebirdsql+syn://user:password@host:port/path/to/db[?key=value&key=value...]
79
+
80
+ For async:
81
+
82
+ ::
83
+
84
+ firebirdsql+asyn://user:password@host:port/path/to/db[?key=value&key=value...]
85
+
86
+ The bare ``firebirdsql://`` scheme defaults to the synchronous (``syn``) driver.
87
+
88
+ Examples
89
+ --------
90
+
91
+ Local server, default port::
92
+
93
+ firebirdsql+syn://sysdba:masterkey@localhost//home/me/databases/my_project.fdb
94
+
95
+ Remote server on port 3050::
96
+
97
+ firebirdsql+syn://sysdba:masterkey@example.com:3050//srv/databases/my_project.fdb
98
+
99
+ Usage
100
+ ++++++++++++++++
101
+
102
+ Synchronous
103
+ -----------
104
+
105
+ .. code-block:: python
106
+
107
+ from sqlalchemy import create_engine, text
108
+
109
+ engine = create_engine(
110
+ "firebirdsql+syn://sysdba:masterkey@localhost//home/me/databases/my_project.fdb",
111
+ echo=True,
112
+ )
113
+
114
+ with engine.connect() as conn:
115
+ result = conn.execute(text("select 1 from rdb$database"))
116
+ print(result.scalar())
117
+
118
+ Asynchronous
119
+ ------------
120
+
121
+ .. code-block:: python
122
+
123
+ import asyncio
124
+ from sqlalchemy import text
125
+ from sqlalchemy.ext.asyncio import create_async_engine
126
+
127
+ engine = create_async_engine(
128
+ "firebirdsql+asyn://sysdba:masterkey@localhost//home/me/databases/my_project.fdb",
129
+ echo=True,
130
+ )
131
+
132
+ async def main():
133
+ async with engine.connect() as conn:
134
+ result = await conn.execute(text("select 1 from rdb$database"))
135
+ print(result.scalar())
136
+
137
+ asyncio.run(main())
138
+
139
+ How to test
140
+ ++++++++++++++++
141
+
142
+ Clone and install
143
+ --------------------
144
+
145
+ ::
146
+
147
+ git clone git@github.com:nakagami/sqlalchemy_firebirdsql.git
148
+ cd sqlalchemy_firebirdsql
149
+ python3 -m venv .venv
150
+ . .venv/bin/activate
151
+ pip install -e .
152
+ pip install pytest
153
+
154
+ Create test database and execute pytest
155
+ -------------------------------------------
156
+
157
+ ::
158
+
159
+ prepare-test-environment
160
+ pytest --db syn
161
+ pytest --db asyn
162
+
@@ -0,0 +1,119 @@
1
+ ============================
2
+ sqlalchemy-firebirdsql
3
+ ============================
4
+
5
+ `SQLAlchemy <https://www.sqlalchemy.org/>`_ dialect
6
+ for `Firebird <https://firebirdsql.org/en/start/>`_
7
+ using `pyfirebirdsql <https://github.com/nakagami/pyfirebirdsql>`_ .
8
+
9
+ It based on `sqlalchemy-firebird <https://github.com/pauldex/sqlalchemy-firebird>`_ , thanks.
10
+
11
+ Requirements
12
+ ++++++++++++++++
13
+
14
+ It is difficult to support many versions, so I target newer versions.
15
+
16
+ - Firebird 4.0+
17
+ - SQLAlchemy 2.0+
18
+ - Python 3.10+
19
+
20
+ Installation
21
+ ++++++++++++++++
22
+
23
+ ::
24
+
25
+ pip install sqlalchemy_firebirdsql
26
+
27
+ Connection strings
28
+ +++++++++++++++++++
29
+
30
+ A SQLAlchemy URL has the shape ``dialect+driver://username:password@host:port/database``.
31
+ For this dialect:
32
+
33
+ ::
34
+
35
+ firebirdsql+syn://user:password@host:port/path/to/db[?key=value&key=value...]
36
+
37
+ For async:
38
+
39
+ ::
40
+
41
+ firebirdsql+asyn://user:password@host:port/path/to/db[?key=value&key=value...]
42
+
43
+ The bare ``firebirdsql://`` scheme defaults to the synchronous (``syn``) driver.
44
+
45
+ Examples
46
+ --------
47
+
48
+ Local server, default port::
49
+
50
+ firebirdsql+syn://sysdba:masterkey@localhost//home/me/databases/my_project.fdb
51
+
52
+ Remote server on port 3050::
53
+
54
+ firebirdsql+syn://sysdba:masterkey@example.com:3050//srv/databases/my_project.fdb
55
+
56
+ Usage
57
+ ++++++++++++++++
58
+
59
+ Synchronous
60
+ -----------
61
+
62
+ .. code-block:: python
63
+
64
+ from sqlalchemy import create_engine, text
65
+
66
+ engine = create_engine(
67
+ "firebirdsql+syn://sysdba:masterkey@localhost//home/me/databases/my_project.fdb",
68
+ echo=True,
69
+ )
70
+
71
+ with engine.connect() as conn:
72
+ result = conn.execute(text("select 1 from rdb$database"))
73
+ print(result.scalar())
74
+
75
+ Asynchronous
76
+ ------------
77
+
78
+ .. code-block:: python
79
+
80
+ import asyncio
81
+ from sqlalchemy import text
82
+ from sqlalchemy.ext.asyncio import create_async_engine
83
+
84
+ engine = create_async_engine(
85
+ "firebirdsql+asyn://sysdba:masterkey@localhost//home/me/databases/my_project.fdb",
86
+ echo=True,
87
+ )
88
+
89
+ async def main():
90
+ async with engine.connect() as conn:
91
+ result = await conn.execute(text("select 1 from rdb$database"))
92
+ print(result.scalar())
93
+
94
+ asyncio.run(main())
95
+
96
+ How to test
97
+ ++++++++++++++++
98
+
99
+ Clone and install
100
+ --------------------
101
+
102
+ ::
103
+
104
+ git clone git@github.com:nakagami/sqlalchemy_firebirdsql.git
105
+ cd sqlalchemy_firebirdsql
106
+ python3 -m venv .venv
107
+ . .venv/bin/activate
108
+ pip install -e .
109
+ pip install pytest
110
+
111
+ Create test database and execute pytest
112
+ -------------------------------------------
113
+
114
+ ::
115
+
116
+ prepare-test-environment
117
+ pytest --db syn
118
+ pytest --db asyn
119
+
@@ -0,0 +1,49 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sqlalchemy_firebirdsql"
7
+ description = "Firebird for SQLAlchemy"
8
+ keywords = ["SQLAlchemy", "Firebird", "firebirdsql"]
9
+ license = {file = "LICENSE"}
10
+ authors = [
11
+ {name = "Paul Graves-DesLauriers", email="paul@dexmicro.com"},
12
+ {name = "F.D.Castel"},
13
+ {name = "Hajime Nakagami", email="nakagami@gmail.com"},
14
+ ]
15
+ maintainers = [
16
+ {name = "Hajime Nakagami", email="nakagami@gmail.com"},
17
+ ]
18
+ classifiers = [
19
+ "Development Status :: 4 - Beta",
20
+ "Intended Audience :: Developers",
21
+ "License :: OSI Approved :: MIT License",
22
+ "Programming Language :: Python",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: Implementation :: CPython",
25
+ "Topic :: Database :: Front-Ends",
26
+ "Operating System :: OS Independent",
27
+ ]
28
+ dependencies = [
29
+ "sqlalchemy>=2.0",
30
+ "firebirdsql",
31
+ ]
32
+ dynamic = ["readme", "version"]
33
+
34
+ [project.entry-points."sqlalchemy.dialects"]
35
+ "firebirdsql" = "sqlalchemy_firebirdsql.syn:FBDialect_syn"
36
+ "firebirdsql.syn" = "sqlalchemy_firebirdsql.syn:FBDialect_syn"
37
+ "firebirdsql.asyn" = "sqlalchemy_firebirdsql.asyn:FBDialect_asyn"
38
+
39
+ [project.scripts]
40
+ prepare-test-environment = "sqlalchemy_firebirdsql:infrastructure.prepare_test_environment"
41
+
42
+ [tool.setuptools.dynamic]
43
+ readme = {file = ["README.rst"], content-type = "text/x-rst"}
44
+ version = {attr = "sqlalchemy_firebirdsql.__version__"}
45
+
46
+ [tool.pytest.ini_options]
47
+ markers = [
48
+ "backend: mark test as a backend-specific test",
49
+ ]
@@ -0,0 +1,13 @@
1
+ [sqla_testing]
2
+ requirement_cls = sqlalchemy_firebirdsql.requirements:Requirements
3
+ profile_file = test/profiles.txt
4
+
5
+ [db]
6
+ default = firebirdsql+syn://sysdba:masterkey@localhost//tmp/test_firebirdsql_syn.fdb
7
+ syn = firebirdsql+syn://sysdba:masterkey@localhost//tmp/test_firebirdsql_syn.fdb
8
+ asyn = firebirdsql+asyn://sysdba:masterkey@localhost//tmp/test_firebirdsql_asyn.fdb
9
+
10
+ [egg_info]
11
+ tag_build =
12
+ tag_date = 0
13
+
@@ -0,0 +1,12 @@
1
+ # sqlalchemy_firebirdsql/__init__.py
2
+ # Copyright (C) 2005-2025 the SQLAlchemy authors and contributors
3
+ # <see AUTHORS file>
4
+ #
5
+ # This module is released under the MIT License: http://www.opensource.org/licenses/mit-license.php
6
+ from .ext import not_similar_to
7
+ from .ext import similar_to
8
+ from .merge import merge
9
+
10
+ __version__ = "0.1.0"
11
+
12
+ __all__ = ["merge", "not_similar_to", "similar_to", "__version__"]
@@ -0,0 +1,275 @@
1
+ # Copyright (C) 2005-2025 the SQLAlchemy authors and contributors <see AUTHORS
2
+ # file>
3
+ #
4
+ # This module is part of SQLAlchemy and is released under
5
+ # the MIT License: https://www.opensource.org/licenses/mit-license.php
6
+ # mypy: ignore-errors
7
+
8
+ r"""
9
+ .. dialect:: firebirdsql+asyn
10
+ :name: firebirdsql
11
+ :dbapi: firebirdsql
12
+ :connectstring: firebirdsql+asyn://user:password@host:port/path/to/db[?key=value&key=value...]
13
+
14
+ This dialect should normally be used only with the
15
+ :func:`_asyncio.create_async_engine` engine creation function::
16
+
17
+ from sqlalchemy.ext.asyncio import create_async_engine
18
+
19
+ engine = create_async_engine(
20
+ "firebirdsql+asyn://user:password@host:port/path/to/db[?key=value&key=value...]
21
+ )
22
+
23
+ """ # noqa
24
+ from collections import deque
25
+
26
+ from .base import FBDialect
27
+ from sqlalchemy import pool
28
+ from sqlalchemy import util
29
+ from sqlalchemy.engine import AdaptedConnection
30
+ from sqlalchemy.util.concurrency import asyncio
31
+ from sqlalchemy.util.concurrency import await_fallback
32
+ from sqlalchemy.util.concurrency import await_only
33
+
34
+ import firebirdsql
35
+
36
+
37
+ class AsyncAdapt_firebirdsql_cursor:
38
+ # TODO: base on connectors/asyncio.py
39
+ # see #10415
40
+ server_side = False
41
+ __slots__ = (
42
+ "_adapt_connection",
43
+ "_connection",
44
+ "await_",
45
+ "_cursor",
46
+ "_rows",
47
+ )
48
+
49
+ def __init__(self, adapt_connection):
50
+ self._adapt_connection = adapt_connection
51
+ self._connection = adapt_connection._connection
52
+ self.await_ = adapt_connection.await_
53
+
54
+ cursor = self._connection.cursor(adapt_connection.dbapi.Cursor)
55
+
56
+ self._cursor = self.await_(cursor.__aenter__())
57
+ self._rows = deque()
58
+
59
+ @property
60
+ def description(self):
61
+ return self._cursor.description
62
+
63
+ @property
64
+ def rowcount(self):
65
+ return self._cursor.rowcount
66
+
67
+ @property
68
+ def arraysize(self):
69
+ return self._cursor.arraysize
70
+
71
+ @arraysize.setter
72
+ def arraysize(self, value):
73
+ self._cursor.arraysize = value
74
+
75
+ @property
76
+ def lastrowid(self):
77
+ return self._cursor.lastrowid
78
+
79
+ def close(self):
80
+ # note we aren't actually closing the cursor here,
81
+ # we are just letting GC do it. to allow this to be async
82
+ # we would need the Result to change how it does "Safe close cursor".
83
+ # Firebird "cursors" don't actually have state to be "closed" besides
84
+ # exhausting rows, which we already have done for sync cursor.
85
+ self._rows.clear()
86
+
87
+ def execute(self, operation, parameters=None):
88
+ return self.await_(self._execute_async(operation, parameters))
89
+
90
+ def executemany(self, operation, seq_of_parameters):
91
+ return self.await_(
92
+ self._executemany_async(operation, seq_of_parameters)
93
+ )
94
+
95
+ async def _execute_async(self, operation, parameters):
96
+ async with self._adapt_connection._execute_mutex:
97
+ result = await self._cursor.execute(operation, parameters)
98
+
99
+ if not self.server_side:
100
+ # firebirdsql.aio has a "fake" async result, so we have to pull it out
101
+ # of that here since our default result is not async.
102
+ # we could just as easily grab "_rows" here and be done with it
103
+ # but this is safer.
104
+ self._rows = deque(await self._cursor.fetchall())
105
+ return result
106
+
107
+ async def _executemany_async(self, operation, seq_of_parameters):
108
+ async with self._adapt_connection._execute_mutex:
109
+ return await self._cursor.executemany(operation, seq_of_parameters)
110
+
111
+ def setinputsizes(self, *inputsizes):
112
+ pass
113
+
114
+ def __iter__(self):
115
+ while self._rows:
116
+ yield self._rows.popleft()
117
+
118
+ def fetchone(self):
119
+ if self._rows:
120
+ return self._rows.popleft()
121
+ else:
122
+ return None
123
+
124
+ def fetchmany(self, size=None):
125
+ if size is None:
126
+ size = self.arraysize
127
+
128
+ rr = self._rows
129
+ return [rr.popleft() for _ in range(min(size, len(rr)))]
130
+
131
+ def fetchall(self):
132
+ retval = list(self._rows)
133
+ self._rows.clear()
134
+ return retval
135
+
136
+
137
+ class AsyncAdapt_firebirdsql_connection(AdaptedConnection):
138
+ # TODO: base on connectors/asyncio.py
139
+ # see #10415
140
+ await_ = staticmethod(await_only)
141
+ __slots__ = ("dbapi", "_execute_mutex")
142
+
143
+ def __init__(self, dbapi, connection):
144
+ self.dbapi = dbapi
145
+ self._connection = connection
146
+ self._execute_mutex = asyncio.Lock()
147
+
148
+ def ping(self, reconnect):
149
+ return self.await_(self._connection.ping(reconnect))
150
+
151
+ def character_set_name(self):
152
+ return self._connection.character_set_name()
153
+
154
+ def autocommit(self, value):
155
+ self.await_(self._connection.autocommit(value))
156
+
157
+ def cursor(self):
158
+ return AsyncAdapt_firebirdsql_cursor(self)
159
+
160
+ def rollback(self):
161
+ self.await_(self._connection.rollback())
162
+
163
+ def commit(self):
164
+ self.await_(self._connection.commit())
165
+
166
+ def terminate(self):
167
+ # it's not awaitable.
168
+ self._connection.close()
169
+
170
+ def close(self) -> None:
171
+ self.await_(self._connection.ensure_closed())
172
+
173
+
174
+ class AsyncAdaptFallback_firebirdsql_connection(AsyncAdapt_firebirdsql_connection):
175
+ # TODO: base on connectors/asyncio.py
176
+ # see #10415
177
+ __slots__ = ()
178
+
179
+ await_ = staticmethod(await_fallback)
180
+
181
+
182
+ class AsyncAdapt_firebirdsql_dbapi:
183
+ def __init__(self, asyn, syn):
184
+ self.asyn = asyn
185
+ self.syn = syn
186
+ self.paramstyle = "qmark"
187
+ self._init_dbapi_attributes()
188
+ self.Cursor = self.asyn.AsyncCursor
189
+
190
+ def _init_dbapi_attributes(self):
191
+ for name in (
192
+ "Warning",
193
+ "Error",
194
+ "InterfaceError",
195
+ "DataError",
196
+ "DatabaseError",
197
+ "OperationalError",
198
+ "InterfaceError",
199
+ "IntegrityError",
200
+ "ProgrammingError",
201
+ "InternalError",
202
+ "NotSupportedError",
203
+ ):
204
+ setattr(self, name, getattr(firebirdsql, name))
205
+
206
+ for name in (
207
+ "NUMBER",
208
+ "STRING",
209
+ "DATETIME",
210
+ "BINARY",
211
+ "TIMESTAMP",
212
+ "Binary",
213
+ ):
214
+ setattr(self, name, getattr(firebirdsql, name))
215
+
216
+ def connect(self, *arg, **kw):
217
+ async_fallback = kw.pop("async_fallback", False)
218
+ creator_fn = kw.pop("async_creator_fn", self.asyn.connect)
219
+
220
+ if util.asbool(async_fallback):
221
+ return AsyncAdaptFallback_firebirdsql_connection(
222
+ self,
223
+ await_fallback(creator_fn(*arg, **kw)),
224
+ )
225
+ else:
226
+ return AsyncAdapt_firebirdsql_connection(
227
+ self,
228
+ await_only(creator_fn(*arg, **kw)),
229
+ )
230
+
231
+
232
+ class FBDialect_asyn(FBDialect):
233
+ driver = "async"
234
+ supports_statement_cache = True
235
+
236
+ is_async = True
237
+ has_terminate = True
238
+
239
+ @classmethod
240
+ def import_dbapi(cls):
241
+ return AsyncAdapt_firebirdsql_dbapi(
242
+ firebirdsql.aio, firebirdsql
243
+ )
244
+
245
+ @classmethod
246
+ def get_pool_class(cls, url):
247
+ async_fallback = url.query.get("async_fallback", False)
248
+
249
+ if util.asbool(async_fallback):
250
+ return pool.FallbackAsyncAdaptedQueuePool
251
+ else:
252
+ return pool.AsyncAdaptedQueuePool
253
+
254
+ def do_terminate(self, dbapi_connection) -> None:
255
+ dbapi_connection.terminate()
256
+
257
+ def create_connect_args(self, url):
258
+ opts = url.translate_connect_args(username="user")
259
+ qry = url.query
260
+
261
+ opts.update(qry)
262
+ return ([], opts)
263
+
264
+ def is_disconnect(self, e, connection, cursor):
265
+ if super().is_disconnect(e, connection, cursor):
266
+ return True
267
+ else:
268
+ str_e = str(e).lower()
269
+ return "not connected" in str_e
270
+
271
+ def get_driver_connection(self, connection):
272
+ return connection._connection
273
+
274
+
275
+ dialect = FBDialect_asyn