I am attempting to load csv files into a table in a database using python.
csv_data = csv.reader(file('ppi.csv'))
for row in csv_data:
cursor.execute('INSERT INTO ADKnowledgeBase.PPI(a,b) VALUES("row[0]","row[1]");')
Whenever I run this, I get a warning stating Incorrect Integer Value and inserts 0's into my table.
When I print row I get [int0,int1] and they are ints so it's pushing in the ints and not null values.
I've attempted to remove the quotes around "row[0]" and "row[1] and instead use VALUES(row[0],row[1]); but that just gives me a syntax error. I've also attempted using "%d" and %d
My table was made using:
CREATE TABLE IF NOT EXISTS ADKnowledgeBase.PPI(a int, b int);
"row[0]"is not any integer I've heard of. (Hint: Use placeholder values)cursor.execute('INSERT INTO ADKnowledgeBase.PPI(a,b) VALUES("%d","%d");',(row[0],row[1]))and my error is something likeWarning: Incorrect integer value: ''19217'' for column 'a' at row 1I have also tried changing the datatype to a varchar in my table and instead of %d to do %s and I still have the issuecursor.close