MySQL Forums
Forum List  »  Connector/Python

MySQL table not updated on exetcuting LOAD DATA LOCAL statement using Python
Posted by: Sardo Numpsa
Date: May 18, 2020 08:33AM

I am attempting to execute a MySQL LOAD DATA LOCAL statement using Python. Below is the statement in MySQL which works as expected, i.e. data in file.csv is populated in MyTable.

LOAD DATA LOCAL INFILE '/home/user/Downloads/file.csv'
INTO TABLE MyDB.MyTable
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'

When attempting to replicate this with the below I do not receive any errors but the table is not populated.

sql_statement = """LOAD DATA LOCAL INFILE '/home/user/Downloads/file.csv'
INTO TABLE MyDB.MyTable
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'"""

cursor.execute(sql_statement, multi=True)
connection.commit()

Anybody notice where I may be going wrong?

Options: ReplyQuote


Subject
Written By
Posted
MySQL table not updated on exetcuting LOAD DATA LOCAL statement using Python
May 18, 2020 08:33AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.