Could you tell me what I am doing wrong in the code?
I've tried to search for this particular case and could not find the answer. I've also tried to use example from the official docs on sqlite3
, but couldn't get it to work. Basically, I have a lot of data in inc_data
that I need to insert into sqlite3.
import sqlite3
inc_data = [[u'Period Ending', u'Dec 31, 2012', u'Dec 31, 2011', u'Dec 31, 2010'],
[u'Total Revenue\n', u'104,507,000\n', u'106,916,000\n', u'99,870,000\n'],
]
conn = sqlite3.connect("inc_data.db")
c = conn.cursor()
c.execute('''DROP TABLE inc_table''')
c.execute('''CREATE TABLE inc_table
(item text, value1 text, value2 text, value3 text)''')
c.execute('INSERT INTO inc_table VALUES (?,?,?,?)', inc_data)
conn.commit()
conn.close()
The error msg:
c.execute('INSERT INTO inc_table VALUES (?,?,?,?)', inc_data)
sqlite3.OperationalError: no such table: inc_table
many thanks for your help.