Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprectaion warnings for trubodbc and pyodbc #441

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Unreleased

🔧 Changed
-----------
- Added deprecation warnings for pyodbc and trubodbc dialects
- Made websockets the default way to use sqlalchemy with exasol
- Made pydobc an optional dependency

Expand Down
7 changes: 7 additions & 0 deletions sqlalchemy_exasol/pyodbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import logging
import re
import sys
from warnings import warn

from packaging import version
from sqlalchemy import sql
Expand All @@ -20,6 +21,7 @@
EXADialect,
EXAExecutionContext,
)
from sqlalchemy_exasol.warnings import SqlaExasolDeprecationWarning

logger = logging.getLogger("sqlalchemy_exasol")

Expand All @@ -30,6 +32,11 @@ class EXADialect_pyodbc(EXADialect, PyODBCConnector):
driver_version = None

def __init__(self, **kw):
message = (
"'pyodbc' support in 'sqlalchemy_exasol' is deprecated and will be removed. "
"Please switch to the websocket driver. See documentation for details."
)
warn(message, SqlaExasolDeprecationWarning)
super().__init__(**kw)

def get_driver_version(self, connection):
Expand Down
10 changes: 10 additions & 0 deletions sqlalchemy_exasol/turbodbc.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import decimal
from warnings import warn

from sqlalchemy import types as sqltypes
from sqlalchemy import util

from sqlalchemy_exasol.base import EXADialect
from sqlalchemy_exasol.warnings import SqlaExasolDeprecationWarning

DEFAULT_CONNECTION_PARAMS = {
# always enable efficient conversion to Python types:
Expand Down Expand Up @@ -72,6 +74,14 @@ class EXADialect_turbodbc(EXADialect):

colspecs = {sqltypes.Numeric: _ExaDecimal, sqltypes.Integer: _ExaInteger}

def __init__(self, **kw):
message = (
"'turbodbc' support in 'sqlalchemy_exasol' is deprecated and will be removed. "
"Please switch to the websocket driver. See documentation for details."
)
warn(message, SqlaExasolDeprecationWarning)
super().__init__(**kw)

@classmethod
def dbapi(cls):
return __import__("turbodbc")
Expand Down
6 changes: 6 additions & 0 deletions sqlalchemy_exasol/warnings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class SqlaExasolWarning(UserWarning):
"""Base class for all warnings emited by sqlalchemy_exasol."""


class SqlaExasolDeprecationWarning(SqlaExasolWarning, DeprecationWarning):
"""Warning class for features that will be removed in future versions."""
12 changes: 12 additions & 0 deletions test/unit/exasol/test_deprectation_warnings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pytest

from sqlalchemy_exasol.pyodbc import EXADialect_pyodbc
from sqlalchemy_exasol.turbodbc import EXADialect_turbodbc


@pytest.mark.parametrize(
"klass,kwargs", [(EXADialect_pyodbc, {}), (EXADialect_turbodbc, {})]
)
def test_deprectation_warnings(klass, kwargs):
with pytest.deprecated_call():
_ = EXADialect_pyodbc(**kwargs)
Loading