import csv #import mysql.connector import pandas as pd import pymysql # Connection to the database connection = pymysql.connect(host='localhost', user='root', password='password', db='db') cursor = connection.cursor() sdata = pd.read_csv(r'/opt/data/data.csv') sdf = pd.DataFrame(sdata, columns=['Site','t_date','t_time','V_MN']) for index, row in sdf.iterrows(): #print(row['V_MIN']) cursor.execute('INSERT INTO "Site_Voltage"(v_mn) VALUES ("%s")', row['V_MN']) connection.commit()
I’m trying to insert the values of the column in my csv data file in to a table Site_Voltage with a record v_mn however I m getting the following error
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘"Site_Voltage"(v_mn) VALUES ("3.3e0")’ at line 1′)
Does any one know what I m doing wrong here ?
Source: Python-3x Questions