forked from pandas-dev/pandas-stubs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsql.pyi
202 lines (195 loc) · 5.71 KB
/
sql.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
from collections.abc import (
Callable,
Generator,
Iterable,
Mapping,
)
import sqlite3
from typing import (
Any,
Literal,
overload,
)
from pandas.core.frame import DataFrame
import sqlalchemy.engine
from sqlalchemy.orm import FromStatement
import sqlalchemy.sql.expression
from sqlalchemy.sql.expression import UpdateBase
from typing_extensions import TypeAlias
from pandas._libs.lib import NoDefault
from pandas._typing import (
DtypeArg,
DtypeBackend,
Scalar,
npt,
)
_SQLConnection: TypeAlias = str | sqlalchemy.engine.Connectable | sqlite3.Connection
_SQLStatement: TypeAlias = (
str
| sqlalchemy.sql.expression.Selectable
| sqlalchemy.sql.expression.TextClause
| sqlalchemy.sql.Select
| FromStatement
| UpdateBase
)
@overload
def read_sql_table(
table_name: str,
con: _SQLConnection,
schema: str | None = ...,
index_col: str | list[str] | None = ...,
coerce_float: bool = ...,
parse_dates: list[str] | dict[str, str] | dict[str, dict[str, Any]] | None = ...,
columns: list[str] | None = ...,
*,
chunksize: int,
dtype_backend: DtypeBackend | NoDefault = ...,
) -> Generator[DataFrame, None, None]: ...
@overload
def read_sql_table(
table_name: str,
con: _SQLConnection,
schema: str | None = ...,
index_col: str | list[str] | None = ...,
coerce_float: bool = ...,
parse_dates: list[str] | dict[str, str] | dict[str, dict[str, Any]] | None = ...,
columns: list[str] | None = ...,
chunksize: None = ...,
dtype_backend: DtypeBackend | NoDefault = ...,
) -> DataFrame: ...
@overload
def read_sql_query(
sql: _SQLStatement,
con: _SQLConnection,
index_col: str | list[str] | None = ...,
coerce_float: bool = ...,
params: (
list[Scalar]
| tuple[Scalar, ...]
| tuple[tuple[Scalar, ...], ...]
| Mapping[str, Scalar]
| Mapping[str, tuple[Scalar, ...]]
| None
) = ...,
parse_dates: list[str] | dict[str, str] | dict[str, dict[str, Any]] | None = ...,
*,
chunksize: int,
dtype: DtypeArg | None = ...,
dtype_backend: DtypeBackend | NoDefault = ...,
) -> Generator[DataFrame, None, None]: ...
@overload
def read_sql_query(
sql: _SQLStatement,
con: _SQLConnection,
index_col: str | list[str] | None = ...,
coerce_float: bool = ...,
params: (
list[Scalar]
| tuple[Scalar, ...]
| tuple[tuple[Scalar, ...], ...]
| Mapping[str, Scalar]
| Mapping[str, tuple[Scalar, ...]]
| None
) = ...,
parse_dates: list[str] | dict[str, str] | dict[str, dict[str, Any]] | None = ...,
chunksize: None = ...,
dtype: DtypeArg | None = ...,
dtype_backend: DtypeBackend | NoDefault = ...,
) -> DataFrame: ...
@overload
def read_sql(
sql: _SQLStatement,
con: _SQLConnection,
index_col: str | list[str] | None = ...,
coerce_float: bool = ...,
params: (
list[Scalar]
| tuple[Scalar, ...]
| tuple[tuple[Scalar, ...], ...]
| Mapping[str, Scalar]
| Mapping[str, tuple[Scalar, ...]]
| None
) = ...,
parse_dates: list[str] | dict[str, str] | dict[str, dict[str, Any]] | None = ...,
columns: list[str] = ...,
*,
chunksize: int,
dtype: DtypeArg | None = ...,
dtype_backend: DtypeBackend | NoDefault = ...,
) -> Generator[DataFrame, None, None]: ...
@overload
def read_sql(
sql: _SQLStatement,
con: _SQLConnection,
index_col: str | list[str] | None = ...,
coerce_float: bool = ...,
params: (
list[Scalar]
| tuple[Scalar, ...]
| tuple[tuple[Scalar, ...], ...]
| Mapping[str, Scalar]
| Mapping[str, tuple[Scalar, ...]]
| None
) = ...,
parse_dates: list[str] | dict[str, str] | dict[str, dict[str, Any]] | None = ...,
columns: list[str] = ...,
chunksize: None = ...,
dtype: DtypeArg | None = ...,
dtype_backend: DtypeBackend | NoDefault = ...,
) -> DataFrame: ...
class PandasSQL:
def read_sql(self, *args, **kwargs): ...
def to_sql(
self,
frame: DataFrame,
name: str,
if_exists: Literal["fail", "replace", "append"] = ...,
index: bool = ...,
index_label=...,
schema: str | None = ...,
chunksize=...,
dtype: DtypeArg | None = ...,
method: (
Literal["multi"]
| Callable[[SQLTable, Any, list[str], Iterable], int | None]
| None
) = ...,
) -> int | None: ...
class SQLTable:
name: str
pd_sql: PandasSQL # pandas SQL interface
prefix: str
frame: DataFrame | None
index: list[str]
schema: str
if_exists: Literal["fail", "replace", "append"]
keys: list[str]
dtype: DtypeArg | None
table: Any # sqlalchemy.Table
def __init__(
self,
name: str,
pandas_sql_engine: PandasSQL,
frame: DataFrame | None = ...,
index: bool | str | list[str] | None = ...,
if_exists: Literal["fail", "replace", "append"] = ...,
prefix: str = ...,
index_label: str | list[str] | None = ...,
schema: str | None = ...,
keys: str | list[str] | None = ...,
dtype: DtypeArg | None = ...,
) -> None: ...
def exists(self) -> bool: ...
def sql_schema(self) -> str: ...
def create(self) -> None: ...
def insert_data(self) -> tuple[list[str], list[npt.NDArray]]: ...
def insert(
self, chunksize: int | None = ..., method: str | None = ...
) -> int | None: ...
def read(
self,
coerce_float: bool = ...,
parse_dates: bool | list[str] | None = ...,
columns: list[str] | None = ...,
chunksize: int | None = ...,
) -> DataFrame | Generator[DataFrame, None, None]: ...