1 from socket import socket as _socket
2 from typing import Any, AnyStr, Generic, Mapping, Tuple, Type, TypeVar, overload
4 from .charset import charset_by_id as charset_by_id, charset_by_name as charset_by_name
5 from .constants import CLIENT as CLIENT, COMMAND as COMMAND, FIELD_TYPE as FIELD_TYPE, SERVER_STATUS as SERVER_STATUS
6 from .cursors import Cursor
7 from .util import byte2int as byte2int, int2byte as int2byte
14 _C = TypeVar("_C", bound=Cursor)
15 _C2 = TypeVar("_C2", bound=Cursor)
17 def dump_packet(data): ...
18 def pack_int24(n): ...
19 def lenenc_int(i: int) -> bytes: ...
23 def __init__(self, data, encoding): ...
24 def get_all_data(self): ...
25 def read(self, size): ...
26 def read_all(self): ...
27 def advance(self, length): ...
28 def rewind(self, position: int = ...): ...
29 def get_bytes(self, position, length: int = ...): ...
30 def read_string(self) -> bytes: ...
31 def read_uint8(self) -> Any: ...
32 def read_uint16(self) -> Any: ...
33 def read_uint24(self) -> Any: ...
34 def read_uint32(self) -> Any: ...
35 def read_uint64(self) -> Any: ...
36 def read_length_encoded_integer(self) -> int: ...
37 def read_length_coded_string(self) -> bytes: ...
38 def read_struct(self, fmt: str) -> Tuple[Any, ...]: ...
39 def is_ok_packet(self) -> bool: ...
40 def is_eof_packet(self) -> bool: ...
41 def is_auth_switch_request(self) -> bool: ...
42 def is_extra_auth_data(self) -> bool: ...
43 def is_resultset_packet(self) -> bool: ...
44 def is_load_local_packet(self) -> bool: ...
45 def is_error_packet(self) -> bool: ...
46 def check_error(self): ...
47 def raise_for_error(self) -> None: ...
50 class FieldDescriptorPacket(MysqlPacket):
51 def __init__(self, data, encoding): ...
52 def description(self): ...
53 def get_column_length(self): ...
55 class Connection(Generic[_C]):
75 max_allowed_packet: int
76 server_public_key: bytes
79 self: Connection[Cursor], # different between overloads
81 host: str | None = ...,
82 user: Any | None = ...,
84 database: Any | None = ...,
86 unix_socket: Any | None = ...,
88 sql_mode: Any | None = ...,
89 read_default_file: Any | None = ...,
91 use_unicode: bool | None = ...,
92 client_flag: int = ...,
93 cursorclass: None = ..., # different between overloads
94 init_command: Any | None = ...,
95 connect_timeout: int | None = ...,
96 ssl: Mapping[Any, Any] | None = ...,
102 ssl_verify_identity=...,
103 read_default_group: Any | None = ...,
104 compress: Any | None = ...,
105 named_pipe: Any | None = ...,
106 autocommit: bool | None = ...,
107 db: Any | None = ...,
108 passwd: Any | None = ...,
109 local_infile: Any | None = ...,
110 max_allowed_packet: int = ...,
111 defer_connect: bool | None = ...,
112 auth_plugin_map: Mapping[Any, Any] | None = ...,
113 read_timeout: float | None = ...,
114 write_timeout: float | None = ...,
115 bind_address: Any | None = ...,
116 binary_prefix: bool | None = ...,
117 program_name: Any | None = ...,
118 server_public_key: bytes | None = ...,
122 self: Connection[_C], # different between overloads
124 host: str | None = ...,
125 user: Any | None = ...,
127 database: Any | None = ...,
129 unix_socket: Any | None = ...,
131 sql_mode: Any | None = ...,
132 read_default_file: Any | None = ...,
134 use_unicode: bool | None = ...,
135 client_flag: int = ...,
136 cursorclass: Type[_C] = ..., # different between overloads
137 init_command: Any | None = ...,
138 connect_timeout: int | None = ...,
139 ssl: Mapping[Any, Any] | None = ...,
145 ssl_verify_identity=...,
146 read_default_group: Any | None = ...,
147 compress: Any | None = ...,
148 named_pipe: Any | None = ...,
149 autocommit: bool | None = ...,
150 db: Any | None = ...,
151 passwd: Any | None = ...,
152 local_infile: Any | None = ...,
153 max_allowed_packet: int = ...,
154 defer_connect: bool | None = ...,
155 auth_plugin_map: Mapping[Any, Any] | None = ...,
156 read_timeout: float | None = ...,
157 write_timeout: float | None = ...,
158 bind_address: Any | None = ...,
159 binary_prefix: bool | None = ...,
160 program_name: Any | None = ...,
161 server_public_key: bytes | None = ...,
166 def close(self) -> None: ...
168 def open(self) -> bool: ...
169 def autocommit(self, value) -> None: ...
170 def get_autocommit(self) -> bool: ...
171 def commit(self) -> None: ...
172 def begin(self) -> None: ...
173 def rollback(self) -> None: ...
174 def select_db(self, db) -> None: ...
175 def escape(self, obj, mapping: Mapping[Any, Any] | None = ...): ...
176 def literal(self, obj): ...
177 def escape_string(self, s: AnyStr) -> AnyStr: ...
179 def cursor(self, cursor: None = ...) -> _C: ...
181 def cursor(self, cursor: Type[_C2]) -> _C2: ...
182 def query(self, sql, unbuffered: bool = ...) -> int: ...
183 def next_result(self, unbuffered: bool = ...) -> int: ...
184 def affected_rows(self): ...
185 def kill(self, thread_id): ...
186 def ping(self, reconnect: bool = ...) -> None: ...
187 def set_charset(self, charset) -> None: ...
188 def connect(self, sock: _socket | None = ...) -> None: ...
189 def write_packet(self, payload) -> None: ...
190 def _read_packet(self, packet_type=...): ...
191 def insert_id(self): ...
192 def thread_id(self): ...
193 def character_set_name(self): ...
194 def get_host_info(self): ...
195 def get_proto_info(self): ...
196 def get_server_info(self): ...
197 def show_warnings(self): ...
203 OperationalError: Any
206 ProgrammingError: Any
207 NotSupportedError: Any
220 def __init__(self, connection: Connection[Any]) -> None: ...
222 def read(self) -> None: ...
223 def init_unbuffered_query(self) -> None: ...
227 connection: Connection[Any]
228 def __init__(self, filename: Any, connection: Connection[Any]) -> None: ...
229 def send_data(self) -> None: ...