Format: application/octet-stream
⬇ Download File (11.0 KB)
   1  import os
   2  import sys
   3  from datetime import date, datetime, time
   4  from typing import Any, Callable, Generator, Iterable, Iterator, List, Optional, Text, Tuple, Type, TypeVar, Union
   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: str
  20  sqlite_version_info: Tuple[int, int, int]
  21  if sys.version_info >= (3,):
  22      Binary = memoryview
  23  else:
  24      Binary = buffer
  25  
  26  # The remaining definitions are imported from _sqlite3.
  27  
  28  PARSE_COLNAMES: int
  29  PARSE_DECLTYPES: int
  30  SQLITE_ALTER_TABLE: int
  31  SQLITE_ANALYZE: int
  32  SQLITE_ATTACH: int
  33  SQLITE_CREATE_INDEX: int
  34  SQLITE_CREATE_TABLE: int
  35  SQLITE_CREATE_TEMP_INDEX: int
  36  SQLITE_CREATE_TEMP_TABLE: int
  37  SQLITE_CREATE_TEMP_TRIGGER: int
  38  SQLITE_CREATE_TEMP_VIEW: int
  39  SQLITE_CREATE_TRIGGER: int
  40  SQLITE_CREATE_VIEW: int
  41  SQLITE_DELETE: int
  42  SQLITE_DENY: int
  43  SQLITE_DETACH: int
  44  SQLITE_DROP_INDEX: int
  45  SQLITE_DROP_TABLE: int
  46  SQLITE_DROP_TEMP_INDEX: int
  47  SQLITE_DROP_TEMP_TABLE: int
  48  SQLITE_DROP_TEMP_TRIGGER: int
  49  SQLITE_DROP_TEMP_VIEW: int
  50  SQLITE_DROP_TRIGGER: int
  51  SQLITE_DROP_VIEW: int
  52  SQLITE_IGNORE: int
  53  SQLITE_INSERT: int
  54  SQLITE_OK: int
  55  SQLITE_PRAGMA: int
  56  SQLITE_READ: int
  57  SQLITE_REINDEX: int
  58  SQLITE_SELECT: int
  59  SQLITE_TRANSACTION: int
  60  SQLITE_UPDATE: int
  61  adapters: Any
  62  converters: Any
  63  sqlite_version: str
  64  version: str
  65  
  66  # TODO: adapt needs to get probed
  67  def adapt(obj, protocol, alternate): ...
  68  def complete_statement(sql: str) -> bool: ...
  69  
  70  if sys.version_info >= (3, 7):
  71      def connect(
  72          database: Union[bytes, Text, os.PathLike[Text]],
  73          timeout: float = ...,
  74          detect_types: int = ...,
  75          isolation_level: Optional[str] = ...,
  76          check_same_thread: bool = ...,
  77          factory: Optional[Type[Connection]] = ...,
  78          cached_statements: int = ...,
  79          uri: bool = ...,
  80      ) -> Connection: ...
  81  
  82  elif sys.version_info >= (3, 4):
  83      def connect(
  84          database: Union[bytes, Text],
  85          timeout: float = ...,
  86          detect_types: int = ...,
  87          isolation_level: Optional[str] = ...,
  88          check_same_thread: bool = ...,
  89          factory: Optional[Type[Connection]] = ...,
  90          cached_statements: int = ...,
  91          uri: bool = ...,
  92      ) -> Connection: ...
  93  
  94  else:
  95      def connect(
  96          database: Union[bytes, Text],
  97          timeout: float = ...,
  98          detect_types: int = ...,
  99          isolation_level: Optional[str] = ...,
 100          check_same_thread: bool = ...,
 101          factory: Optional[Type[Connection]] = ...,
 102          cached_statements: int = ...,
 103      ) -> Connection: ...
 104  
 105  def enable_callback_tracebacks(flag: bool) -> None: ...
 106  def enable_shared_cache(do_enable: int) -> None: ...
 107  def register_adapter(type: Type[_T], callable: Callable[[_T], Union[int, float, str, bytes]]) -> None: ...
 108  def register_converter(typename: str, callable: Callable[[bytes], Any]) -> None: ...
 109  
 110  if sys.version_info < (3, 8):
 111      class Cache(object):
 112          def __init__(self, *args, **kwargs) -> None: ...
 113          def display(self, *args, **kwargs) -> None: ...
 114          def get(self, *args, **kwargs) -> None: ...
 115  
 116  class Connection(object):
 117      DataError: Any
 118      DatabaseError: Any
 119      Error: Any
 120      IntegrityError: Any
 121      InterfaceError: Any
 122      InternalError: Any
 123      NotSupportedError: Any
 124      OperationalError: Any
 125      ProgrammingError: Any
 126      Warning: Any
 127      in_transaction: Any
 128      isolation_level: Any
 129      row_factory: Any
 130      text_factory: Any
 131      total_changes: Any
 132      def __init__(self, *args: Any, **kwargs: Any) -> None: ...
 133      def close(self) -> None: ...
 134      def commit(self) -> None: ...
 135      def create_aggregate(self, name: str, num_params: int, aggregate_class: type) -> None: ...
 136      def create_collation(self, name: str, callable: Any) -> None: ...
 137      if sys.version_info >= (3, 8):
 138          def create_function(self, name: str, num_params: int, func: Any, *, deterministic: bool = ...) -> None: ...
 139      else:
 140          def create_function(self, name: str, num_params: int, func: Any) -> None: ...
 141      def cursor(self, cursorClass: Optional[type] = ...) -> Cursor: ...
 142      def execute(self, sql: str, parameters: Iterable[Any] = ...) -> Cursor: ...
 143      # TODO: please check in executemany() if seq_of_parameters type is possible like this
 144      def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable[Any]]) -> Cursor: ...
 145      def executescript(self, sql_script: Union[bytes, Text]) -> Cursor: ...
 146      def interrupt(self, *args: Any, **kwargs: Any) -> None: ...
 147      def iterdump(self, *args: Any, **kwargs: Any) -> Generator[str, None, None]: ...
 148      def rollback(self, *args: Any, **kwargs: Any) -> None: ...
 149      # TODO: set_authorizer(authorzer_callback)
 150      # see https://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.set_authorizer
 151      # returns [SQLITE_OK, SQLITE_DENY, SQLITE_IGNORE] so perhaps int
 152      def set_authorizer(self, *args: Any, **kwargs: Any) -> None: ...
 153      # set_progress_handler(handler, n) -> see https://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.set_progress_handler
 154      def set_progress_handler(self, *args: Any, **kwargs: Any) -> None: ...
 155      def set_trace_callback(self, *args: Any, **kwargs: Any) -> None: ...
 156      # enable_load_extension and load_extension is not available on python distributions compiled
 157      # without sqlite3 loadable extension support. see footnotes https://docs.python.org/3/library/sqlite3.html#f1
 158      def enable_load_extension(self, enabled: bool) -> None: ...
 159      def load_extension(self, path: str) -> None: ...
 160      if sys.version_info >= (3, 7):
 161          def backup(
 162              self,
 163              target: Connection,
 164              *,
 165              pages: int = ...,
 166              progress: Optional[Callable[[int, int, int], object]] = ...,
 167              name: str = ...,
 168              sleep: float = ...,
 169          ) -> None: ...
 170      def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
 171      def __enter__(self) -> Connection: ...
 172      def __exit__(self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ...) -> None: ...
 173  
 174  class Cursor(Iterator[Any]):
 175      arraysize: Any
 176      connection: Any
 177      description: Any
 178      lastrowid: Any
 179      row_factory: Any
 180      rowcount: Any
 181      # TODO: Cursor class accepts exactly 1 argument
 182      # required type is sqlite3.Connection (which is imported as _Connection)
 183      # however, the name of the __init__ variable is unknown
 184      def __init__(self, *args: Any, **kwargs: Any) -> None: ...
 185      def close(self, *args: Any, **kwargs: Any) -> None: ...
 186      def execute(self, sql: str, parameters: Iterable[Any] = ...) -> Cursor: ...
 187      def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable[Any]]) -> Cursor: ...
 188      def executescript(self, sql_script: Union[bytes, Text]) -> Cursor: ...
 189      def fetchall(self) -> List[Any]: ...
 190      def fetchmany(self, size: Optional[int] = ...) -> List[Any]: ...
 191      def fetchone(self) -> Any: ...
 192      def setinputsizes(self, *args: Any, **kwargs: Any) -> None: ...
 193      def setoutputsize(self, *args: Any, **kwargs: Any) -> None: ...
 194      def __iter__(self) -> Cursor: ...
 195      if sys.version_info >= (3, 0):
 196          def __next__(self) -> Any: ...
 197      else:
 198          def next(self) -> Any: ...
 199  
 200  class DataError(DatabaseError): ...
 201  class DatabaseError(Error): ...
 202  class Error(Exception): ...
 203  class IntegrityError(DatabaseError): ...
 204  class InterfaceError(Error): ...
 205  class InternalError(DatabaseError): ...
 206  class NotSupportedError(DatabaseError): ...
 207  class OperationalError(DatabaseError): ...
 208  
 209  if sys.version_info >= (3,):
 210      OptimizedUnicode = str
 211  else:
 212      class OptimizedUnicode(object):
 213          maketrans: Any
 214          def __init__(self, *args, **kwargs): ...
 215          def capitalize(self, *args, **kwargs): ...
 216          def casefold(self, *args, **kwargs): ...
 217          def center(self, *args, **kwargs): ...
 218          def count(self, *args, **kwargs): ...
 219          def encode(self, *args, **kwargs): ...
 220          def endswith(self, *args, **kwargs): ...
 221          def expandtabs(self, *args, **kwargs): ...
 222          def find(self, *args, **kwargs): ...
 223          def format(self, *args, **kwargs): ...
 224          def format_map(self, *args, **kwargs): ...
 225          def index(self, *args, **kwargs): ...
 226          def isalnum(self, *args, **kwargs): ...
 227          def isalpha(self, *args, **kwargs): ...
 228          def isdecimal(self, *args, **kwargs): ...
 229          def isdigit(self, *args, **kwargs): ...
 230          def isidentifier(self, *args, **kwargs): ...
 231          def islower(self, *args, **kwargs): ...
 232          def isnumeric(self, *args, **kwargs): ...
 233          def isprintable(self, *args, **kwargs): ...
 234          def isspace(self, *args, **kwargs): ...
 235          def istitle(self, *args, **kwargs): ...
 236          def isupper(self, *args, **kwargs): ...
 237          def join(self, *args, **kwargs): ...
 238          def ljust(self, *args, **kwargs): ...
 239          def lower(self, *args, **kwargs): ...
 240          def lstrip(self, *args, **kwargs): ...
 241          def partition(self, *args, **kwargs): ...
 242          def replace(self, *args, **kwargs): ...
 243          def rfind(self, *args, **kwargs): ...
 244          def rindex(self, *args, **kwargs): ...
 245          def rjust(self, *args, **kwargs): ...
 246          def rpartition(self, *args, **kwargs): ...
 247          def rsplit(self, *args, **kwargs): ...
 248          def rstrip(self, *args, **kwargs): ...
 249          def split(self, *args, **kwargs): ...
 250          def splitlines(self, *args, **kwargs): ...
 251          def startswith(self, *args, **kwargs): ...
 252          def strip(self, *args, **kwargs): ...
 253          def swapcase(self, *args, **kwargs): ...
 254          def title(self, *args, **kwargs): ...
 255          def translate(self, *args, **kwargs): ...
 256          def upper(self, *args, **kwargs): ...
 257          def zfill(self, *args, **kwargs): ...
 258          def __add__(self, other): ...
 259          def __contains__(self, *args, **kwargs): ...
 260          def __eq__(self, other): ...
 261          def __format__(self, *args, **kwargs): ...
 262          def __ge__(self, other): ...
 263          def __getitem__(self, index): ...
 264          def __getnewargs__(self, *args, **kwargs): ...
 265          def __gt__(self, other): ...
 266          def __hash__(self): ...
 267          def __iter__(self): ...
 268          def __le__(self, other): ...
 269          def __len__(self, *args, **kwargs): ...
 270          def __lt__(self, other): ...
 271          def __mod__(self, other): ...
 272          def __mul__(self, other): ...
 273          def __ne__(self, other): ...
 274          def __rmod__(self, other): ...
 275          def __rmul__(self, other): ...
 276  
 277  class PrepareProtocol(object):
 278      def __init__(self, *args: Any, **kwargs: Any) -> None: ...
 279  
 280  class ProgrammingError(DatabaseError): ...
 281  
 282  class Row(object):
 283      def __init__(self, *args: Any, **kwargs: Any) -> None: ...
 284      def keys(self, *args: Any, **kwargs: Any): ...
 285      def __eq__(self, other): ...
 286      def __ge__(self, other): ...
 287      def __getitem__(self, index): ...
 288      def __gt__(self, other): ...
 289      def __hash__(self): ...
 290      def __iter__(self): ...
 291      def __le__(self, other): ...
 292      def __len__(self, *args: Any, **kwargs: Any): ...
 293      def __lt__(self, other): ...
 294      def __ne__(self, other): ...
 295  
 296  if sys.version_info < (3, 8):
 297      class Statement(object):
 298          def __init__(self, *args, **kwargs): ...
 299  
 300  class Warning(Exception): ...
 301