@@ -5,12 +5,14 @@ from typing import (
55 Generator ,
66 Iterable ,
77 Literal ,
8+ Union ,
89 overload ,
910)
1011
1112from pandas .core .base import PandasObject
1213from pandas .core .frame import DataFrame
1314import sqlalchemy .engine
15+ import sqlalchemy .sql .expression
1416
1517from pandas ._typing import (
1618 DtypeArg ,
@@ -20,10 +22,16 @@ from pandas._typing import (
2022# TODO: Remove after switch to 1.5.x, moved to pandas.errors
2123class DatabaseError (IOError ): ...
2224
25+ _SQLConnection = Union [
26+ str ,
27+ sqlalchemy .engine .Connectable ,
28+ sqlite3 .Connection ,
29+ ]
30+
2331@overload
2432def read_sql_table (
2533 table_name : str ,
26- con : str | sqlalchemy . engine . Connectable | sqlite3 . Connection ,
34+ con : _SQLConnection ,
2735 schema : str | None = ...,
2836 index_col : str | list [str ] | None = ...,
2937 coerce_float : bool = ...,
@@ -35,7 +43,7 @@ def read_sql_table(
3543@overload
3644def read_sql_table (
3745 table_name : str ,
38- con : str | sqlalchemy . engine . Connectable | sqlite3 . Connection ,
46+ con : _SQLConnection ,
3947 schema : str | None = ...,
4048 index_col : str | list [str ] | None = ...,
4149 coerce_float : bool = ...,
@@ -45,8 +53,8 @@ def read_sql_table(
4553) -> DataFrame : ...
4654@overload
4755def read_sql_query (
48- sql : str ,
49- con : str | sqlalchemy . engine . Connectable | sqlite3 . Connection ,
56+ sql : str | sqlalchemy . sql . expression . Selectable ,
57+ con : _SQLConnection ,
5058 index_col : str | list [str ] | None = ...,
5159 coerce_float : bool = ...,
5260 params : list [str ] | tuple [str , ...] | dict [str , str ] | None = ...,
@@ -57,8 +65,8 @@ def read_sql_query(
5765) -> Generator [DataFrame , None , None ]: ...
5866@overload
5967def read_sql_query (
60- sql : str ,
61- con : str | sqlalchemy . engine . Connectable | sqlite3 . Connection ,
68+ sql : str | sqlalchemy . sql . expression . Selectable ,
69+ con : _SQLConnection ,
6270 index_col : str | list [str ] | None = ...,
6371 coerce_float : bool = ...,
6472 params : list [str ] | tuple [str , ...] | dict [str , str ] | None = ...,
@@ -68,8 +76,8 @@ def read_sql_query(
6876) -> DataFrame : ...
6977@overload
7078def read_sql (
71- sql : str ,
72- con : str | sqlalchemy . engine . Connectable | sqlite3 . Connection ,
79+ sql : str | sqlalchemy . sql . expression . Selectable ,
80+ con : _SQLConnection ,
7381 index_col : str | list [str ] | None = ...,
7482 coerce_float : bool = ...,
7583 params : list [str ] | tuple [str , ...] | dict [str , str ] | None = ...,
@@ -80,8 +88,8 @@ def read_sql(
8088) -> Generator [DataFrame , None , None ]: ...
8189@overload
8290def read_sql (
83- sql : str ,
84- con : str | sqlalchemy . engine . Connectable | sqlite3 . Connection ,
91+ sql : str | sqlalchemy . sql . expression . Selectable ,
92+ con : _SQLConnection ,
8593 index_col : str | list [str ] | None = ...,
8694 coerce_float : bool = ...,
8795 params : list [str ] | tuple [str , ...] | dict [str , str ] | None = ...,
0 commit comments