在用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作者去世,后面没有更新维护了
webpy在insert时currval仍没被定义,布布扣,bubuko.com
原文地址:http://my.oschina.net/yongqing/blog/290873