]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Deprecate unsupported dialects and dbapi
authorFederico Caselli <cfederico87@gmail.com>
Sat, 18 Apr 2020 18:58:41 +0000 (20:58 +0200)
committerFederico Caselli <cfederico87@gmail.com>
Wed, 29 Apr 2020 17:50:44 +0000 (17:50 +0000)
- Deprecate dialects firebird and sybase.

- Deprecate DBAPI

  - mxODBC for mssql

  - oursql for mysql

  - pygresql and py-postgresql for postgresql

- Removed adodbapi DBAPI for mssql

Fixes: #5189
Change-Id: Id9025f4f4de7e97d65aacd0eb4b0c21beb9a67b5

17 files changed:
doc/build/changelog/unreleased_14/5189.rst [new file with mode: 0644]
doc/build/dialects/index.rst
doc/build/dialects/mssql.rst
lib/sqlalchemy/connectors/mxodbc.py
lib/sqlalchemy/dialects/firebird/base.py
lib/sqlalchemy/dialects/mssql/__init__.py
lib/sqlalchemy/dialects/mssql/adodbapi.py [deleted file]
lib/sqlalchemy/dialects/mssql/mxodbc.py
lib/sqlalchemy/dialects/mysql/oursql.py
lib/sqlalchemy/dialects/postgresql/pygresql.py
lib/sqlalchemy/dialects/postgresql/pypostgresql.py
lib/sqlalchemy/dialects/sqlite/pysqlcipher.py
lib/sqlalchemy/dialects/sybase/base.py
lib/sqlalchemy/dialects/sybase/mxodbc.py
lib/sqlalchemy/dialects/sybase/pyodbc.py
lib/sqlalchemy/testing/warnings.py
test/dialect/mssql/test_engine.py

diff --git a/doc/build/changelog/unreleased_14/5189.rst b/doc/build/changelog/unreleased_14/5189.rst
new file mode 100644 (file)
index 0000000..3a2c4bf
--- /dev/null
@@ -0,0 +1,10 @@
+.. change::
+    :tags: dialects, deprecations
+    :tickets: 5189
+
+    Deprecate unsupported dialects and dbapi
+    - Deprecate dialects firefis and sybase.
+    - Deprecate DBAPI
+      - adodbapi and mxODBC for mssql
+      - oursql for mysql
+      - pygresql and py-postgresql for postgresql
index 2d0755d28d6f80c5329ff81838224a30392052d5..869c6a39cbeb90cfa555ebf1de190daff9c668cd 100644 (file)
@@ -22,12 +22,12 @@ Included Dialects
     oracle
     mssql
 
-Included, but not currently supported dialects
-----------------------------------------------
+Deprecated, no longer supported dialects
+----------------------------------------
 
 The following dialects have implementations within SQLAlchemy, but they are not
 part of continuous integration testing nor are they actively developed.
-These dialects may be removed in future major releases.
+These dialects are deprecated and will be removed in future major releases.
 
 .. toctree::
     :maxdepth: 1
@@ -62,6 +62,8 @@ Currently maintained external dialect projects for SQLAlchemy include:
 +---------------------------------------+-----------------------+
 | Elasticsearch (readonly)              | elasticsearch-dbapi_  |
 +---------------------------------------+-----------------------+
+| Firebird                              | sqlalchemy-firebird_  |
++---------------------------------------+-----------------------+
 | Google BigQuery                       | pybigquery_           |
 +---------------------------------------+-----------------------+
 | Google Sheets                         | gsheets_              |
@@ -101,3 +103,4 @@ Currently maintained external dialect projects for SQLAlchemy include:
 .. _elasticsearch-dbapi: https://github.com/preset-io/elasticsearch-dbapi/
 .. _pydruid: https://github.com/druid-io/pydruid
 .. _gsheets: https://github.com/betodealmeida/gsheets-db-api
+.. _sqlalchemy-firebird: https://github.com/pauldex/sqlalchemy-firebird
index 0ba4763b42b4dd0694919a5711aa3bf7f34c8b1f..47bfdc52f4dad26d932b9ac354f7d350d3a6e1b6 100644 (file)
@@ -124,8 +124,3 @@ pymssql
 -------
 .. automodule:: sqlalchemy.dialects.mssql.pymssql
 
-
-AdoDBAPI
---------
-.. automodule:: sqlalchemy.dialects.mssql.adodbapi
-
index 0a34cfe003964876f53cbf07f9a5dcbb2765c1aa..e243aba80f68bd372b361d7a87a7035b61f10c3c 100644 (file)
@@ -17,6 +17,10 @@ possible for this to be used on other database platforms.
 
 For more info on mxODBC, see http://www.egenix.com/
 
