@@ -322,9 +322,6 @@ def is_resultset_packet(self):
322322 field_count = ord (self ._data [0 :1 ])
323323 return 1 <= field_count <= 250
324324
325- def is_load_local_packet (self ):
326- return self ._data [0 :1 ] == b'\xfb '
327-
328325 def is_error_packet (self ):
329326 return self ._data [0 :1 ] == b'\xff '
330327
@@ -437,26 +434,6 @@ def __getattr__(self, key):
437434 return getattr (self .packet , key )
438435
439436
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-
460437
461438class Connection (object ):
462439 """
@@ -476,8 +453,7 @@ def __init__(self, host="localhost", user=None, password="",
476453 client_flag = 0 , cursorclass = Cursor , init_command = None ,
477454 connect_timeout = None , ssl = None , read_default_group = None ,
478455 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 ):
481457 """
482458 Establish a connection to the MySQL database. Accepts several
483459 arguments:
@@ -511,7 +487,6 @@ def __init__(self, host="localhost", user=None, password="",
511487 no_delay: Disable Nagle's algorithm on the socket
512488 autocommit: Autocommit mode. None means use server default. (default: False)
513489 io_loop: Tornado IOLoop
514- local_infile: Boolean to enable the use of LOAD DATA LOCAL command. (default: False)
515490
516491 db: Alias for database. (for compatibility to MySQLdb)
517492 passwd: Alias for password. (for compatibility to MySQLdb)
@@ -529,9 +504,6 @@ def __init__(self, host="localhost", user=None, password="",
529504 if compress or named_pipe :
530505 raise NotImplementedError ("compress and named_pipe arguments are not supported" )
531506
532- if local_infile :
533- client_flag |= CLIENT .LOCAL_FILES
534-
535507 if ssl and ('capath' in ssl or 'cipher' in ssl ):
536508 raise NotImplementedError ('ssl options capath and cipher are not supported' )
537509
@@ -1063,8 +1035,6 @@ def read(self):
10631035
10641036 if first_packet .is_ok_packet ():
10651037 self ._read_ok_packet (first_packet )
1066- elif first_packet .is_load_local_packet ():
1067- self ._read_load_local_packet (first_packet )
10681038 else :
10691039 yield self ._read_result_packet (first_packet )
10701040 finally :
@@ -1097,16 +1067,6 @@ def _read_ok_packet(self, first_packet):
10971067 self .message = ok_packet .message
10981068 self .has_next = ok_packet .has_next
10991069
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-
11101070 def _check_packet_is_eof (self , packet ):
11111071 if packet .is_eof_packet ():
11121072 eof_packet = EOFPacketWrapper (packet )
@@ -1212,39 +1172,4 @@ def _get_descriptions(self):
12121172 self .description = tuple (description )
12131173
12141174
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-
12501175# g:khuno_ignore='E226,E301,E701'
0 commit comments