[sqlalchemy] Re: accessing fields by name

2008-06-25 Thread Werner F. Bruhin

Alex,

alex bodnaru wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1


 hello friends,

 as opposed to a table.query() that returns a list of records of that table, 
 with
 fields accessible as record attributes, a select() statement returns a list of
 tuples with the values of the fields in the virtual record.

 i'd like to access the fields by their column name or label, at least the non
 calculated or labelled ones. it would suffice to be able to retrieve a list 
 with
 the labels of the fields in the resulted tuples.

 could you point me in the right direction?
   
No expert, so take this with a grain of salt.

q = db.Quality.__table__.select()
print q
print dir(q)
print q.columns

q.columns is giving the column names as a list

Werner

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: accessing fields by name

2008-06-25 Thread az

AFAIK non-orm queries yield RowProxies, which are sort of ordered 
dicts, i.e. can be used as sequences or as dicts, keyed by 
column-name or by column-object itself.

class RowProxy(object):
Proxy a single cursor row for a parent ResultProxy.

Mostly follows ordered dictionary behavior, mapping result
values to the string-based column name, the integer position of
the result in the row, as well as Column instances which can be
mapped to the original Columns that produced this result set (for
results that correspond to constructed SQL expressions).



On Wednesday 25 June 2008 13:01:11 alex bodnaru wrote:
 hello friends,

 as opposed to a table.query() that returns a list of records of
 that table, with fields accessible as record attributes, a select()
 statement returns a list of tuples with the values of the fields in
 the virtual record.

 i'd like to access the fields by their column name or label, at
 least the non calculated or labelled ones. it would suffice to be
 able to retrieve a list with the labels of the fields in the
 resulted tuples.

 could you point me in the right direction?

 thanks in advance,
 alex

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: accessing fields by name

2008-06-25 Thread alex bodnaru

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


thanks werner, but i was asking about a generic query (not about one table)

alex

Werner F. Bruhin wrote:
| Alex,
|
| alex bodnaru wrote:
| -BEGIN PGP SIGNED MESSAGE-
| Hash: SHA1
|
|
| hello friends,
|
| as opposed to a table.query() that returns a list of records of that table, 
with
| fields accessible as record attributes, a select() statement returns a list 
of
| tuples with the values of the fields in the virtual record.
|
| i'd like to access the fields by their column name or label, at least the non
| calculated or labelled ones. it would suffice to be able to retrieve a list 
with
| the labels of the fields in the resulted tuples.
|
| could you point me in the right direction?
|
| No expert, so take this with a grain of salt.
|
| q = db.Quality.__table__.select()
| print q
| print dir(q)
| print q.columns
|
| q.columns is giving the column names as a list
|
| Werner
|
| |
|
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQCVAwUBSGIzI9pwN1sq38njAQKqoQP/VaLmQ87HFKc8At/iuMAk3PdWsJqBvOdi
HLveRI+FGZPEr/ICezW0YzVtXjTiAqPees5j/6PjMsoHeY4AEJKSTCpCBEwCQSdY
lcnyXrdg0cram1uhSItnLSyQslgQAPvAANQEv5AgJlh1garw/3O1h+yWi4kgqswO
mYAClwKrBxE=
=N3xj
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: accessing fields by name

2008-06-25 Thread alex bodnaru

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


thanks a lot,

it realy works :)

[EMAIL PROTECTED] wrote:
| AFAIK non-orm queries yield RowProxies, which are sort of ordered
| dicts, i.e. can be used as sequences or as dicts, keyed by
| column-name or by column-object itself.
|
| class RowProxy(object):
| Proxy a single cursor row for a parent ResultProxy.
|
| Mostly follows ordered dictionary behavior, mapping result
| values to the string-based column name, the integer position of
| the result in the row, as well as Column instances which can be
| mapped to the original Columns that produced this result set (for
| results that correspond to constructed SQL expressions).
| 
|
|
| On Wednesday 25 June 2008 13:01:11 alex bodnaru wrote:
| hello friends,
|
| as opposed to a table.query() that returns a list of records of
| that table, with fields accessible as record attributes, a select()
| statement returns a list of tuples with the values of the fields in
| the virtual record.
|
| i'd like to access the fields by their column name or label, at
| least the non calculated or labelled ones. it would suffice to be
| able to retrieve a list with the labels of the fields in the
| resulted tuples.
|
| could you point me in the right direction?
|
| thanks in advance,
| alex
|
| |
|
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQCVAwUBSGJC2NpwN1sq38njAQLk0gQAtG3y4MPPxVux6zFHYxaz+hpIHBHjAJkI
nuJPi+c+iAm58OSQPGZXfyXadzaoFgu+DAgLsx7MaL5bwOtjnEUsuRQ9cMgaWIWZ
b0cqJo7jXOuF39IglrEaLO3pNjl6mzkjHPkBXUO+KnybJxuCoazkwRC/moXV/kiN
e/CGoq1fMM0=
=OH0/
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---