2
2
# based heavily on Andrey Vlasovskikh's python-skeletons https://github.com/JetBrains/python-skeletons/blob/master/sqlite3.py
3
3
4
4
import sys
5
- from typing import Any , Union , List , Iterator , Optional , TypeVar , Callable
6
- from datetime import time , datetime
7
- from collections import Iterable
5
+ from typing import Any , Callable , Iterable , Iterator , List , Optional , Text , Tuple , Type , TypeVar , Union
6
+ from datetime import date , time , datetime
8
7
9
8
_T = TypeVar ('_T' )
10
9
11
- paramstyle = ... # type : str
12
- threadsafety = ... # type : int
13
- apilevel = ... # type : str
14
- Date = ... # type: datetime
15
- Time = ... # type: time
16
- Timestamp = ... # type: datetime
10
+ paramstyle : str
11
+ threadsafety : int
12
+ apilevel : str
13
+ Date = date
14
+ Time = time
15
+ Timestamp = datetime
17
16
18
17
def DateFromTicks (ticks ): ...
19
18
def TimeFromTicks (ticks ): ...
20
19
def TimestampFromTicks (ticks ): ...
21
20
22
- version_info = ... # type: Any
23
- sqlite_version_info = ... # type: Any
24
- Binary = ... # type: Any
21
+ version_info : str
22
+ sqlite_version_info : Tuple [ int , int , int ]
23
+ Binary : Type [ Any ]
25
24
26
25
def register_adapters_and_converters (): ...
27
26
@@ -69,21 +68,33 @@ version = ... # type: str
69
68
def adapt (obj , protocol , alternate ): ...
70
69
def complete_statement (sql : str ) -> bool : ...
71
70
if sys .version_info >= (3 , 4 ):
72
- def connect (database : Union [bytes , str ], timeout : float = ..., detect_types : int = ..., isolation_level : Union [str , None ] = ..., check_same_thread : bool = ..., factory : Union [Connection , None ] = ..., cached_statements : int = ..., uri : bool = ...) -> Connection : ...
71
+ def connect (database : Union [bytes , Text ],
72
+ timeout : float = ...,
73
+ detect_types : int = ...,
74
+ isolation_level : Optional [str ] = ...,
75
+ check_same_thread : bool = ...,
76
+ factory : Optional [Type [Connection ]] = ...,
77
+ cached_statements : int = ...,
78
+ uri : bool = ...) -> Connection : ...
73
79
else :
74
- def connect (database : Union [bytes , str ], timeout : float = ..., detect_types : int = ..., isolation_level : Union [str , None ] = ..., check_same_thread : bool = ..., factory : Union [Connection , None ] = ..., cached_statements : int = ...) -> Connection : ...
80
+ def connect (database : Union [bytes , Text ],
81
+ timeout : float = ...,
82
+ detect_types : int = ...,
83
+ isolation_level : Optional [str ] = ...,
84
+ check_same_thread : bool = ...,
85
+ factory : Optional [Type [Connection ]] = ...,
86
+ cached_statements : int = ...) -> Connection : ...
75
87
def enable_callback_tracebacks (flag : bool ) -> None : ...
76
88
def enable_shared_cache (do_enable : int ) -> None : ...
77
- def register_adapter (type : _T , callable : Callable [[_T ], Union [int , float , str , bytes ]]) -> None : ...
78
- # TODO: sqlite3.register_converter.__doc__ specifies callable as unknown
89
+ def register_adapter (type : Type [_T ], callable : Callable [[_T ], Union [int , float , str , bytes ]]) -> None : ...
79
90
def register_converter (typename : str , callable : Callable [[bytes ], Any ]) -> None : ...
80
91
81
- class Cache :
92
+ class Cache ( object ) :
82
93
def __init__ (self , * args , ** kwargs ) -> None : ...
83
94
def display (self , * args , ** kwargs ) -> None : ...
84
95
def get (self , * args , ** kwargs ) -> None : ...
85
96
86
- class Connection :
97
+ class Connection ( object ) :
87
98
DataError = ... # type: Any
88
99
DatabaseError = ... # type: Any
89
100
Error = ... # type: Any
@@ -109,7 +120,7 @@ class Connection:
109
120
def execute (self , sql : str , parameters : Iterable = ...) -> Cursor : ...
110
121
# TODO: please check in executemany() if seq_of_parameters type is possible like this
111
122
def executemany (self , sql : str , seq_of_parameters : Iterable [Iterable ]) -> Cursor : ...
112
- def executescript (self , sql_script : Union [bytes , str ]) -> Cursor : ...
123
+ def executescript (self , sql_script : Union [bytes , Text ]) -> Cursor : ...
113
124
def interrupt (self , * args , ** kwargs ) -> None : ...
114
125
def iterdump (self , * args , ** kwargs ) -> None : ...
115
126
def rollback (self , * args , ** kwargs ) -> None : ...
@@ -142,7 +153,7 @@ class Cursor(Iterator[Any]):
142
153
def close (self , * args , ** kwargs ): ...
143
154
def execute (self , sql : str , parameters : Iterable = ...) -> Cursor : ...
144
155
def executemany (self , sql : str , seq_of_parameters : Iterable [Iterable ]): ...
145
- def executescript (self , sql_script : Union [bytes , str ]) -> Cursor : ...
156
+ def executescript (self , sql_script : Union [bytes , Text ]) -> Cursor : ...
146
157
def fetchall (self ) -> List [Any ]: ...
147
158
def fetchmany (self , size : Optional [int ] = ...) -> List [Any ]: ...
148
159
def fetchone (self ) -> Any : ...
@@ -168,7 +179,7 @@ class NotSupportedError(DatabaseError): ...
168
179
169
180
class OperationalError (DatabaseError ): ...
170
181
171
- class OptimizedUnicode :
182
+ class OptimizedUnicode ( object ) :
172
183
maketrans = ... # type: Any
173
184
def __init__ (self , * args , ** kwargs ): ...
174
185
def capitalize (self , * args , ** kwargs ): ...
@@ -233,12 +244,12 @@ class OptimizedUnicode:
233
244
def __rmod__ (self , other ): ...
234
245
def __rmul__ (self , other ): ...
235
246
236
- class PrepareProtocol :
247
+ class PrepareProtocol ( object ) :
237
248
def __init__ (self , * args , ** kwargs ): ...
238
249
239
250
class ProgrammingError (DatabaseError ): ...
240
251
241
- class Row :
252
+ class Row ( object ) :
242
253
def __init__ (self , * args , ** kwargs ): ...
243
254
def keys (self , * args , ** kwargs ): ...
244
255
def __eq__ (self , other ): ...
@@ -252,7 +263,7 @@ class Row:
252
263
def __lt__ (self , other ): ...
253
264
def __ne__ (self , other ): ...
254
265
255
- class Statement :
266
+ class Statement ( object ) :
256
267
def __init__ (self , * args , ** kwargs ): ...
257
268
258
269
class Warning (Exception ): ...
0 commit comments