Mysql能够插入到qestion表但是插入不到answer 表
来源:6-21 保存数据到mysql中 -3
慕Lynn
2018-03-23
我想问 就是items.py中的question 和 answer 后面都是def get_insert_sql(self)
,返回的都是return insert_sql,params,那么pipeline 的
def do_insert(self,cursor,item):
insert_sql,params=item. get_insert_sql()
cursor.execute(insert_sql,params)
这里面的item.get_insert_sql()是question中的def get_insert_sql(self)还是answer中的def get_insert_sql(self)?
我在debug的时候mysql表只能插入question部分的表内容不能够插入answer 部分的表
同时在failure中显示的是<class 'tuple'>: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')\n ON DUPLICATE KEY UPDATE content=VALUES(content),topics=VAL' at line 2")
我想知道具体的错误是什么呢
然后在后面显示的错误是AttributeError: 'dict' object has no attribute 'cursor'
Traceback: <class '_mysql_exceptions.ProgrammingError'>: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 2")
1回答
-
bobby
2018-03-26
AttributeError: 'dict' object has no attribute 'cursor' 你截图我看看你的插入mysql的代码呢
00
相似问题