读书人

[D]psycopg2有没有dictfetchall步骤

发布时间: 2012-09-21 15:47:26 作者: rapoo

[D]psycopg2有没有dictfetchall方法
今天用了一下,提示这个

<type 'exceptions.AttributeError'>: 'psycopg2._psycopg.cursor' object has no attribute 'dictfetchall'
args = ("'psycopg2._psycopg.cursor' object has no attribute 'dictfetchall'",)
message = "'psycopg2._psycopg.cursor' object has no attribute 'dictfetchall'"

在网上找了半天没有这方面的资料,请高手求救

---------------------
Double行动:
原帖分数:40
帖子加分:40

[解决办法]

Python code
>>> cur.execute("SELECT * FROM test;")>>> cur.fetchall()[(1, 100, "abc'def"), (2, None, 'dada'), (3, 42, 'bar')]
[解决办法]
psycopg2.extras.DictCursor

探讨

引用:

Python code
>>> cur.execute("SELECT * FROM test;")
>>> cur.fetchall()
[(1, 100, "abc'def"), (2, None, 'dada'), (3, 42, 'bar')]

Python code

>>> dict_cur = conn.cursor(cursor_f……

读书人网 >perl python

热点推荐