SQLwith python操作错误(sqlite)

SQLwith python操作错误(sqlite),python,sql,sqlite,Python,Sql,Sqlite,我正在使用SQLite构建一个简单的数据库。插入函数有问题。它不断表明: import sqlite3 conn = sqlite3.connect('MyIndex.db') c = conn.cursor() def insert(t, f, d): with conn: c.execute("INSERT INTO Index VALUES (:t, :frequency, :docID)", {'t': t, 'f': f, 'd': d}) inser

我正在使用SQLite构建一个简单的数据库。插入函数有问题。它不断表明:

import sqlite3

conn = sqlite3.connect('MyIndex.db')

c = conn.cursor()

def insert(t, f, d):
    with conn:
        c.execute("INSERT INTO Index VALUES (:t, :frequency, :docID)", {'t': t, 'f': f, 'd': d})


insert('apple', 1, '1/2')

conn.close()
但是我没有在我的代码中找到任何语法错误。有人能告诉我怎么修吗?提前谢谢

“索引”是SQL中的保留字

sqlite3.OperationalError: near "Index": syntax error

尝试将索引放在单引号中,如下所示:

INSERT INTO `Index` VALUES ...
索引是一个保留关键字

c.execute("INSERT INTO 'Index' VALUES (:token, :frequency, :docID)", {'token': token, 'frequency': frequency, 'docID': docID})