Skip to content

Commit a259ab4

Browse files
Add the import_dbapi method to the inherited class to suppress SQLAlchemy WARNING messages. (fix #582)
1 parent d2806e4 commit a259ab4

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

pyathena/sqlalchemy/arrow.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# -*- coding: utf-8 -*-
2+
from typing import TYPE_CHECKING
3+
24
from pyathena.sqlalchemy.base import AthenaDialect
35
from pyathena.util import strtobool
46

7+
if TYPE_CHECKING:
8+
from types import ModuleType
9+
510

611
class AthenaArrowDialect(AthenaDialect):
712
driver = "arrow"
@@ -18,3 +23,7 @@ def create_connect_args(self, url):
1823
if cursor_kwargs:
1924
opts.update({"cursor_kwargs": cursor_kwargs})
2025
return [[], opts]
26+
27+
@classmethod
28+
def import_dbapi(cls) -> "ModuleType":
29+
return super().import_dbapi()

pyathena/sqlalchemy/pandas.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# -*- coding: utf-8 -*-
2+
from typing import TYPE_CHECKING
3+
24
from pyathena.sqlalchemy.base import AthenaDialect
35
from pyathena.util import strtobool
46

7+
if TYPE_CHECKING:
8+
from types import ModuleType
9+
510

611
class AthenaPandasDialect(AthenaDialect):
712
driver = "pandas"
@@ -22,3 +27,7 @@ def create_connect_args(self, url):
2227
if cursor_kwargs:
2328
opts.update({"cursor_kwargs": cursor_kwargs})
2429
return [[], opts]
30+
31+
@classmethod
32+
def import_dbapi(cls) -> "ModuleType":
33+
return super().import_dbapi()

pyathena/sqlalchemy/rest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
# -*- coding: utf-8 -*-
2+
from typing import TYPE_CHECKING
3+
24
from pyathena.sqlalchemy.base import AthenaDialect
35

6+
if TYPE_CHECKING:
7+
from types import ModuleType
8+
49

510
class AthenaRestDialect(AthenaDialect):
611
driver = "rest"
712
supports_statement_cache = True
13+
14+
@classmethod
15+
def import_dbapi(cls) -> "ModuleType":
16+
return super().import_dbapi()

0 commit comments

Comments
 (0)