File tree 2 files changed +27
-1
lines changed 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -1319,6 +1319,10 @@ def init_unbuffered_query(self):
1319
1319
self ._read_ok_packet (first_packet )
1320
1320
self .unbuffered_active = False
1321
1321
self .connection = None
1322
+ elif first_packet .is_load_local_packet ():
1323
+ self ._read_load_local_packet (first_packet )
1324
+ self .unbuffered_active = False
1325
+ self .connection = None
1322
1326
else :
1323
1327
self .field_count = first_packet .read_length_encoded_integer ()
1324
1328
self ._get_descriptions ()
Original file line number Diff line number Diff line change 1
- from pymysql import OperationalError , Warning
1
+ from pymysql import cursors , OperationalError , Warning
2
2
from pymysql .tests import base
3
3
4
4
import os
@@ -42,6 +42,28 @@ def test_load_file(self):
42
42
finally :
43
43
c .execute ("DROP TABLE test_load_local" )
44
44
45
+ def test_unbuffered_load_file (self ):
46
+ """Test unbuffered load local infile with a valid file"""
47
+ conn = self .connections [0 ]
48
+ c = conn .cursor (cursors .SSCursor )
49
+ c .execute ("CREATE TABLE test_load_local (a INTEGER, b INTEGER)" )
50
+ filename = os .path .join (os .path .dirname (os .path .realpath (__file__ )),
51
+ 'data' ,
52
+ 'load_local_data.txt' )
53
+ try :
54
+ c .execute (
55
+ ("LOAD DATA LOCAL INFILE '{0}' INTO TABLE " +
56
+ "test_load_local FIELDS TERMINATED BY ','" ).format (filename )
57
+ )
58
+ c .execute ("SELECT COUNT(*) FROM test_load_local" )
59
+ self .assertEqual (22749 , c .fetchone ()[0 ])
60
+ finally :
61
+ c .close ()
62
+ conn .close ()
63
+ conn .connect ()
64
+ c = conn .cursor ()
65
+ c .execute ("DROP TABLE test_load_local" )
66
+
45
67
def test_load_warnings (self ):
46
68
"""Test load local infile produces the appropriate warnings"""
47
69
conn = self .connections [0 ]
You can’t perform that action at this time.
0 commit comments