Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23305

mysql.connector.errors.ProgrammingError: 1064 (42000) on python

$
0
0

My code:

cursor = cnx.cursor()xlsx = pd.read_excel('online_retail.xlsx')for index, row in xlsx.iterrows():    values = [row['Invoice'],              row['StockCode'],              row['Description'],              row['Quantity'],              row['InvoiceDate'],              row['Price'],              row['Customer ID'],              row['Country']]    INSERT_INTO = (f"INSERT INTO online_retail.registers VALUES {values[0]}, "                   f"{values[1]}, "                   f"{values[2]}, "                   f"{values[3]}, "                   f"{values[4]}, "                   f"{values[5]}, "                   f"{values[6]}, "                   f"{values[7]}")    cursor.execute(INSERT_INTO)

My database schema:

CREATE TABLE online_retail.registers (    invoice INT NOT NULL,    stock_code VARCHAR(6) NOT NULL,    description TEXT,    quantity INT ,    invoice_date DATETIME(0),    price FLOAT,    customer_ID INT,    country VARCHAR(32),    PRIMARY KEY(invoice));

Data example:Data in text

Error:mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '489434, 85048, 15CM CHRISTMAS GLASS BALL 20 LIGHTS, 12, 2009-12-01 07:45:00, 6.9' at line 1

Why i am getting this error and how can i proceed?

How can i solve this problem?


Viewing all articles
Browse latest Browse all 23305

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>