forked from microsoft/mssql-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmssql_python.pyi
More file actions
192 lines (157 loc) · 4.67 KB
/
mssql_python.pyi
File metadata and controls
192 lines (157 loc) · 4.67 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
"""
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
"""
from typing import Final, Union
import datetime
# GLOBALS
# Read-Only
apilevel: Final[str] = "2.0"
paramstyle: Final[str] = "pyformat"
threadsafety: Final[int] = 1
# Type Objects
# https://www.python.org/dev/peps/pep-0249/#type-objects
class STRING:
"""
This type object is used to describe columns in a database that are string-based (e.g. CHAR).
"""
def __init__(self) -> None: ...
class BINARY:
"""
This type object is used to describe (long)
binary columns in a database (e.g. LONG, RAW, BLOBs).
"""
def __init__(self) -> None: ...
class NUMBER:
"""
This type object is used to describe numeric columns in a database.
"""
def __init__(self) -> None: ...
class DATETIME:
"""
This type object is used to describe date/time columns in a database.
"""
def __init__(self) -> None: ...
class ROWID:
"""
This type object is used to describe the “Row ID” column in a database.
"""
def __init__(self) -> None: ...
# 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(string: str) -> bytes: ...
# Exceptions
# https://www.python.org/dev/peps/pep-0249/#exceptions
class Warning(Exception): ...
class Error(Exception): ...
class InterfaceError(Error): ...
class DatabaseError(Error): ...
class DataError(DatabaseError): ...
class OperationalError(DatabaseError): ...
class IntegrityError(DatabaseError): ...
class InternalError(DatabaseError): ...
class ProgrammingError(DatabaseError): ...
class NotSupportedError(DatabaseError): ...
# Connection Objects
class Connection:
"""
Connection object for interacting with the database.
https://www.python.org/dev/peps/pep-0249/#connection-objects
This class should not be instantiated directly, instead call global connect() method to
create a Connection object.
"""
def cursor(self) -> "Cursor":
"""
Return a new Cursor object using the connection.
"""
...
def commit(self) -> None:
"""
Commit the current transaction.
"""
...
def rollback(self) -> None:
"""
Roll back the current transaction.
"""
...
def close(self) -> None:
"""
Close the connection now.
"""
...
# Cursor Objects
class Cursor:
"""
Cursor object for executing SQL queries and fetching results.
https://www.python.org/dev/peps/pep-0249/#cursor-objects
This class should not be instantiated directly, instead call cursor() from a Connection
object to create a Cursor object.
"""
def callproc(
self, procname: str, parameters: Union[None, list] = None
) -> Union[None, list]:
"""
Call a stored database procedure with the given name.
"""
...
def close(self) -> None:
"""
Close the cursor now.
"""
...
def execute(
self, operation: str, parameters: Union[None, list, dict] = None
) -> None:
"""
Prepare and execute a database operation (query or command).
"""
...
def executemany(self, operation: str, seq_of_parameters: list) -> None:
"""
Prepare a database operation and execute it against all parameter sequences.
"""
...
def fetchone(self) -> Union[None, tuple]:
"""
Fetch the next row of a query result set.
"""
...
def fetchmany(self, size: int = None) -> list:
"""
Fetch the next set of rows of a query result.
"""
...
def fetchall(self) -> list:
"""
Fetch all (remaining) rows of a query result.
"""
...
def nextset(self) -> Union[None, bool]:
"""
Skip to the next available result set.
"""
...
def setinputsizes(self, sizes: list) -> None:
"""
Predefine memory areas for the operation’s parameters.
"""
...
def setoutputsize(self, size: int, column: int = None) -> None:
"""
Set a column buffer size for fetches of large columns.
"""
...
# Module Functions
def connect(connection_str: str) -> Connection:
"""
Constructor for creating a connection to the database.
"""
...