cursor.execute(“ [某些sql查询]”,t)导致语法错误

时间:2018-09-28 13:10:53

标签: sqlite

我的查询作为第一个参数传递,而我将一个元组作为第二个参数传递,而我的字符串是该元组的一个条目。

我的代码:

http-service-port

摘自文档:我遵循了https://docs.python.org/2/library/sqlite3.html

中的指南
def create_table():
    conn = sqlite3.connect('example.db')
    c = conn.cursor()
    t = ('books',)
    c.execute('CREATE TABLE IF NOT EXISTS ? (id INTEGER PRIMARY KEY, title text, author text, year integer, isbn integer)', t)
    conn.commit()
    conn.close()

0 个答案:

没有答案
相关问题