我将SQLite与Python结合使用,并从SQLite教程中复制了以下简单代码:
import sqlite3
conn = sqlite3.connect('references.db')
c = conn.cursor()
c.execute('''CREATE TABLE refs
(author text, title text, year int)''')
c.execute('''INSERT INTO refs VALUES
('author1', 'title1', 2014)''')
conn.commit()
conn.close()这个效果很好。但是,每当我试图将表名设置为“引用”时:
c.execute('''CREATE TABLE refs
(author text, title text, year int)''')我知道这个错误:
line 7, in <module> (author text, title text, year int)''')
sqlite3.OperationalError: near "references": syntax error我已经检查了其他帖子,我认为不应该出现最大长度的问题。
http://www.allinterview.com/showanswers/20054.html http://www.sqlite.org/limits.html
那么这里有什么问题呢?
谢谢!
发布于 2014-09-14 19:41:57
引用是一个保留字,在表声明中使用,所以您不能在表声明中使用它是有意义的。
https://stackoverflow.com/questions/25837271
复制相似问题