Aight. But that (I assume) only works from within sqlobject. Maybe I did not explain myself right.

In some occasions, I speed up my app by executing some raw sql queries. Currently I bypass sqlobject entirely and use psycopg. I create a open a connection, create a raw cursor and do a dictfetchall so I get back a nice dict with row names as keys.

I find it nicer and easier to let the sqlobject connection pool handle all connections, also the raw sql queries. An example:

Now I do:

connection = psycopg.connect(dsn)
curs = connection.cursor()

query = """SELECT foo,SUM(foobar) AS rafoob FROM bar WHERE bar.id IN (SELECT barfoo FROM oofrap WHERE oforba<current_date+barofo) AND COALESCE(SUM(foo+MAX(foobar))) > NOW() - time (10:00) OR foraba!=fafobo"""

result = curs.dictfetchall(curs.execute(query))

print result[0]['rafoob']

I would like to do

result = SomeObject._connection.queryAll(query)

print result[0]['rafoob']

Thanks!!

On Thu, Jan 26, 2006 at 09:07:26PM +0100, Koen Bok wrote:
> I googled my ass off, but I could not find if SQLObject has an option  
> like dictfetchall in psycopg. Is there? Or is there a good trick?
> (dictfetchall returns your sql query as a dict object with the row  
> names as keys)

   row.sqlmeta.asDict()

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to