我想在python中使用sqlite3做一个sqlite数据库。在这里,我正在创建新的表格,其名称为table_names
,每个表格只有一个字段列。 conn.execute('CREATE TABLE {} (quote TEXT PRIMARY KEY NOT NULL);'.format(table_names[i]))
和quote
我正在从文件中读取。然而,我无法执行插入语句,下面我已经发布了所有我尝试过的和他们的错误。任何帮助将不胜感激。由于python sqlite错误
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
如果你想变'foo'在'bar'分配到的价值,你做'FOO = “酒吧”'? –
@ColonelThirtyTwo得到了错误。谢谢 – sujithvm