-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathmssql_python.pyi
More file actions
355 lines (306 loc) · 10.5 KB
/
mssql_python.pyi
File metadata and controls
355 lines (306 loc) · 10.5 KB
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
"""
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
Type stubs for mssql_python package - based on actual public API
"""
from typing import Any, Dict, List, Optional, Union, Tuple, Sequence, Callable, Iterator
import datetime
import logging
# GLOBALS - DB-API 2.0 Required Module Globals
# https://www.python.org/dev/peps/pep-0249/#module-interface
apilevel: str # "2.0"
paramstyle: str # "qmark"
threadsafety: int # 1
# Module Settings - Properties that can be get/set at module level
lowercase: bool # Controls column name case behavior
native_uuid: bool # Controls UUID type handling
# Settings Class
class Settings:
lowercase: bool
decimal_separator: str
native_uuid: bool
def __init__(self) -> None: ...
# Module-level Configuration Functions
def get_settings() -> Settings: ...
def setDecimalSeparator(separator: str) -> None: ...
def getDecimalSeparator() -> str: ...
def pooling(max_size: int = 100, idle_timeout: int = 600, enabled: bool = True) -> None: ...
def get_info_constants() -> Dict[str, int]: ...
# Logging Functions
def setup_logging(mode: str = "file", log_level: int = logging.DEBUG) -> None: ...
def get_logger() -> Optional[logging.Logger]: ...
# DB-API 2.0 Type Objects
# https://www.python.org/dev/peps/pep-0249/#type-objects
class STRING:
"""Type object for string-based database columns (e.g. CHAR, VARCHAR)."""
...
class BINARY:
"""Type object for binary database columns (e.g. BINARY, VARBINARY)."""
...
class NUMBER:
"""Type object for numeric database columns (e.g. INT, DECIMAL)."""
...
class DATETIME:
"""Type object for date/time database columns (e.g. DATE, TIMESTAMP)."""
...
class ROWID:
"""Type object for row identifier columns."""
...
# DB-API 2.0 Type Constructors
# https://www.python.org/dev/peps/pep-0249/#type-constructors
def Date(year: int, month: int, day: int) -> datetime.date: ...
def Time(hour: int, minute: int, second: int) -> datetime.time: ...
def Timestamp(
year: int,
month: int,
day: int,
hour: int,
minute: int,
second: int,
microsecond: int,
) -> datetime.datetime: ...
def DateFromTicks(ticks: int) -> datetime.date: ...
def TimeFromTicks(ticks: int) -> datetime.time: ...
def TimestampFromTicks(ticks: int) -> datetime.datetime: ...
def Binary(value: Union[str, bytes, bytearray]) -> bytes: ...
# DB-API 2.0 Exception Hierarchy
# https://www.python.org/dev/peps/pep-0249/#exceptions
class Warning(Exception):
def __init__(self, driver_error: str, ddbc_error: str) -> None: ...
driver_error: str
ddbc_error: str
message: str
class Error(Exception):
def __init__(self, driver_error: str, ddbc_error: str) -> None: ...
driver_error: str
ddbc_error: str
message: str
class InterfaceError(Error):
def __init__(self, driver_error: str, ddbc_error: str) -> None: ...
class DatabaseError(Error):
def __init__(self, driver_error: str, ddbc_error: str) -> None: ...
class DataError(DatabaseError):
def __init__(self, driver_error: str, ddbc_error: str) -> None: ...
class OperationalError(DatabaseError):
def __init__(self, driver_error: str, ddbc_error: str) -> None: ...
class IntegrityError(DatabaseError):
def __init__(self, driver_error: str, ddbc_error: str) -> None: ...
class InternalError(DatabaseError):
def __init__(self, driver_error: str, ddbc_error: str) -> None: ...
class ProgrammingError(DatabaseError):
def __init__(self, driver_error: str, ddbc_error: str) -> None: ...
class NotSupportedError(DatabaseError):
def __init__(self, driver_error: str, ddbc_error: str) -> None: ...
# Row Object
class Row:
"""
Represents a database result row.
Supports both index-based and name-based column access.
"""
def __init__(
self,
values: List[Any],
column_map: Dict[str, int],
cursor: Optional["Cursor"] = None,
converter_map: Optional[List[Any]] = None,
uuid_str_indices: Optional[Tuple[int, ...]] = None,
) -> None: ...
def __getitem__(self, index: int) -> Any: ...
def __getattr__(self, name: str) -> Any: ...
def __eq__(self, other: Any) -> bool: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[Any]: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
# DB-API 2.0 Cursor Object
# https://www.python.org/dev/peps/pep-0249/#cursor-objects
class Cursor:
"""
Database cursor for executing SQL operations and fetching results.
This class should not be instantiated directly. Use Connection.cursor() instead.
"""
# DB-API 2.0 Required Attributes
description: Optional[
List[
Tuple[
str,
Any,
Optional[int],
Optional[int],
Optional[int],
Optional[int],
Optional[bool],
]
]
]
rowcount: int
arraysize: int
# Extension Attributes
closed: bool
messages: List[str]
@property
def rownumber(self) -> int: ...
@property
def connection(self) -> "Connection": ...
def __init__(self, connection: "Connection", timeout: int = 0) -> None: ...
# DB-API 2.0 Required Methods
def callproc(
self, procname: str, parameters: Optional[Sequence[Any]] = None
) -> Optional[Sequence[Any]]: ...
def close(self) -> None: ...
def execute(
self,
operation: str,
*parameters: Any,
use_prepare: bool = True,
reset_cursor: bool = True,
) -> "Cursor": ...
def executemany(self, operation: str, seq_of_parameters: List[Sequence[Any]]) -> None: ...
def fetchone(self) -> Optional[Row]: ...
def fetchmany(self, size: Optional[int] = None) -> List[Row]: ...
def fetchall(self) -> List[Row]: ...
def nextset(self) -> Optional[bool]: ...
def setinputsizes(self, sizes: List[Union[int, Tuple[Any, ...]]]) -> None: ...
def setoutputsize(self, size: int, column: Optional[int] = None) -> None: ...
# DB-API 2.0 Connection Object
# https://www.python.org/dev/peps/pep-0249/#connection-objects
class Connection:
"""
Database connection object.
This class should not be instantiated directly. Use the connect() function instead.
"""
# DB-API 2.0 Exception Attributes
Warning: type[Warning]
Error: type[Error]
InterfaceError: type[InterfaceError]
DatabaseError: type[DatabaseError]
DataError: type[DataError]
OperationalError: type[OperationalError]
IntegrityError: type[IntegrityError]
InternalError: type[InternalError]
ProgrammingError: type[ProgrammingError]
NotSupportedError: type[NotSupportedError]
# Connection Properties
@property
def timeout(self) -> int: ...
@timeout.setter
def timeout(self, value: int) -> None: ...
@property
def autocommit(self) -> bool: ...
@autocommit.setter
def autocommit(self, value: bool) -> None: ...
@property
def searchescape(self) -> str: ...
def __init__(
self,
connection_str: str = "",
autocommit: bool = False,
attrs_before: Optional[Dict[int, Union[int, str, bytes]]] = None,
timeout: int = 0,
native_uuid: Optional[bool] = None,
**kwargs: Any,
) -> None: ...
# DB-API 2.0 Required Methods
def cursor(self) -> Cursor: ...
def commit(self) -> None: ...
def rollback(self) -> None: ...
def close(self) -> None: ...
# Extension Methods
def setautocommit(self, value: bool = False) -> None: ...
def setencoding(self, encoding: Optional[str] = None, ctype: Optional[int] = None) -> None: ...
def getencoding(self) -> Dict[str, Union[str, int]]: ...
def setdecoding(
self, sqltype: int, encoding: Optional[str] = None, ctype: Optional[int] = None
) -> None: ...
def getdecoding(self, sqltype: int) -> Dict[str, Union[str, int]]: ...
def set_attr(self, attribute: int, value: Union[int, str, bytes, bytearray]) -> None: ...
def add_output_converter(self, sqltype: int, func: Callable[[Any], Any]) -> None: ...
def get_output_converter(self, sqltype: Union[int, type]) -> Optional[Callable[[Any], Any]]: ...
def remove_output_converter(self, sqltype: Union[int, type]) -> None: ...
def clear_output_converters(self) -> None: ...
def execute(self, sql: str, *args: Any) -> Cursor: ...
def batch_execute(
self,
statements: List[str],
params: Optional[List[Union[None, Any, Tuple[Any, ...], List[Any]]]] = None,
reuse_cursor: Optional[Cursor] = None,
auto_close: bool = False,
) -> Tuple[List[Union[List[Row], int]], Cursor]: ...
def getinfo(self, info_type: int) -> Union[str, int, bool, None]: ...
# Context Manager Support
def __enter__(self) -> "Connection": ...
def __exit__(self, *args: Any) -> None: ...
# Module Connection Function
def connect(
connection_str: str = "",
autocommit: bool = False,
attrs_before: Optional[Dict[int, Union[int, str, bytes]]] = None,
timeout: int = 0,
native_uuid: Optional[bool] = None,
**kwargs: Any,
) -> Connection: ...
# SQL Type Constants
SQL_CHAR: int
SQL_VARCHAR: int
SQL_LONGVARCHAR: int
SQL_WCHAR: int
SQL_WVARCHAR: int
SQL_WLONGVARCHAR: int
SQL_DECIMAL: int
SQL_NUMERIC: int
SQL_BIT: int
SQL_TINYINT: int
SQL_SMALLINT: int
SQL_INTEGER: int
SQL_BIGINT: int
SQL_REAL: int
SQL_FLOAT: int
SQL_DOUBLE: int
SQL_BINARY: int
SQL_VARBINARY: int
SQL_LONGVARBINARY: int
SQL_DATE: int
SQL_TIME: int
SQL_TIMESTAMP: int
SQL_WMETADATA: int
# Connection Attribute Constants
SQL_ATTR_ACCESS_MODE: int
SQL_ATTR_CONNECTION_TIMEOUT: int
SQL_ATTR_CURRENT_CATALOG: int
SQL_ATTR_LOGIN_TIMEOUT: int
SQL_ATTR_PACKET_SIZE: int
SQL_ATTR_TXN_ISOLATION: int
# Transaction Isolation Level Constants
SQL_TXN_READ_UNCOMMITTED: int
SQL_TXN_READ_COMMITTED: int
SQL_TXN_REPEATABLE_READ: int
SQL_TXN_SERIALIZABLE: int
# Access Mode Constants
SQL_MODE_READ_WRITE: int
SQL_MODE_READ_ONLY: int
# GetInfo Constants for Connection.getinfo()
SQL_DRIVER_NAME: int
SQL_DRIVER_VER: int
SQL_DRIVER_ODBC_VER: int
SQL_DATA_SOURCE_NAME: int
SQL_DATABASE_NAME: int
SQL_SERVER_NAME: int
SQL_USER_NAME: int
SQL_SQL_CONFORMANCE: int
SQL_KEYWORDS: int
SQL_IDENTIFIER_QUOTE_CHAR: int
SQL_SEARCH_PATTERN_ESCAPE: int
SQL_CATALOG_TERM: int
SQL_SCHEMA_TERM: int
SQL_TABLE_TERM: int
SQL_PROCEDURE_TERM: int
SQL_TXN_CAPABLE: int
SQL_DEFAULT_TXN_ISOLATION: int
SQL_NUMERIC_FUNCTIONS: int
SQL_STRING_FUNCTIONS: int
SQL_DATETIME_FUNCTIONS: int
SQL_MAX_COLUMN_NAME_LEN: int
SQL_MAX_TABLE_NAME_LEN: int
SQL_MAX_SCHEMA_NAME_LEN: int
SQL_MAX_CATALOG_NAME_LEN: int
SQL_MAX_IDENTIFIER_LEN: int