@@ -322,9 +322,6 @@ def is_resultset_packet(self):
322
322
field_count = ord (self ._data [0 :1 ])
323
323
return 1 <= field_count <= 250
324
324
325
- def is_load_local_packet (self ):
326
- return self ._data [0 :1 ] == b'\xfb '
327
-
328
325
def is_error_packet (self ):
329
326
return self ._data [0 :1 ] == b'\xff '
330
327
@@ -437,26 +434,6 @@ def __getattr__(self, key):
437
434
return getattr (self .packet , key )
438
435
439
436
440
- class LoadLocalPacketWrapper (object ):
441
- """
442
- Load Local Packet Wrapper. It uses an existing packet object, and wraps
443
- around it, exposing useful variables while still providing access
444
- to the original packet objects variables and methods.
445
- """
446
-
447
- def __init__ (self , from_packet ):
448
- if not from_packet .is_load_local_packet ():
449
- raise ValueError (
450
- "Cannot create '{0}' object from invalid packet type" .format (
451
- self .__class__ ))
452
-
453
- self .packet = from_packet
454
- self .filename = self .packet .get_all_data ()[1 :]
455
- if DEBUG : print ("filename=" , self .filename )
456
-
457
- def __getattr__ (self , key ):
458
- return getattr (self .packet , key )
459
-
460
437
461
438
class Connection (object ):
462
439
"""
@@ -476,8 +453,7 @@ def __init__(self, host="localhost", user=None, password="",
476
453
client_flag = 0 , cursorclass = Cursor , init_command = None ,
477
454
connect_timeout = None , ssl = None , read_default_group = None ,
478
455
compress = None , named_pipe = None , no_delay = False ,
479
- autocommit = False , db = None , passwd = None , local_infile = False ,
480
- io_loop = None ):
456
+ autocommit = False , db = None , passwd = None , io_loop = None ):
481
457
"""
482
458
Establish a connection to the MySQL database. Accepts several
483
459
arguments:
@@ -511,7 +487,6 @@ def __init__(self, host="localhost", user=None, password="",
511
487
no_delay: Disable Nagle's algorithm on the socket
512
488
autocommit: Autocommit mode. None means use server default. (default: False)
513
489
io_loop: Tornado IOLoop
514
- local_infile: Boolean to enable the use of LOAD DATA LOCAL command. (default: False)
515
490
516
491
db: Alias for database. (for compatibility to MySQLdb)
517
492
passwd: Alias for password. (for compatibility to MySQLdb)
@@ -529,9 +504,6 @@ def __init__(self, host="localhost", user=None, password="",
529
504
if compress or named_pipe :
530
505
raise NotImplementedError ("compress and named_pipe arguments are not supported" )
531
506
532
- if local_infile :
533
- client_flag |= CLIENT .LOCAL_FILES
534
-
535
507
if ssl and ('capath' in ssl or 'cipher' in ssl ):
536
508
raise NotImplementedError ('ssl options capath and cipher are not supported' )
537
509
@@ -1063,8 +1035,6 @@ def read(self):
1063
1035
1064
1036
if first_packet .is_ok_packet ():
1065
1037
self ._read_ok_packet (first_packet )
1066
- elif first_packet .is_load_local_packet ():
1067
- self ._read_load_local_packet (first_packet )
1068
1038
else :
1069
1039
yield self ._read_result_packet (first_packet )
1070
1040
finally :
@@ -1097,16 +1067,6 @@ def _read_ok_packet(self, first_packet):
1097
1067
self .message = ok_packet .message
1098
1068
self .has_next = ok_packet .has_next
1099
1069
1100
- def _read_load_local_packet (self , first_packet ):
1101
- load_packet = LoadLocalPacketWrapper (first_packet )
1102
- sender = LoadLocalFile (load_packet .filename , self .connection )
1103
- sender .send_data ()
1104
-
1105
- ok_packet = self .connection ._read_packet ()
1106
- if not ok_packet .is_ok_packet ():
1107
- raise OperationalError (2014 , "Commands Out of Sync" )
1108
- self ._read_ok_packet (ok_packet )
1109
-
1110
1070
def _check_packet_is_eof (self , packet ):
1111
1071
if packet .is_eof_packet ():
1112
1072
eof_packet = EOFPacketWrapper (packet )
@@ -1212,39 +1172,4 @@ def _get_descriptions(self):
1212
1172
self .description = tuple (description )
1213
1173
1214
1174
1215
- class LoadLocalFile (object ):
1216
- def __init__ (self , filename , connection ):
1217
- self .filename = filename
1218
- self .connection = connection
1219
-
1220
- def send_data (self ):
1221
- """Send data packets from the local file to the server"""
1222
- if not self .connection .socket :
1223
- raise InterfaceError ("(0, '')" )
1224
-
1225
- # sequence id is 2 as we already sent a query packet
1226
- seq_id = 2
1227
- try :
1228
- with open (self .filename , 'rb' ) as open_file :
1229
- chunk_size = MAX_PACKET_LEN
1230
- prelude = b""
1231
- packet = b""
1232
- packet_size = 0
1233
-
1234
- while True :
1235
- chunk = open_file .read (chunk_size )
1236
- if not chunk :
1237
- break
1238
- packet = struct .pack ('<i' , len (chunk ))[:3 ] + int2byte (seq_id )
1239
- format_str = '!{0}s' .format (len (chunk ))
1240
- packet += struct .pack (format_str , chunk )
1241
- self .connection ._write_bytes (packet )
1242
- seq_id += 1
1243
- except IOError :
1244
- raise OperationalError (1017 , "Can't find file '{0}'" .format (self .filename ))
1245
- finally :
1246
- # send the empty packet to signify we are done sending data
1247
- packet = struct .pack ('<i' , 0 )[:3 ] + int2byte (seq_id )
1248
- self .connection ._write_bytes (packet )
1249
-
1250
1175
# g:khuno_ignore='E226,E301,E701'
0 commit comments