Quantcast
Channel: MySQL Forums - Connector/Python
Viewing all articles
Browse latest Browse all 384

MySQL table not updated on exetcuting LOAD DATA LOCAL statement using Python (1 reply)

$
0
0
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?

Viewing all articles
Browse latest Browse all 384

Trending Articles