Re: Dictionary

Antonio Prado <antonio-m7WKv7+duuT/[email protected]> Thu, 22 Apr 2010 16:40:08 -0300
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
Em Qui, 2010-04-22 às 12:25 -0700, Tim Roberts escreveu:
> 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.
> 

Yes! Only cut-and-paste error. I'm sorry.

Antonio.



_______________________________________________
Psycopg mailing list
[email protected]
http://lists.initd.org/mailman/listinfo/psycopg