[Twisted-Python] DB dictionary/tuple result wrapper for woven models

Stephen C. Waterbury golux at comcast.net
Tue Oct 14 23:50:49 MDT 2003


James Y Knight wrote:
> I took dtuple.py (a wrapper that makes database results look like both a 
> tuple and a dictionary simultaneously, which I found on the web)  ...

PgResultSet already does that.
E.g.:

 >>> from pyPgSQL import PgSQL
 >>> conn = PgSQL.connect(database='pgerdb')
 >>> curs = conn.cursor()
 >>> curs.execute('select * from id_context')
 >>> res = curs.fetchall()
 >>> len(res)
6
 >>> res[0]
[None, 'IdContext', None, 'PGER', 0, 'PGER', '', '', 'admin', 'PGER', 'admin', 'PGER', <DateTime 
object for '2003-10-02 13:36:55.29' at 40429fa8>, 'admin', 'PGER', <DateTime object for '2003-10-02 
13:36:55.29' at 40443090>, 'admin', 'PGER', 'admin', 'PGER', <DateTime object for '2003-10-02 
13:36:55.29' at 404430c8>, 'admin', 'PGER', <DateTime object for '2003-10-02 13:36:55.29' at 
40443100>, None]
 >>> for k in res[0].keys():
...     print '%s : %s' % (k, res[0][k])
...
pgef_oid : None
pgef_class : IdContext
id : None
id_context : PGER
pgef_security_mask : 0
name : PGER
short_description :
long_description :
pger_owner : admin
pger_owner_context : PGER
pger_creator : admin
pger_creator_context : PGER
pger_create_datetime : 2003-10-02 13:36:55.29
pger_modifier : admin
pger_modifier_context : PGER
pger_mod_datetime : 2003-10-02 13:36:55.29
owner : admin
owner_context : PGER
creator : admin
creator_context : PGER
create_datetime : 2003-10-02 13:36:55.29
modifier : admin
modifier_context : PGER
mod_datetime : 2003-10-02 13:36:55.29
ext_name : None
 >>>





More information about the Twisted-Python mailing list