[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: test_load_local.py
File is not writable. Editing disabled.
from pymysql import cursors, OperationalError, Warning from pymysql.tests import base import os import warnings __all__ = ["TestLoadLocal"] class TestLoadLocal(base.PyMySQLTestCase): def test_no_file(self): """Test load local infile when the file does not exist""" conn = self.connections[0] c = conn.cursor() c.execute("CREATE TABLE test_load_local (a INTEGER, b INTEGER)") try: self.assertRaises( OperationalError, c.execute, ("LOAD DATA LOCAL INFILE 'no_data.txt' INTO TABLE " "test_load_local fields terminated by ','") ) finally: c.execute("DROP TABLE test_load_local") c.close() def test_load_file(self): """Test load local infile with a valid file""" conn = self.connections[0] c = conn.cursor() c.execute("CREATE TABLE test_load_local (a INTEGER, b INTEGER)") filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data', 'load_local_data.txt') try: c.execute( ("LOAD DATA LOCAL INFILE '{0}' INTO TABLE " + "test_load_local FIELDS TERMINATED BY ','").format(filename) ) c.execute("SELECT COUNT(*) FROM test_load_local") self.assertEqual(22749, c.fetchone()[0]) finally: c.execute("DROP TABLE test_load_local") def test_unbuffered_load_file(self): """Test unbuffered load local infile with a valid file""" conn = self.connections[0] c = conn.cursor(cursors.SSCursor) c.execute("CREATE TABLE test_load_local (a INTEGER, b INTEGER)") filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data', 'load_local_data.txt') try: c.execute( ("LOAD DATA LOCAL INFILE '{0}' INTO TABLE " + "test_load_local FIELDS TERMINATED BY ','").format(filename) ) c.execute("SELECT COUNT(*) FROM test_load_local") self.assertEqual(22749, c.fetchone()[0]) finally: c.close() conn.close() conn.connect() c = conn.cursor() c.execute("DROP TABLE test_load_local") def test_load_warnings(self): """Test load local infile produces the appropriate warnings""" conn = self.connections[0] c = conn.cursor() c.execute("CREATE TABLE test_load_local (a INTEGER, b INTEGER)") filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data', 'load_local_warn_data.txt') try: with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') c.execute( ("LOAD DATA LOCAL INFILE '{0}' INTO TABLE " + "test_load_local FIELDS TERMINATED BY ','").format(filename) ) self.assertEqual(w[0].category, Warning) expected_message = "Incorrect integer value" if expected_message not in str(w[-1].message): self.fail("%r not in %r" % (expected_message, w[-1].message)) finally: c.execute("DROP TABLE test_load_local") c.close() if __name__ == "__main__": import unittest unittest.main()
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server05.hostinghome.co.in
Server IP: 192.168.74.40
PHP Version: 7.4.33
Server Software: Apache
System: Linux server05.hostinghome.co.in 3.10.0-962.3.2.lve1.5.81.el7.x86_64 #1 SMP Wed May 31 10:36:47 UTC 2023 x86_64
HDD Total: 1.95 TB
HDD Free: 691.06 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Disabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: itsweb
User ID (UID): 1619
Group ID (GID): 1621
Script Owner UID: 1619
Current Dir Owner: N/A