+.. deprecated:: 1.4 The mxODBC DBAPI is deprecated and will be removed
+   in a future version. Please use one of the supported DBAPIs to
+   connect to mssql.
+
 """
 
 import re
@@ -24,6 +28,7 @@ import sys
 import warnings
 
 from . import Connector
+from ..util import warn_deprecated
 
 
 class MxODBCConnector(Connector):
@@ -50,6 +55,13 @@ class MxODBCConnector(Connector):
             from mx.ODBC import iODBC as Module
         else:
             raise ImportError("Unrecognized platform for mxODBC import")
+
+        warn_deprecated(
+            "The mxODBC DBAPI is deprecated and will be removed"
+            "in a future version. Please use one of the supported DBAPIs to"
+            "connect to mssql.",
+            version="1.4",
+        )
         return Module
 
     @classmethod
index 5779ac8858162b975d6eeaff08eeafe8d42f18f1..b7260403af45f1a5cae6d009a0f8349c7a5ac91a 100644 (file)
@@ -16,6 +16,10 @@ r"""
     dialect is not tested within continuous integration and is likely to have
     many issues and caveats not currently handled.
 
+.. deprecated:: 1.4 This dialect is deprecated and will be removed
+    in a future version. This dialect is superseded by the external
+    version available at external-dialect_.
+
 Firebird Dialects
 -----------------
 
@@ -73,7 +77,7 @@ the SQLAlchemy ``returning()`` method, such as::
 
 
 .. _dialects: http://mc-computing.com/Databases/Firebird/SQL_Dialect.html
-
+.. _external-dialect: https://github.com/pauldex/sqlalchemy-firebird
 """
 
 import datetime
@@ -648,6 +652,15 @@ class FBDialect(default.DefaultDialect):
     # first connect
     _version_two = True
 
+    def __init__(self, *args, **kwargs):
+        util.warn_deprecated(
+            "The firebird dialect is deprecated and will be removed "
+            "in a future version. This dialect is superseded by the external "
+            "dialect https://github.com/pauldex/sqlalchemy-firebird.",
+            version="1.4",
+        )
+        super(FBDialect, self).__init__(*args, **kwargs)
+
     def initialize(self, connection):
         super(FBDialect, self).initialize(connection)
         self._version_two = (
index 67830affe308035448b53e0fd44be7e166f4a9fb..283c92eca53b3aabba7403f0691fb6dcc690a8d2 100644 (file)
@@ -5,7 +5,6 @@
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
-from . import adodbapi  # noqa
 from . import base  # noqa
 from . import mxodbc  # noqa
 from . import pymssql  # noqa
diff --git a/lib/sqlalchemy/dialects/mssql/adodbapi.py b/lib/sqlalchemy/dialects/mssql/adodbapi.py
deleted file mode 100644 (file)
index 15f1b65..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-# mssql/adodbapi.py
-# Copyright (C) 2005-2020 the SQLAlchemy authors and contributors
-# <see AUTHORS file>
-#
-# This module is part of SQLAlchemy and is released under
-# the MIT License: http://www.opensource.org/licenses/mit-license.php
-
-"""
-.. dialect:: mssql+adodbapi
-    :name: adodbapi
-    :dbapi: adodbapi
-    :connectstring: mssql+adodbapi://<username>:<password>@<dsnname>
-    :url: http://adodbapi.sourceforge.net/
-
-.. note::
-
-    The adodbapi dialect is not implemented in SQLAlchemy versions 0.6 and
-    above at this time.
-
-"""
-import datetime
-import sys
-
-from sqlalchemy import types as sqltypes
-from sqlalchemy import util
-from sqlalchemy.dialects.mssql.base import MSDateTime
-from sqlalchemy.dialects.mssql.base import MSDialect
-
-
-class MSDateTime_adodbapi(MSDateTime):
-    def result_processor(self, dialect, coltype):
-        def process(value):
-            # adodbapi will return datetimes with empty time
-            # values as datetime.date() objects.
-            # Promote them back to full datetime.datetime()
-            if type(value) is datetime.date:
-                return datetime.datetime(value.year, value.month, value.day)
-            return value
-
-        return process
-
-
-class MSDialect_adodbapi(MSDialect):
-    supports_sane_rowcount = True
-    supports_sane_multi_rowcount = True
-    supports_unicode = sys.maxunicode == 65535
-    supports_unicode_statements = True
-    driver = "adodbapi"
-
-    @classmethod
-    def import_dbapi(cls):
-        import adodbapi as module
-
-        return module
-
-    colspecs = util.update_copy(
-        MSDialect.colspecs, {sqltypes.DateTime: MSDateTime_adodbapi}
-    )
-
-    def create_connect_args(self, url):
-        def check_quote(token):
-            if ";" in str(token):
-                token = "'%s'" % token
-            return token
-
-        keys = dict((k, check_quote(v)) for k, v in url.query.items())
-
-        connectors = ["Provider=SQLOLEDB"]
-        if "port" in keys:
-            connectors.append(
-                "Data Source=%s, %s" % (keys.get("host"), keys.get("port"))
-            )
-        else:
-            connectors.append("Data Source=%s" % keys.get("host"))
-        connectors.append("Initial Catalog=%s" % keys.get("database"))
-        user = keys.get("user")
-        if user:
-            connectors.append("User Id=%s" % user)
-            connectors.append("Password=%s" % keys.get("password", ""))
-        else:
-            connectors.append("Integrated Security=SSPI")
-        return [[";".join(connectors)], {}]
-
-    def is_disconnect(self, e, connection, cursor):
-        return isinstance(
-            e, self.dbapi.adodbapi.DatabaseError
-        ) and "'connection failure'" in str(e)
-
-
-dialect = MSDialect_adodbapi
index 5df1351d2bce20914b3739026e6a70f21bcc314c..998153d7a77b504804b6c78bfc17726fefe758a0 100644 (file)
     :connectstring: mssql+mxodbc://<username>:<password>@<dsnname>
     :url: http://www.egenix.com/
 
+.. deprecated:: 1.4 The mxODBC DBAPI is deprecated and will be removed
+   in a future version. Please use one of the supported DBAPIs to
+   connect to mssql.
+
 Execution Modes
 ---------------
 
index d7334711b7e81f5329751159455d9391ff62a2e2..7c2b220b42cbbe0f7290ac59295285ff573d3de3 100644 (file)
     and is **not tested as part of SQLAlchemy's continuous integration**.
     The recommended MySQL dialects are mysqlclient and PyMySQL.
 
+.. deprecated:: 1.4 The OurSQL DBAPI is deprecated and will be removed
+   in a future version. Please use one of the supported DBAPIs to
+   connect to mysql.
+
 Unicode
 -------
 
@@ -68,6 +72,12 @@ class MySQLDialect_oursql(MySQLDialect):
 
     @classmethod
     def dbapi(cls):
+        util.warn_deprecated(
+            "The OurSQL DBAPI is deprecated and will be removed "
+            "in a future version. Please use one of the supported DBAPIs to "
+            "connect to mysql.",
+            version="1.4",
+        )
         return __import__("oursql")
 
     def do_execute(self, cursor, statement, parameters, context=None):
index 8666f41725dcf892cf6801b179d42330efb0d24f..8dbd23fe943ddf01786670428ad2f08bb5e073f3 100644 (file)
     integration** and may have unresolved issues.  The recommended PostgreSQL
     dialect is psycopg2.
 
+.. deprecated:: 1.4 The pygresql DBAPI is deprecated and will be removed
+   in a future version. Please use one of the supported DBAPIs to
+   connect to PostgreSQL.
+
 """  # noqa
 
 import decimal
