1
- from _typeshed import Incomplete
1
+ from _typeshed import FileDescriptorOrPath , Incomplete
2
2
from collections .abc import Mapping
3
3
from socket import socket as _socket
4
4
from ssl import _PasswordType
5
- from typing import Any , AnyStr , Generic , TypeVar , overload
6
- from typing_extensions import Self
5
+ from typing import AnyStr , Generic , TypeVar , overload
6
+ from typing_extensions import Self , deprecated
7
7
8
8
from .charset import charset_by_id as charset_by_id , charset_by_name as charset_by_name
9
9
from .constants import CLIENT as CLIENT , COMMAND as COMMAND , FIELD_TYPE as FIELD_TYPE , SERVER_STATUS as SERVER_STATUS
10
10
from .cursors import Cursor
11
- from .util import byte2int as byte2int , int2byte as int2byte
11
+
12
+ _C = TypeVar ("_C" , bound = Cursor )
13
+ _C2 = TypeVar ("_C2" , bound = Cursor )
12
14
13
15
SSL_ENABLED : bool
14
16
DEFAULT_USER : str | None
@@ -17,68 +19,30 @@ DEFAULT_CHARSET: str
17
19
TEXT_TYPES : set [int ]
18
20
MAX_PACKET_LEN : int
19
21
20
- _C = TypeVar ("_C" , bound = Cursor )
21
- _C2 = TypeVar ("_C2" , bound = Cursor )
22
-
23
22
def dump_packet (data ): ...
24
- def pack_int24 (n ): ...
25
23
def _lenenc_int (i : int ) -> bytes : ...
26
24
27
- class MysqlPacket :
28
- connection : Any
29
- def __init__ (self , data , encoding ): ...
30
- def get_all_data (self ): ...
31
- def read (self , size ): ...
32
- def read_all (self ): ...
33
- def advance (self , length ): ...
34
- def rewind (self , position : int = 0 ): ...
35
- def get_bytes (self , position , length : int = 1 ): ...
36
- def read_string (self ) -> bytes : ...
37
- def read_uint8 (self ) -> Any : ...
38
- def read_uint16 (self ) -> Any : ...
39
- def read_uint24 (self ) -> Any : ...
40
- def read_uint32 (self ) -> Any : ...
41
- def read_uint64 (self ) -> Any : ...
42
- def read_length_encoded_integer (self ) -> int : ...
43
- def read_length_coded_string (self ) -> bytes : ...
44
- def read_struct (self , fmt : str ) -> tuple [Any , ...]: ...
45
- def is_ok_packet (self ) -> bool : ...
46
- def is_eof_packet (self ) -> bool : ...
47
- def is_auth_switch_request (self ) -> bool : ...
48
- def is_extra_auth_data (self ) -> bool : ...
49
- def is_resultset_packet (self ) -> bool : ...
50
- def is_load_local_packet (self ) -> bool : ...
51
- def is_error_packet (self ) -> bool : ...
52
- def check_error (self ): ...
53
- def raise_for_error (self ) -> None : ...
54
- def dump (self ): ...
55
-
56
- class FieldDescriptorPacket (MysqlPacket ):
57
- def __init__ (self , data , encoding ): ...
58
- def description (self ): ...
59
- def get_column_length (self ): ...
60
-
61
25
class Connection (Generic [_C ]):
62
- ssl : Any
63
- host : Any
64
- port : Any
65
- user : Any
66
- password : Any
67
- db : Any
68
- unix_socket : Any
26
+ ssl : Incomplete
27
+ host : Incomplete
28
+ port : Incomplete
29
+ user : Incomplete
30
+ password : Incomplete
31
+ db : Incomplete
32
+ unix_socket : Incomplete
69
33
charset : str
70
34
collation : str | None
71
- bind_address : Any
72
- use_unicode : Any
73
- client_flag : Any
74
- cursorclass : Any
75
- connect_timeout : Any
76
- messages : Any
77
- encoders : Any
78
- decoders : Any
79
- host_info : Any
80
- sql_mode : Any
81
- init_command : Any
35
+ bind_address : Incomplete
36
+ use_unicode : Incomplete
37
+ client_flag : Incomplete
38
+ cursorclass : Incomplete
39
+ connect_timeout : Incomplete
40
+ messages : Incomplete
41
+ encoders : Incomplete
42
+ decoders : Incomplete
43
+ host_info : Incomplete
44
+ sql_mode : Incomplete
45
+ init_command : Incomplete
82
46
max_allowed_packet : int
83
47
server_public_key : bytes
84
48
@overload
@@ -101,7 +65,7 @@ class Connection(Generic[_C]):
101
65
cursorclass : None = None , # different between overloads
102
66
init_command = None ,
103
67
connect_timeout : int | None = 10 ,
104
- ssl : Mapping [Any , Any ] | None = None ,
68
+ ssl : Mapping [Incomplete , Incomplete ] | None = None ,
105
69
ssl_ca = None ,
106
70
ssl_cert = None ,
107
71
ssl_disabled = None ,
@@ -118,7 +82,7 @@ class Connection(Generic[_C]):
118
82
local_infile : Incomplete | None = False ,
119
83
max_allowed_packet : int = 16777216 ,
120
84
defer_connect : bool | None = False ,
121
- auth_plugin_map : Mapping [Any , Any ] | None = None ,
85
+ auth_plugin_map : Mapping [Incomplete , Incomplete ] | None = None ,
122
86
read_timeout : float | None = None ,
123
87
write_timeout : float | None = None ,
124
88
bind_address = None ,
@@ -147,7 +111,7 @@ class Connection(Generic[_C]):
147
111
cursorclass : type [_C ] = ..., # different between overloads
148
112
init_command = None ,
149
113
connect_timeout : int | None = 10 ,
150
- ssl : Mapping [Any , Any ] | None = None ,
114
+ ssl : Mapping [Incomplete , Incomplete ] | None = None ,
151
115
ssl_ca = None ,
152
116
ssl_cert = None ,
153
117
ssl_disabled = None ,
@@ -163,27 +127,28 @@ class Connection(Generic[_C]):
163
127
local_infile : Incomplete | None = False ,
164
128
max_allowed_packet : int = 16777216 ,
165
129
defer_connect : bool | None = False ,
166
- auth_plugin_map : Mapping [Any , Any ] | None = None ,
130
+ auth_plugin_map : Mapping [Incomplete , Incomplete ] | None = None ,
167
131
read_timeout : float | None = None ,
168
132
write_timeout : float | None = None ,
169
133
bind_address = None ,
170
134
binary_prefix : bool | None = False ,
171
135
program_name = None ,
172
136
server_public_key : bytes | None = None ,
173
137
) -> None : ...
174
- socket : Any
175
- rfile : Any
176
- wfile : Any
138
+ socket : Incomplete
139
+ rfile : Incomplete
140
+ wfile : Incomplete
177
141
def close (self ) -> None : ...
178
142
@property
179
143
def open (self ) -> bool : ...
144
+ def __del__ (self ) -> None : ...
180
145
def autocommit (self , value ) -> None : ...
181
146
def get_autocommit (self ) -> bool : ...
182
147
def commit (self ) -> None : ...
183
148
def begin (self ) -> None : ...
184
149
def rollback (self ) -> None : ...
185
150
def select_db (self , db ) -> None : ...
186
- def escape (self , obj , mapping : Mapping [Any , Any ] | None = None ): ...
151
+ def escape (self , obj , mapping : Mapping [Incomplete , Incomplete ] | None = None ): ...
187
152
def literal (self , obj ): ...
188
153
def escape_string (self , s : AnyStr ) -> AnyStr : ...
189
154
@overload
@@ -195,7 +160,9 @@ class Connection(Generic[_C]):
195
160
def affected_rows (self ): ...
196
161
def kill (self , thread_id ): ...
197
162
def ping (self , reconnect : bool = True ) -> None : ...
198
- def set_charset (self , charset ) -> None : ...
163
+ @deprecated ("Method is deprecated. Use set_character_set() instead." )
164
+ def set_charset (self , charset : str ) -> None : ...
165
+ def set_character_set (self , charset : str , collation : str | None = None ) -> None : ...
199
166
def connect (self , sock : _socket | None = None ) -> None : ...
200
167
def write_packet (self , payload ) -> None : ...
201
168
def _read_packet (self , packet_type = ...): ...
@@ -208,35 +175,36 @@ class Connection(Generic[_C]):
208
175
def show_warnings (self ): ...
209
176
def __enter__ (self ) -> Self : ...
210
177
def __exit__ (self , * exc_info : object ) -> None : ...
211
- Warning : Any
212
- Error : Any
213
- InterfaceError : Any
214
- DatabaseError : Any
215
- DataError : Any
216
- OperationalError : Any
217
- IntegrityError : Any
218
- InternalError : Any
219
- ProgrammingError : Any
220
- NotSupportedError : Any
178
+ Warning : Incomplete
179
+ Error : Incomplete
180
+ InterfaceError : Incomplete
181
+ DatabaseError : Incomplete
182
+ DataError : Incomplete
183
+ OperationalError : Incomplete
184
+ IntegrityError : Incomplete
185
+ InternalError : Incomplete
186
+ ProgrammingError : Incomplete
187
+ NotSupportedError : Incomplete
221
188
222
189
class MySQLResult :
223
- connection : Any
224
- affected_rows : Any
225
- insert_id : Any
226
- server_status : Any
227
- warning_count : Any
228
- message : Any
229
- field_count : Any
230
- description : Any
231
- rows : Any
232
- has_next : Any
233
- def __init__ (self , connection : Connection [Any ]) -> None : ...
234
- first_packet : Any
190
+ connection : Incomplete
191
+ affected_rows : Incomplete
192
+ insert_id : Incomplete
193
+ server_status : Incomplete
194
+ warning_count : Incomplete
195
+ message : Incomplete
196
+ field_count : Incomplete
197
+ description : Incomplete
198
+ rows : Incomplete
199
+ has_next : Incomplete
200
+ def __init__ (self , connection : Connection [Incomplete ]) -> None : ...
201
+ def __del__ (self ) -> None : ...
202
+ first_packet : Incomplete
235
203
def read (self ) -> None : ...
236
204
def init_unbuffered_query (self ) -> None : ...
237
205
238
206
class LoadLocalFile :
239
- filename : Any
240
- connection : Connection [Any ]
241
- def __init__ (self , filename : Any , connection : Connection [Any ]) -> None : ...
207
+ filename : FileDescriptorOrPath
208
+ connection : Connection [Incomplete ]
209
+ def __init__ (self , filename : FileDescriptorOrPath , connection : Connection [Incomplete ]) -> None : ...
242
210
def send_data (self ) -> None : ...
0 commit comments