diff --git a/pyexasol/db2/__init__.py b/pyexasol/db2/__init__.py index 07718fc..307e17f 100644 --- a/pyexasol/db2/__init__.py +++ b/pyexasol/db2/__init__.py @@ -8,16 +8,29 @@ There is no "paramstyle" and no proper error handling """ +from warnings import warn +from inspect import cleandoc from ..connection import ExaConnection - -apilevel = '2.0' +from ..warnings import PyexasolDeprecationWarning + +warn( + cleandoc( + """ + This module is deprecated and will be removed in the future. + If you require a dbapi2 compliant driver, please use the dbapi2 compliant driver facade available in the `exasol.driver.websocket` package. + """ + ), + PyexasolDeprecationWarning, +) + +apilevel = "2.0" threadsafety = 1 paramstyle = None def connect(**kwargs): - if 'autocommit' not in kwargs: - kwargs['autocommit'] = False + if "autocommit" not in kwargs: + kwargs["autocommit"] = False return DB2Connection(**kwargs) @@ -66,15 +79,17 @@ def description(self): cols = [] for k, v in self.stmt.columns().items(): - cols.append(( - k, - v.get('type', None), - v.get('size', None), - v.get('size', None), - v.get('precision', None), - v.get('scale', None), - True - )) + cols.append( + ( + k, + v.get("type", None), + v.get("size", None), + v.get("size", None), + v.get("precision", None), + v.get("scale", None), + True, + ) + ) return cols diff --git a/pyexasol/warnings.py b/pyexasol/warnings.py new file mode 100644 index 0000000..194e63f --- /dev/null +++ b/pyexasol/warnings.py @@ -0,0 +1,6 @@ +class PyexasolWarning(UserWarning): + """Base class for all warnings emited by pyexasol.""" + + +class PyexasolDeprecationWarning(PyexasolWarning, DeprecationWarning): + """Warning class for features that will be removed in future versions.""" diff --git a/test/unit/deprectation_warning_test.py b/test/unit/deprectation_warning_test.py new file mode 100644 index 0000000..0e06099 --- /dev/null +++ b/test/unit/deprectation_warning_test.py @@ -0,0 +1,7 @@ +import pytest +from pyexasol.warnings import PyexasolDeprecationWarning + + +def test_import_db2_module_emits_deprecation_warning(): + with pytest.warns(PyexasolDeprecationWarning): + from pyexasol import db2