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
15 def DateFromTicks(ticks: float) -> Date: ...
16 def TimeFromTicks(ticks: float) -> Time: ...
17 def TimestampFromTicks(ticks: float) -> Timestamp: ...
19 version_info: tuple[int, int, int]
20 sqlite_version_info: tuple[int, int, int]
23 # The remaining definitions are imported from _sqlite3.
27 SQLITE_ALTER_TABLE: 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
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
51 if sys.version_info >= (3, 7):
52 SQLITE_DROP_VTABLE: 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
73 if sys.version_info >= (3, 7):
77 SQLITE_TRANSACTION: int
84 # TODO: adapt needs to get probed
85 def adapt(obj, protocol, alternate): ...
86 def complete_statement(sql: str) -> bool: ...
88 if sys.version_info >= (3, 7):
90 database: StrOrBytesPath,
92 detect_types: int = ...,
93 isolation_level: str | None = ...,
94 check_same_thread: bool = ...,
95 factory: Type[Connection] | None = ...,
96 cached_statements: int = ...,
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 = ...,
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: ...
117 if sys.version_info < (3, 8):
119 def __init__(self, *args, **kwargs) -> None: ...
120 def display(self, *args, **kwargs) -> None: ...
121 def get(self, *args, **kwargs) -> None: ...
123 class _AggregateProtocol(Protocol):
124 def step(self, value: int) -> None: ...
125 def finalize(self) -> int: ...
127 class Connection(object):
134 NotSupportedError: Any
135 OperationalError: Any
136 ProgrammingError: 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: ...
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):
177 progress: Callable[[int, int, int], object] | 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: ...
185 class Cursor(Iterator[Any]):
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: ...
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): ...
217 OptimizedUnicode = str
219 class PrepareProtocol(object):
220 def __init__(self, *args: Any, **kwargs: Any) -> None: ...
222 class ProgrammingError(DatabaseError): ...
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): ...
238 if sys.version_info < (3, 8):
239 class Statement(object):
240 def __init__(self, *args, **kwargs): ...
242 class Warning(Exception): ...