0

I am trying to create an SQL database table and insert some data ("mask_id" below). I am receiving the error sqlite3.OperationalError near ")": syntax error that is referring to the last line (row['MASKID'],)). Specifically, I am trying to read a CSV file and insert data from the 'MASKID' column into my database.

I am unable to troubleshoot and would appreciate some help.

cur.execute('''CREATE TABLE IF NOT EXISTS subj_list (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, mask_id TEXT)''')

with open('/Users/Leo/Desktop/bp.csv', 'rU') as bp_csv:
    bp_reader = csv.DictReader(bp_csv)
    count = 0
    for row in bp_reader:
        cur.execute('INSERT OR IGNORE INTO subj_list (mask_id,) VALUES (?,)' (row['MASKID'],))
1
  • 1
    cur.execute('INSERT OR IGNORE INTO subj_list (mask_id) VALUES (?)' , (row['MASKID'],)) Commented Feb 8, 2017 at 3:47

1 Answer 1

1

It looks like you are missing a comma:

cur.execute('INSERT OR IGNORE INTO subj_list (mask_id) VALUES (?)',
     (row['MASKID'],))
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.