首页 > 代码库 > webpy在insert时currval仍没被定义
webpy在insert时currval仍没被定义
在用webpy的db.insert()向postgres插入数据时出现
Traceback (most recent call last): File "upgrade2.0.py", line 170, in <module> copy_webservice() File "upgrade2.0.py", line 165, in copy_webservice db36.insert(‘top_node_location‘, **r) File "/usr/lib/python2.7/site-packages/web/db.py", line 777, in insert self._db_execute(db_cursor, sql_query) File "/usr/lib/python2.7/site-packages/web/db.py", line 587, in _db_execute out = cur.execute(query, params) File "/usr/lib/python2.7/site-packages/DBUtils/SteadyDB.py", line 631, in tough_method raise error # reraise the original error again psycopg2.OperationalError: 错误: 在此会话中序列 "top_node_location_id_seq" 的 currval 仍没被定义
找到/lib/python2.7/site-packages/web/db.py
def _process_insert_query(self, query, tablename, seqname): if seqname is None: # when seqname is not provided guess the seqname and make sure it exists seqname = tablename + "_id_seq" if seqname not in self._get_all_sequences(): seqname = None if seqname: # 注释掉此句 #query += "; SELECT currval(‘%s‘)" % seqname pass return query
原因是webpy在insert时,有一个额外的select使用currval获取当前序列值,但是在postgres9.3中已经不支持currval()了.
看来webpy作者去世,后面没有更新维护了
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。