1 # Filip Hron <filip.hron@gmail.com>
\r
2 # based heavily on Andrey Vlasovskikh's python-skeletons https://github.com/JetBrains/python-skeletons/blob/master/sqlite3.py
\r
5 from typing import Any, Callable, Iterable, Iterator, List, Optional, Text, Tuple, Type, TypeVar, Union
\r
6 from datetime import date, time, datetime
\r
15 Timestamp = datetime
\r
17 def DateFromTicks(ticks): ...
\r
18 def TimeFromTicks(ticks): ...
\r
19 def TimestampFromTicks(ticks): ...
\r
22 sqlite_version_info: Tuple[int, int, int]
\r
23 if sys.version_info >= (3,):
\r
28 def register_adapters_and_converters(): ...
\r
30 # The remaining definitions are imported from _sqlite3.
\r
32 PARSE_COLNAMES = ... # type: int
\r
33 PARSE_DECLTYPES = ... # type: int
\r
34 SQLITE_ALTER_TABLE = ... # type: int
\r
35 SQLITE_ANALYZE = ... # type: int
\r
36 SQLITE_ATTACH = ... # type: int
\r
37 SQLITE_CREATE_INDEX = ... # type: int
\r
38 SQLITE_CREATE_TABLE = ... # type: int
\r
39 SQLITE_CREATE_TEMP_INDEX = ... # type: int
\r
40 SQLITE_CREATE_TEMP_TABLE = ... # type: int
\r
41 SQLITE_CREATE_TEMP_TRIGGER = ... # type: int
\r
42 SQLITE_CREATE_TEMP_VIEW = ... # type: int
\r
43 SQLITE_CREATE_TRIGGER = ... # type: int
\r
44 SQLITE_CREATE_VIEW = ... # type: int
\r
45 SQLITE_DELETE = ... # type: int
\r
46 SQLITE_DENY = ... # type: int
\r
47 SQLITE_DETACH = ... # type: int
\r
48 SQLITE_DROP_INDEX = ... # type: int
\r
49 SQLITE_DROP_TABLE = ... # type: int
\r
50 SQLITE_DROP_TEMP_INDEX = ... # type: int
\r
51 SQLITE_DROP_TEMP_TABLE = ... # type: int
\r
52 SQLITE_DROP_TEMP_TRIGGER = ... # type: int
\r
53 SQLITE_DROP_TEMP_VIEW = ... # type: int
\r
54 SQLITE_DROP_TRIGGER = ... # type: int
\r
55 SQLITE_DROP_VIEW = ... # type: int
\r
56 SQLITE_IGNORE = ... # type: int
\r
57 SQLITE_INSERT = ... # type: int
\r
58 SQLITE_OK = ... # type: int
\r
59 SQLITE_PRAGMA = ... # type: int
\r
60 SQLITE_READ = ... # type: int
\r
61 SQLITE_REINDEX = ... # type: int
\r
62 SQLITE_SELECT = ... # type: int
\r
63 SQLITE_TRANSACTION = ... # type: int
\r
64 SQLITE_UPDATE = ... # type: int
\r
65 adapters = ... # type: Any
\r
66 converters = ... # type: Any
\r
67 sqlite_version = ... # type: str
\r
68 version = ... # type: str
\r
70 # TODO: adapt needs to get probed
\r
71 def adapt(obj, protocol, alternate): ...
\r
72 def complete_statement(sql: str) -> bool: ...
\r
73 if sys.version_info >= (3, 4):
\r
74 def connect(database: Union[bytes, Text],
\r
75 timeout: float = ...,
\r
76 detect_types: int = ...,
\r
77 isolation_level: Optional[str] = ...,
\r
78 check_same_thread: bool = ...,
\r
79 factory: Optional[Type[Connection]] = ...,
\r
80 cached_statements: int = ...,
\r
81 uri: bool = ...) -> Connection: ...
\r
83 def connect(database: Union[bytes, Text],
\r
84 timeout: float = ...,
\r
85 detect_types: int = ...,
\r
86 isolation_level: Optional[str] = ...,
\r
87 check_same_thread: bool = ...,
\r
88 factory: Optional[Type[Connection]] = ...,
\r
89 cached_statements: int = ...) -> Connection: ...
\r
90 def enable_callback_tracebacks(flag: bool) -> None: ...
\r
91 def enable_shared_cache(do_enable: int) -> None: ...
\r
92 def register_adapter(type: Type[_T], callable: Callable[[_T], Union[int, float, str, bytes]]) -> None: ...
\r
93 def register_converter(typename: str, callable: Callable[[bytes], Any]) -> None: ...
\r
95 class Cache(object):
\r
96 def __init__(self, *args, **kwargs) -> None: ...
\r
97 def display(self, *args, **kwargs) -> None: ...
\r
98 def get(self, *args, **kwargs) -> None: ...
\r
100 class Connection(object):
\r
101 DataError = ... # type: Any
\r
102 DatabaseError = ... # type: Any
\r
103 Error = ... # type: Any
\r
104 IntegrityError = ... # type: Any
\r
105 InterfaceError = ... # type: Any
\r
106 InternalError = ... # type: Any
\r
107 NotSupportedError = ... # type: Any
\r
108 OperationalError = ... # type: Any
\r
109 ProgrammingError = ... # type: Any
\r
110 Warning = ... # type: Any
\r
111 in_transaction = ... # type: Any
\r
112 isolation_level = ... # type: Any
\r
113 row_factory = ... # type: Any
\r
114 text_factory = ... # type: Any
\r
115 total_changes = ... # type: Any
\r
116 def __init__(self, *args, **kwargs): ...
\r
117 def close(self) -> None: ...
\r
118 def commit(self) -> None: ...
\r
119 def create_aggregate(self, name: str, num_params: int, aggregate_class: type) -> None: ...
\r
120 def create_collation(self, name: str, callable: Any) -> None: ...
\r
121 def create_function(self, name: str, num_params: int, func: Any) -> None: ...
\r
122 def cursor(self, cursorClass: Optional[type] = ...) -> Cursor: ...
\r
123 def execute(self, sql: str, parameters: Iterable = ...) -> Cursor: ...
\r
124 # TODO: please check in executemany() if seq_of_parameters type is possible like this
\r
125 def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]) -> Cursor: ...
\r
126 def executescript(self, sql_script: Union[bytes, Text]) -> Cursor: ...
\r
127 def interrupt(self, *args, **kwargs) -> None: ...
\r
128 def iterdump(self, *args, **kwargs) -> None: ...
\r
129 def rollback(self, *args, **kwargs) -> None: ...
\r
130 # TODO: set_authorizer(authorzer_callback)
\r
131 # see https://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.set_authorizer
\r
132 # returns [SQLITE_OK, SQLITE_DENY, SQLITE_IGNORE] so perhaps int
\r
133 def set_authorizer(self, *args, **kwargs) -> None: ...
\r
134 # set_progress_handler(handler, n) -> see https://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.set_progress_handler
\r
135 def set_progress_handler(self, *args, **kwargs) -> None: ...
\r
136 def set_trace_callback(self, *args, **kwargs): ...
\r
137 if sys.version_info >= (3, 7):
\r
138 def backup(self, target: Connection, *, pages: int = ...,
\r
139 progress: Optional[Callable[[int, int, int], object]] = ..., name: str = ...,
\r
140 sleep: float = ...) -> None: ...
\r
141 def __call__(self, *args, **kwargs): ...
\r
142 def __enter__(self, *args, **kwargs): ...
\r
143 def __exit__(self, *args, **kwargs): ...
\r
145 class Cursor(Iterator[Any]):
\r
146 arraysize = ... # type: Any
\r
147 connection = ... # type: Any
\r
148 description = ... # type: Any
\r
149 lastrowid = ... # type: Any
\r
150 row_factory = ... # type: Any
\r
151 rowcount = ... # type: Any
\r
152 # TODO: Cursor class accepts exactly 1 argument
\r
153 # required type is sqlite3.Connection (which is imported as _Connection)
\r
154 # however, the name of the __init__ variable is unknown
\r
155 def __init__(self, *args, **kwargs): ...
\r
156 def close(self, *args, **kwargs): ...
\r
157 def execute(self, sql: str, parameters: Iterable = ...) -> Cursor: ...
\r
158 def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]): ...
\r
159 def executescript(self, sql_script: Union[bytes, Text]) -> Cursor: ...
\r
160 def fetchall(self) -> List[Any]: ...
\r
161 def fetchmany(self, size: Optional[int] = ...) -> List[Any]: ...
\r
162 def fetchone(self) -> Any: ...
\r
163 def setinputsizes(self, *args, **kwargs): ...
\r
164 def setoutputsize(self, *args, **kwargs): ...
\r
165 def __iter__(self) -> Cursor: ...
\r
166 if sys.version_info >= (3, 0):
\r
167 def __next__(self) -> Any: ...
\r
169 def next(self) -> Any: ...
\r
172 class DataError(DatabaseError): ...
\r
174 class DatabaseError(Error): ...
\r
176 class Error(Exception): ...
\r
178 class IntegrityError(DatabaseError): ...
\r
180 class InterfaceError(Error): ...
\r
182 class InternalError(DatabaseError): ...
\r
184 class NotSupportedError(DatabaseError): ...
\r
186 class OperationalError(DatabaseError): ...
\r
188 class OptimizedUnicode(object):
\r
189 maketrans = ... # type: Any
\r
190 def __init__(self, *args, **kwargs): ...
\r
191 def capitalize(self, *args, **kwargs): ...
\r
192 def casefold(self, *args, **kwargs): ...
\r
193 def center(self, *args, **kwargs): ...
\r
194 def count(self, *args, **kwargs): ...
\r
195 def encode(self, *args, **kwargs): ...
\r
196 def endswith(self, *args, **kwargs): ...
\r
197 def expandtabs(self, *args, **kwargs): ...
\r
198 def find(self, *args, **kwargs): ...
\r
199 def format(self, *args, **kwargs): ...
\r
200 def format_map(self, *args, **kwargs): ...
\r
201 def index(self, *args, **kwargs): ...
\r
202 def isalnum(self, *args, **kwargs): ...
\r
203 def isalpha(self, *args, **kwargs): ...
\r
204 def isdecimal(self, *args, **kwargs): ...
\r
205 def isdigit(self, *args, **kwargs): ...
\r
206 def isidentifier(self, *args, **kwargs): ...
\r
207 def islower(self, *args, **kwargs): ...
\r
208 def isnumeric(self, *args, **kwargs): ...
\r
209 def isprintable(self, *args, **kwargs): ...
\r
210 def isspace(self, *args, **kwargs): ...
\r
211 def istitle(self, *args, **kwargs): ...
\r
212 def isupper(self, *args, **kwargs): ...
\r
213 def join(self, *args, **kwargs): ...
\r
214 def ljust(self, *args, **kwargs): ...
\r
215 def lower(self, *args, **kwargs): ...
\r
216 def lstrip(self, *args, **kwargs): ...
\r
217 def partition(self, *args, **kwargs): ...
\r
218 def replace(self, *args, **kwargs): ...
\r
219 def rfind(self, *args, **kwargs): ...
\r
220 def rindex(self, *args, **kwargs): ...
\r
221 def rjust(self, *args, **kwargs): ...
\r
222 def rpartition(self, *args, **kwargs): ...
\r
223 def rsplit(self, *args, **kwargs): ...
\r
224 def rstrip(self, *args, **kwargs): ...
\r
225 def split(self, *args, **kwargs): ...
\r
226 def splitlines(self, *args, **kwargs): ...
\r
227 def startswith(self, *args, **kwargs): ...
\r
228 def strip(self, *args, **kwargs): ...
\r
229 def swapcase(self, *args, **kwargs): ...
\r
230 def title(self, *args, **kwargs): ...
\r
231 def translate(self, *args, **kwargs): ...
\r
232 def upper(self, *args, **kwargs): ...
\r
233 def zfill(self, *args, **kwargs): ...
\r
234 def __add__(self, other): ...
\r
235 def __contains__(self, *args, **kwargs): ...
\r
236 def __eq__(self, other): ...
\r
237 def __format__(self, *args, **kwargs): ...
\r
238 def __ge__(self, other): ...
\r
239 def __getitem__(self, index): ...
\r
240 def __getnewargs__(self, *args, **kwargs): ...
\r
241 def __gt__(self, other): ...
\r
242 def __hash__(self): ...
\r
243 def __iter__(self): ...
\r
244 def __le__(self, other): ...
\r
245 def __len__(self, *args, **kwargs): ...
\r
246 def __lt__(self, other): ...
\r
247 def __mod__(self, other): ...
\r
248 def __mul__(self, other): ...
\r
249 def __ne__(self, other): ...
\r
250 def __rmod__(self, other): ...
\r
251 def __rmul__(self, other): ...
\r
253 class PrepareProtocol(object):
\r
254 def __init__(self, *args, **kwargs): ...
\r
256 class ProgrammingError(DatabaseError): ...
\r
259 def __init__(self, *args, **kwargs): ...
\r
260 def keys(self, *args, **kwargs): ...
\r
261 def __eq__(self, other): ...
\r
262 def __ge__(self, other): ...
\r
263 def __getitem__(self, index): ...
\r
264 def __gt__(self, other): ...
\r
265 def __hash__(self): ...
\r
266 def __iter__(self): ...
\r
267 def __le__(self, other): ...
\r
268 def __len__(self, *args, **kwargs): ...
\r
269 def __lt__(self, other): ...
\r
270 def __ne__(self, other): ...
\r
272 class Statement(object):
\r
273 def __init__(self, *args, **kwargs): ...
\r
275 class Warning(Exception): ...
\r