I am trying to insert stock market csv data that I downloaded from Yahoo finance into a mysql table named 'TEST' that is in a database named 'stocks' but I am getting an error code from python:
InternalError: (1292, "incorrect date value: 'Date for column 'date at row 1")
the data that I am trying to insert has hundreads of rows that look something like this:
1995-03-31,0.141150,0.141150,0.141150,0.141150,0.105375,10000
the table that i am trying to insert this data into contains the following columns:
date DATE NOT NULL PRIMARY KEY,
open DECIMAL(10,6),
high DECIMAL(10,6),
low DECIMAL(10,6),
close DECIMAL(10,6),
adj_close DECIMAL(10,6),
volume INT,
this is the python code that i have used to insert the data into the table
with open('/home/matt/Desktop/python_projects/csv_files/CH8_SG.csv',
'r') as f:
reader = csv.reader(f)
data = next(reader)
query = 'insert into TEST values (%s,%s,%s,%s,%s, %s, %s)'
query = query.format(','.split('%s' * len(data)))
cursor = connection.cursor()
cursor.execute(query, data)
for data in reader:
cursor.execute(query, data)
cursor.commit()
when i run the code pictured above I get the following error
InternalError: (1292, "incorrect date value: 'Date for column 'date at row 1")
I really think that I am close but I do not know what is going on with that error. Can anyone help me?