- 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
--- /dev/null
+.. 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
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
+---------------------------------------+-----------------------+
| Elasticsearch (readonly) | elasticsearch-dbapi_ |
+---------------------------------------+-----------------------+
+| Firebird | sqlalchemy-firebird_ |
++---------------------------------------+-----------------------+
| Google BigQuery | pybigquery_ |
+---------------------------------------+-----------------------+
| Google Sheets | gsheets_ |
.. _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
-------
.. automodule:: sqlalchemy.dialects.mssql.pymssql
-
-AdoDBAPI
---------
-.. automodule:: sqlalchemy.dialects.mssql.adodbapi
-
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
import warnings
from . import Connector
+from ..util import warn_deprecated
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
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
-----------------
.. _dialects: http://mc-computing.com/Databases/Firebird/SQL_Dialect.html
-
+.. _external-dialect: https://github.com/pauldex/sqlalchemy-firebird
"""
import datetime
# 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 = (
# 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
+++ /dev/null
-# 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
: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
---------------
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
-------
@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):
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
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(
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
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 = [
from pysqlcipher3 import dbapi2 as sqlcipher
except ImportError:
raise e
+
return sqlcipher
@classmethod
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
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)
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
:connectstring: sybase+pyodbc://<username>:<password>@<dsnname>[/<database>]
:url: http://pypi.python.org/pypi/pyodbc/
-
Unicode Support
---------------
colspecs = {sqltypes.Numeric: _SybNumeric_pyodbc}
+ @classmethod
+ def dbapi(cls):
+ return PyODBCConnector.dbapi()
+
dialect = SybaseDialect_pyodbc
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
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
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()