0

I've been trying to insert data from excel into a table I've created using sqlite3 in python. However with the current code it will only return 'none' for each value instead of the actual values from the excel spreadsheet.

row_count = sheet.max_row - 1
count1 = 2
while count1 < row_count:
    cursor.execute("INSERT INTO violations (points, serial_number, violation_code, violation_description, violation_status) VALUES (?, ?, ?, ?, ?)", (sheet.cell(row=(count1), column='A').value, sheet.cell(row=(count1), column='B').value, sheet.cell(row=(count1), column='C').value, sheet.cell(row=(count1), column='D').value, sheet.cell(row=(count1), column='E').value))
    count1 = count1 + 1

So far i think the issue comes from the way the values are connected into the sql code with all the question marks as place holders for the other values, but I'm not sure how else to do this successfully. All help is greatly appreciated thank you :)

kmurp62rulz
  • 169
  • 2
  • 9
  • Your code looks wrong. I'd suggest you put the code for the row into a separate statement so you can debug it. – Charlie Clark Oct 04 '18 at 13:27
  • @kmurp62rulz you may want to check out this question:https://stackoverflow.com/q/17439885/8062091 – Mr.Zeus Oct 04 '18 at 13:53
  • @Mr.Zeus I checked out the other question and it seems to work but through a completely different method, I want to find out what's wrong with my code because im sure its just a small error that can be corrected to make the whole thing work – kmurp62rulz Oct 04 '18 at 22:50

0 Answers0