Skip to content

Commit bda803b

Browse files
committed
added sendall() fix - thanks tarek
1 parent adce57e commit bda803b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pymysql/connections.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -700,18 +700,19 @@ def _send_command(self, command, sql):
700700
if isinstance(sql, unicode):
701701
sql = sql.encode(self.charset)
702702

703-
send_data = struct.pack('<i', len(sql)+1) + int2byte(command) + sql
703+
prelude = struct.pack('<i', len(sql)+1) + int2byte(command)
704704
if len(sql) <= (MAX_PACKET_LENGTH-5):
705-
self.socket.send(send_data)
706-
if DEBUG: dump_packet(send_data)
705+
self.socket.send(prelude + sql)
706+
if DEBUG: dump_packet(prelude + sql)
707707
else:
708-
self.socket.send(send_data)
708+
self.socket.send(prelude)
709709
if DEBUG: dump_packet(send_data)
710710
while len(sql) > MAX_PACKET_LENGTH:
711-
self.socket.send(sql[:MAX_PACKET_LENGTH])
711+
self.socket.sendall(sql[:MAX_PACKET_LENGTH])
712712
if DEBUG: dump_packet(sql[:MAX_PACKET_LENGTH])
713713
sql = sql[MAX_PACKET_LENGTH:]
714-
self.socket.send(sql)
714+
if len(sql) > 0:
715+
self.socket.sendall(sql)
715716

716717
#sock = self.socket
717718
#sock.send(send_data)

0 commit comments

Comments
 (0)