[英]Sqlite3 & Python creating tables
I'm trying to use the scrapy pipeline to store its data in a sqlite3 database here is the little part that trows a OperationalError: near "Transaction": syntax error 我正在尝试使用scrapy管道将其数据存储在sqlite3数据库中,这是引发OperationalError的小部分:“ Transaction”附近:语法错误
def createResidentialTable(self):
self.cur.execute("""CREATE TABLE IF NOT EXISTS Residential
(Id INT PRIMARY KEY NOT NULL, Transaction TEXT, Location TEXT, Price REAL)""")
My debugging so far, if i remove the Transaction TEXT & Location TEXT & Price Real from the creating tables my spider runs again. 到目前为止,我的调试工作是,如果我从创建表中删除了交易文本和位置文本以及实际价格,那么我的蜘蛛程序将再次运行。 So i'm assuming there is something wrong with my listing of the tables.
所以我假设我的表列表有问题。
Have looked trough some code examples and the official sqlite3 documentation and they list it as followed : 通过一些代码示例和官方的sqlite3文档,他们列出了以下内容:
c.execute('''CREATE TABLE stocks
(date text, trans text, symbol text, qty real, price real)''')
Any thoughts or suggestions? 有什么想法或建议吗?
Transaction
is a reserved keyword which you are not allowed to use as an identifier. Transaction
是保留的关键字 ,您不能将其用作标识符。 Just use something other than Transaction
as an identifier. 只需使用
Transaction
以外的其他内容作为标识符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.