massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / sqlite3 / dbapi2.pyi
1 import sys
2 from _typeshed import Self, StrOrBytesPath
3 from datetime import date, datetime, time
4 from typing import Any, Callable, Generator, Iterable, Iterator, Protocol, Type, TypeVar
5
6 _T = TypeVar("_T")
7
8 paramstyle: str
9 threadsafety: int
10 apilevel: str
11 Date = date
12 Time = time
13 Timestamp = datetime
14
15 def DateFromTicks(ticks: float) -> Date: ...
16 def TimeFromTicks(ticks: float) -> Time: ...
17 def TimestampFromTicks(ticks: float) -> Timestamp: ...
18
19 version_info: tuple[int, int, int]
20 sqlite_version_info: tuple[int, int, int]
21 Binary = memoryview
22
23 # The remaining definitions are imported from _sqlite3.
24
25 PARSE_COLNAMES: int
26 PARSE_DECLTYPES: int
27 SQLITE_ALTER_TABLE: int
28 SQLITE_ANALYZE: int
29 SQLITE_ATTACH: int
30 SQLITE_CREATE_INDEX: int
31 SQLITE_CREATE_TABLE: int
32 SQLITE_CREATE_TEMP_INDEX: int
33 SQLITE_CREATE_TEMP_TABLE: int
34 SQLITE_CREATE_TEMP_TRIGGER: int
35 SQLITE_CREATE_TEMP_VIEW: int
36 SQLITE_CREATE_TRIGGER: int
37 SQLITE_CREATE_VIEW: int
38 if sys.version_info >= (3, 7):
39     SQLITE_CREATE_VTABLE: int
40 SQLITE_DELETE: int
41 SQLITE_DENY: int
42 SQLITE_DETACH: int
43 SQLITE_DROP_INDEX: int
44 SQLITE_DROP_TABLE: int
45 SQLITE_DROP_TEMP_INDEX: int
46 SQLITE_DROP_TEMP_TABLE: int
47 SQLITE_DROP_TEMP_TRIGGER: int
48 SQLITE_DROP_TEMP_VIEW: int
49 SQLITE_DROP_TRIGGER: int
50 SQLITE_DROP_VIEW: int
51 if sys.version_info >= (3, 7):
52     SQLITE_DROP_VTABLE: int
53     SQLITE_FUNCTION: int
54 SQLITE_IGNORE: int
55 SQLITE_INSERT: int
56 SQLITE_OK: int
57 if sys.version_info >= (3, 11):
58     SQLITE_LIMIT_LENGTH: int
59     SQLITE_LIMIT_SQL_LENGTH: int
60     SQLITE_LIMIT_COLUMN: int
61     SQLITE_LIMIT_EXPR_DEPTH: int
62     SQLITE_LIMIT_COMPOUND_SELECT: int
63     SQLITE_LIMIT_VDBE_OP: int
64     SQLITE_LIMIT_FUNCTION_ARG: int
65     SQLITE_LIMIT_ATTACHED: int
66     SQLITE_LIMIT_LIKE_PATTERN_LENGTH: int
67     SQLITE_LIMIT_VARIABLE_NUMBER: int
68     SQLITE_LIMIT_TRIGGER_DEPTH: int
69     SQLITE_LIMIT_WORKER_THREADS: int
70 SQLITE_PRAGMA: int
71 SQLITE_READ: int
72 SQLITE_REINDEX: int
73 if sys.version_info >= (3, 7):
74     SQLITE_RECURSIVE: int
75     SQLITE_SAVEPOINT: int
76 SQLITE_SELECT: int
77 SQLITE_TRANSACTION: int
78 SQLITE_UPDATE: int
79 adapters: Any
80 converters: Any
81 sqlite_version: str
82 version: str
83
84 # TODO: adapt needs to get probed
85 def adapt(obj, protocol, alternate): ...
86 def complete_statement(sql: str) -> bool: ...
87
88 if sys.version_info >= (3, 7):
89     def connect(
90         database: StrOrBytesPath,
91         timeout: float = ...,
92         detect_types: int = ...,
93         isolation_level: str | None = ...,
94         check_same_thread: bool = ...,
95         factory: Type[Connection] | None = ...,
96         cached_statements: int = ...,
97         uri: bool = ...,
98     ) -> Connection: ...
99
100 else:
101     def connect(
102         database: bytes | str,
103         timeout: float = ...,
104         detect_types: int = ...,
105         isolation_level: str | None = ...,
106         check_same_thread: bool = ...,
107         factory: Type[Connection] | None = ...,
108         cached_statements: int = ...,
109         uri: bool = ...,
110     ) -> Connection: ...
111
112 def enable_callback_tracebacks(__enable: bool) -> None: ...
113 def enable_shared_cache(enable: int) -> None: ...
114 def register_adapter(__type: Type[_T], __caster: Callable[[_T], int | float | str | bytes]) -> None: ...
115 def register_converter(__name: str, __converter: Callable[[bytes], Any]) -> None: ...
116
117 if sys.version_info < (3, 8):
118     class Cache(object):
119         def __init__(self, *args, **kwargs) -> None: ...
120         def display(self, *args, **kwargs) -> None: ...
121         def get(self, *args, **kwargs) -> None: ...
122
123 class _AggregateProtocol(Protocol):
124     def step(self, value: int) -> None: ...
125     def finalize(self) -> int: ...
126
127 class Connection(object):
128     DataError: Any
129     DatabaseError: Any
130     Error: Any
131     IntegrityError: Any
132     InterfaceError: Any
133     InternalError: Any
134     NotSupportedError: Any
135     OperationalError: Any
136     ProgrammingError: Any
137     Warning: Any
138     in_transaction: Any
139     isolation_level: Any
140     row_factory: Any
141     text_factory: Any
142     total_changes: Any
143     def __init__(self, *args: Any, **kwargs: Any) -> None: ...
144     def close(self) -> None: ...
145     def commit(self) -> None: ...
146     def create_aggregate(self, name: str, n_arg: int, aggregate_class: Callable[[], _AggregateProtocol]) -> None: ...
147     def create_collation(self, __name: str, __callback: Any) -> None: ...
148     if sys.version_info >= (3, 8):
149         def create_function(self, name: str, narg: int, func: Any, *, deterministic: bool = ...) -> None: ...
150     else:
151         def create_function(self, name: str, num_params: int, func: Any) -> None: ...
152     def cursor(self, cursorClass: type | None = ...) -> Cursor: ...
153     def execute(self, sql: str, parameters: Iterable[Any] = ...) -> Cursor: ...
154     # TODO: please check in executemany() if seq_of_parameters type is possible like this
155     def executemany(self, __sql: str, __parameters: Iterable[Iterable[Any]]) -> Cursor: ...
156     def executescript(self, __sql_script: bytes | str) -> Cursor: ...
157     def interrupt(self, *args: Any, **kwargs: Any) -> None: ...
158     def iterdump(self, *args: Any, **kwargs: Any) -> Generator[str, None, None]: ...
159     def rollback(self, *args: Any, **kwargs: Any) -> None: ...
160     # TODO: set_authorizer(authorzer_callback)
161     # see https://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.set_authorizer
162     # returns [SQLITE_OK, SQLITE_DENY, SQLITE_IGNORE] so perhaps int
163     def set_authorizer(self, *args: Any, **kwargs: Any) -> None: ...
164     # set_progress_handler(handler, n) -> see https://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.set_progress_handler
165     def set_progress_handler(self, *args: Any, **kwargs: Any) -> None: ...
166     def set_trace_callback(self, *args: Any, **kwargs: Any) -> None: ...
167     # enable_load_extension and load_extension is not available on python distributions compiled
168     # without sqlite3 loadable extension support. see footnotes https://docs.python.org/3/library/sqlite3.html#f1
169     def enable_load_extension(self, enabled: bool) -> None: ...
170     def load_extension(self, path: str) -> None: ...
171     if sys.version_info >= (3, 7):
172         def backup(
173             self,
174             target: Connection,
175             *,
176             pages: int = ...,
177             progress: Callable[[int, int, int], object] | None = ...,
178             name: str = ...,
179             sleep: float = ...,
180         ) -> None: ...
181     def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
182     def __enter__(self: Self) -> Self: ...
183     def __exit__(self, t: type | None, exc: BaseException | None, tb: Any | None) -> None: ...
184
185 class Cursor(Iterator[Any]):
186     arraysize: Any
187     connection: Any
188     description: Any
189     lastrowid: Any
190     row_factory: Any
191     rowcount: int
192     # TODO: Cursor class accepts exactly 1 argument
193     # required type is sqlite3.Connection (which is imported as _Connection)
194     # however, the name of the __init__ variable is unknown
195     def __init__(self, *args: Any, **kwargs: Any) -> None: ...
196     def close(self, *args: Any, **kwargs: Any) -> None: ...
197     def execute(self, __sql: str, __parameters: Iterable[Any] = ...) -> Cursor: ...
198     def executemany(self, __sql: str, __seq_of_parameters: Iterable[Iterable[Any]]) -> Cursor: ...
199     def executescript(self, __sql_script: bytes | str) -> Cursor: ...
200     def fetchall(self) -> list[Any]: ...
201     def fetchmany(self, size: int | None = ...) -> list[Any]: ...
202     def fetchone(self) -> Any: ...
203     def setinputsizes(self, *args: Any, **kwargs: Any) -> None: ...
204     def setoutputsize(self, *args: Any, **kwargs: Any) -> None: ...
205     def __iter__(self) -> Cursor: ...
206     def __next__(self) -> Any: ...
207
208 class DataError(DatabaseError): ...
209 class DatabaseError(Error): ...
210 class Error(Exception): ...
211 class IntegrityError(DatabaseError): ...
212 class InterfaceError(Error): ...
213 class InternalError(DatabaseError): ...
214 class NotSupportedError(DatabaseError): ...
215 class OperationalError(DatabaseError): ...
216
217 OptimizedUnicode = str
218
219 class PrepareProtocol(object):
220     def __init__(self, *args: Any, **kwargs: Any) -> None: ...
221
222 class ProgrammingError(DatabaseError): ...
223
224 class Row(object):
225     def __init__(self, *args: Any, **kwargs: Any) -> None: ...
226     def keys(self, *args: Any, **kwargs: Any): ...
227     def __eq__(self, other): ...
228     def __ge__(self, other): ...
229     def __getitem__(self, index): ...
230     def __gt__(self, other): ...
231     def __hash__(self): ...
232     def __iter__(self): ...
233     def __le__(self, other): ...
234     def __len__(self): ...
235     def __lt__(self, other): ...
236     def __ne__(self, other): ...
237
238 if sys.version_info < (3, 8):
239     class Statement(object):
240         def __init__(self, *args, **kwargs): ...
241
242 class Warning(Exception): ...