Re: Dictionary

Tim Roberts <[email protected]> Thu, 22 Apr 2010 12:25:17 -0700
Newsgroups gmane.comp.python.db.psycopg.devel
Organization Providenza & Boekelheide, Inc.
Message-ID <[email protected]>
Antonio Prado wrote:
>
> [...]
> cur = conection.cur(cursor_factory=psycopg_extras.DictCursor)
> cur.execute("SELECT * FROM users")
> result = self.cursor.fetchall() <<<<<<------------- It's correct?
> result = [dict(x) for x in result]
>   

You're mixing things up here, but it may be just cut-and-paste
problems.  If you do "cur.execute", then you need "cur.fetchall()".  If
you do "self.cursor.execute", then you need "self.cursor.fetchall()". 
You need to fetch using the same object that handled the query.

-- 
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.