MCPcopy Create free account
hub / github.com/PyMySQL/PyMySQL / test_load_file

Method test_load_file

pymysql/tests/test_load_local.py:29–45  ·  view source on GitHub ↗

Test load local infile with a valid file

(self)

Source from the content-addressed store, hash-verified

27 c.close()
28
29 def test_load_file(self):
30 """Test load local infile with a valid file"""
31 conn = self.connect()
32 c = conn.cursor()
33 c.execute("CREATE TABLE test_load_local (a INTEGER, b INTEGER)")
34 filename = os.path.join(
35 os.path.dirname(os.path.realpath(__file__)), "data", "load_local_data.txt"
36 )
37 try:
38 c.execute(
39 f"LOAD DATA LOCAL INFILE '{filename}' INTO TABLE test_load_local"
40 + " FIELDS TERMINATED BY ','"
41 )
42 c.execute("SELECT COUNT(*) FROM test_load_local")
43 self.assertEqual(22749, c.fetchone()[0])
44 finally:
45 c.execute("DROP TABLE test_load_local")
46
47 def test_unbuffered_load_file(self):
48 """Test unbuffered load local infile with a valid file"""

Callers

nothing calls this directly

Calls 4

cursorMethod · 0.80
executeMethod · 0.80
connectMethod · 0.45
fetchoneMethod · 0.45

Tested by

no test coverage detected