首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

[D]psycopg2有没有dictfetchall步骤

2012-09-21 
[D]psycopg2有没有dictfetchall方法今天用了一下,提示这个type exceptions.AttributeError: psycopg2

[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……

热点排行