0

I am getting the error 'sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 4, and there are 1 supplied.' The below code should be making a database and creating a table with the the titles listed below. Then take values from a csv. file and add it under the allotted headings. Any help would be would be appreciated!

import const 
import sqlite3 


SEP = ','

DATA_FILENAME = 'pokemon.csv'
con = sqlite3.connect('poki.db')
cur = con.cursor()


cur.execute('DROP TABLE IF EXISTS poki')
cur.execute( ' CREATE TABLE  poki( pokemon TEXT, species_id INTEGER,'
             ' height REAL, weight REAL)' )

values = ('INSERT INTO poki VALUES (?, ?, ?, ?)')

for line in DATA_FILENAME:
    list_of_values = line.strip().split(SEP)
    cur.execute(values, list_of_values)

cur.close()
con.commit()
con.close()
martineau
  • 119,623
  • 25
  • 170
  • 301
  • Seems the `'pokemon.csv` doesn't contain exactly four values per line. – Michael Butscher Nov 18 '18 at 21:50
  • While it might be obvious where the error comes from in this case, please include the full error and stack trace with your questions as it makes it much easier for others to help. – SuperShoot Nov 18 '18 at 21:54
  • Hey, i have about 20 values in pokemon.csv but only need those 4 from the header, how can this bee accomplished? – Meliodus123 Nov 18 '18 at 21:55
  • Have you seen this question? https://stackoverflow.com/questions/16503560/read-specific-columns-from-a-csv-file-with-csv-module – SuperShoot Nov 18 '18 at 22:53

0 Answers0