I am trying to make a sqlite database in python using sqlite3. Here i am creating new tables with names specified in table_names each having only one field column. conn.execute('CREATE TABLE {} (quote TEXT PRIMARY KEY NOT NULL);'.format(table_names[i]))
and quote i am reading from a file. However i am not able to execute insert statement and below i have posted what all i have tried and their errors. Any help will be appreciated. Thanks
conn.execute('''INSERT INTO {} (quote) VALUES ('{}')'''.format(table_names[i], quote))
Error : sqlite3.OperationalError: near "s": syntax error
conn.execute('''INSERT INTO {} (quote) VALUES ('?')'''.format(table_names[i]), (quote,))
Error : sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 0, and there are 1 supplied.
conn.execute('''INSERT INTO ? (quote) VALUES ('?')''', (table_names[i], quote))
Error : sqlite3.OperationalError: near "?": syntax error
footo the value inbar, do you dofoo = "bar"?