When I tried to execute LOAD DATA with pymysql as shown below
python
def load_data(file_path):
with conn.cursor() as cursor:
sql = """
LOAD DATA LOCAL INFILE '{}'
INTO TABLE Sample
CHARACTER SET utf8
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES
""".format(file_path)
cursor.execute(sql)
I got the following error and could not import.
pymysql.err.InternalError: (1148, 'The used command is not allowed with this MySQL version')
It was solved by specifying local_infile = True
at the time of connect.
python
pymysql.connect(
:
local_infile=True
)
Recommended Posts