]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Standardize DBAPI version access across dialects main
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 6 Aug 2026 16:37:46 +0000 (12:37 -0400)
committerMichael Bayer <mike_mp@zzzcomputing.com>
Thu, 6 Aug 2026 19:23:09 +0000 (19:23 +0000)
commit9a4b82e798f9658e9edfac7f9fbd07e530b9993f
tree3924413241d71bed4b4de2fecd462fb293b8ddd9
parent3ea271cc9653ef9fe12d26f1911aa8d13386cbab
Standardize DBAPI version access across dialects

Added :attr:`.Dialect.dbapi_version`, a standardized accessor for the
version of the DBAPI module in use by a dialect, in contrast to
:attr:`.Dialect.server_version_info` which refers to the database server.
The implementation on :class:`.DefaultDialect` makes use of a new
per-dialect method :meth:`.Dialect.retrieve_dbapi_version` in order to
retrieve the version from the DBAPI module and return it as a
:class:`.VersionInfo` object, which is a tuple subclass with additional
properties; third-party dialects should also implement the
:meth:`.Dialect.retrieve_dbapi_version` method.

Fixed issue in the asyncpg dialect where the version of the ``asyncpg``
DBAPI would always be reported as ``(99, 99, 99)``, as the version was
looked up on the dialect's DBAPI wrapper module rather than on the
``asyncpg`` module itself.

Fixed issue where the version of the DBAPI reported by the mysqldb and
pymysql dialects was incorrect.  Current mysqlclient releases publish
``MySQLdb.version_info`` and no version string at all, so no version was
reported; pymysql publishes ``__version__`` and ``version_info`` as
mysqlclient compatibility values, so the version reported for pymysql
was that of the mysqlclient release it emulates, e.g. ``(2, 2, 8)``
rather than ``(1, 2, 0)``.

The version specifications used by testing exclusions such as
``testing.fails_if("+asyncmy<0.2.13")`` now support a driver name, in
which case the comparison is against the version of the DBAPI rather
than that of the database server.  Previously this form raised
``AssertionError: DBAPI version specs not supported yet``.

Change-Id: I09035a861adc6892f84a6c3a788e6b4657858820
34 files changed:
doc/build/changelog/unreleased_21/dbapi_version.rst [new file with mode: 0644]
lib/sqlalchemy/connectors/pyodbc.py
lib/sqlalchemy/dialects/mssql/mssqlpython.py
lib/sqlalchemy/dialects/mssql/pymssql.py
lib/sqlalchemy/dialects/mssql/pyodbc.py
lib/sqlalchemy/dialects/mysql/aiomysql.py
lib/sqlalchemy/dialects/mysql/asyncmy.py
lib/sqlalchemy/dialects/mysql/mariadbconnector.py
lib/sqlalchemy/dialects/mysql/mysqlconnector.py
lib/sqlalchemy/dialects/mysql/mysqldb.py
lib/sqlalchemy/dialects/mysql/pymysql.py
lib/sqlalchemy/dialects/oracle/cx_oracle.py
lib/sqlalchemy/dialects/oracle/oracledb.py
lib/sqlalchemy/dialects/postgresql/_psycopg_common.py
lib/sqlalchemy/dialects/postgresql/asyncpg.py
lib/sqlalchemy/dialects/postgresql/pg8000.py
lib/sqlalchemy/dialects/postgresql/psycopg.py
lib/sqlalchemy/dialects/postgresql/psycopg2.py
lib/sqlalchemy/dialects/sqlite/aiosqlite.py
lib/sqlalchemy/dialects/sqlite/pysqlcipher.py
lib/sqlalchemy/dialects/sqlite/pysqlite.py
lib/sqlalchemy/engine/default.py
lib/sqlalchemy/engine/interfaces.py
lib/sqlalchemy/exc.py
lib/sqlalchemy/testing/exclusions.py
lib/sqlalchemy/util/__init__.py
lib/sqlalchemy/util/langhelpers.py
test/base/test_except.py
test/base/test_utils.py
test/dialect/mysql/test_dialect.py
test/dialect/oracle/test_dialect.py
test/dialect/test_pyodbc.py [deleted file]
test/engine/test_parseconnect.py
test/requirements.py