@@ -197,6 +201,13 @@ class PGDialect_pygresql(PGDialect):
     def dbapi(cls):
         import pgdb
 
+        util.warn_deprecated(
+            "The pygresql DBAPI is deprecated and will be removed "
+            "in a future version. Please use one of the supported DBAPIs to "
+            "connect to PostgreSQL.",
+            version="1.4",
+        )
+
         return pgdb
 
     colspecs = util.update_copy(
index 289a9a0971c19db3c3dcb4a05cc65a281577a43d..bd015a5b8a08d20bb2b24e81709579df7c52db7b 100644 (file)
     integration** and may have unresolved issues.  The recommended PostgreSQL
     driver is psycopg2.
 
+.. deprecated:: 1.4 The py-postgresql DBAPI is deprecated and will be removed
+   in a future version. This DBAPI is superseded by the external
+    version available at external-dialect_. Please use the external version or
+    one of the supported DBAPIs to connect to PostgreSQL.
+
+.. TODO update link
+.. _external-dialect: https://github.com/PyGreSQL
 
 """  # noqa
 
@@ -69,6 +76,15 @@ class PGDialect_pypostgresql(PGDialect):
     def dbapi(cls):
         from postgresql.driver import dbapi20
 
+        # TODO update link
+        util.warn_deprecated(
+            "The py-postgresql DBAPI is deprecated and will be removed "
+            "in a future version. This DBAPI is superseded by the external"
+            "version available at https://github.com/PyGreSQL. Please "
+            "use one of the supported DBAPIs to connect to PostgreSQL.",
+            version="1.4",
+        )
+
         return dbapi20
 
     _DBAPI_ERROR_NAMES = [
index 213cc55f2c30cb1524232e70c6bc882475fdb37d..8f72e12fa377a4fa71c4b3e81f3c5602168c6033 100644 (file)
@@ -99,6 +99,7 @@ class SQLiteDialect_pysqlcipher(SQLiteDialect_pysqlite):
                 from pysqlcipher3 import dbapi2 as sqlcipher
             except ImportError:
                 raise e
+
         return sqlcipher
 
     @classmethod
index 3920aff0552478a7ff079679336d490778d942a6..634cf0da4ecba1dc92b52a5eb5d4567ce1878b29 100644 (file)
@@ -20,6 +20,9 @@
     dialect is not tested within continuous integration and is likely to have
     many issues and caveats not currently handled.
 
+.. deprecated:: 1.4 The Sybase dialect is deprecated and will be removed
+   in a future version.
+
 """
 
 import re
@@ -648,6 +651,14 @@ class SybaseDialect(default.DefaultDialect):
 
     construct_arguments = []
 
+    def __init__(self, *args, **kwargs):
+        util.warn_deprecated(
+            "The Sybase dialect is deprecated and will be removed "
+            "in a future version.",
+            version="1.4",
+        )
+        super(SybaseDialect, self).__init__(*args, **kwargs)
+
     def _get_default_schema_name(self, connection):
         return connection.scalar(
             text("SELECT user_name() as user_name").columns(username=Unicode)
index 12dcc2cf7b9490609d65123e58e2e888232c540f..d2348235781732ecf55db339e7455fb95fd384aa 100644 (file)
@@ -16,7 +16,6 @@
 
     This dialect is a stub only and is likely non functional at this time.
 
-
 """
 from sqlalchemy.connectors.mxodbc import MxODBCConnector
 from sqlalchemy.dialects.sybase.base import SybaseDialect
index ff166feb107e56a519b3516fd497664113ad438e..d11aae1c5d3cc942c51fc71d61e8ee73aea28bcd 100644 (file)
@@ -12,7 +12,6 @@
     :connectstring: sybase+pyodbc://<username>:<password>@<dsnname>[/<database>]
     :url: http://pypi.python.org/pypi/pyodbc/
 
-
 Unicode Support
 ---------------
 
@@ -81,5 +80,9 @@ class SybaseDialect_pyodbc(PyODBCConnector, SybaseDialect):
 
     colspecs = {sqltypes.Numeric: _SybNumeric_pyodbc}
 
+    @classmethod
+    def dbapi(cls):
+        return PyODBCConnector.dbapi()
+
 
 dialect = SybaseDialect_pyodbc
index 39cffbf158159faab4e67c5ddcbe1ba23533b522..3850f65c8f1544be17a82e8b87d8d8590840d595 100644 (file)
@@ -40,6 +40,11 @@ def setup_filters():
         category=sa_exc.SADeprecationWarning,
         message=r".*\(deprecated since: 2.0\)$",
     )
+    warnings.filterwarnings(
+        "ignore",
+        category=sa_exc.SADeprecationWarning,
+        message=r"^The (Sybase|firebird) dialect is deprecated and will be",
+    )
 
     try:
         import pytest
index 97e924feda9aeabd86dff2de22a3eef5c8c36ea6..00babf8ce7ebec51a078511451d32a8f06eaf1ab 100644 (file)
@@ -7,7 +7,6 @@ from sqlalchemy import Integer
 from sqlalchemy import String
 from sqlalchemy import Table
 from sqlalchemy import testing
-from sqlalchemy.dialects.mssql import adodbapi
 from sqlalchemy.dialects.mssql import base
 from sqlalchemy.dialects.mssql import pymssql
 from sqlalchemy.dialects.mssql import pyodbc
@@ -223,32 +222,6 @@ class ParseConnectTest(fixtures.TestBase):
             connection,
         )
 
-    def test_adodbapi_token_injection(self):
-        token1 = "someuser%3BPORT%3D50001"
-        token2 = "somepw%3BPORT%3D50001"
-        token3 = "somehost%3BPORT%3D50001"
-        token4 = "someport%3BPORT%3D50001"
-
-        # this URL format is all wrong
-        u = url.make_url(
-            "mssql+adodbapi://@/?user=%s&password=%s&host=%s&port=%s"
-            % (token1, token2, token3, token4)
-        )
-        dialect = adodbapi.dialect()
-        connection = dialect.create_connect_args(u)
-        eq_(
-            [
-                [
-                    "Provider=SQLOLEDB;"
-                    "Data Source='somehost;PORT=50001', 'someport;PORT=50001';"
-                    "Initial Catalog=None;User Id='someuser;PORT=50001';"
-                    "Password='somepw;PORT=50001'"
-                ],
-                {},
-            ],
-            connection,
-        )
-
     def test_pymssql_port_setting(self):
         dialect = pymssql.dialect()