Re: [sqlalchemy] obtaining * field when more than 1 table

2011-09-16 Thread Mike Conley
Suppose I wish to do something like:
>> Session.query(Files.original_name, MSPResponse.*
>> because MSPResponse table has so many fields, and I want to get them
>> all. How do I do this given that I am also picking field(s) from other
>> tables ? Thanks RVince
>>
>
>
Session.query(Files.original_name, MSPResponse) should work. You get result
rows with 2 items: a scalar for original_name and a MSPResponse object.
You can then process the result like this:

for row in result:
### access Files.original_name as row.original_name
### access MSPResponse as row[1]


-- 
Mike Conley

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] obtaining * field when more than 1 table

2011-09-15 Thread Wichert Akkerman

On 2011-9-15 18:58, RVince wrote:

Suppose I wish to do something like:
Session.query(Files.original_name, MSPResponse.*
because MSPResponse table has so many fields, and I want to get them
all. How do I do this given that I am also picking field(s) from other
tables ? Thanks RVince



You can use the power of python:

Session.query(Files.original_name,
  *[c.name for c in MSPResponse.__table__.c])

Wichert.

--
Wichert AkkermanIt is simple to make things.
http://www.wiggy.net/  It is hard to make things simple.

--
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] obtaining * field when more than 1 table

2011-09-15 Thread RVince
Suppose I wish to do something like:
Session.query(Files.original_name, MSPResponse.*
because MSPResponse table has so many fields, and I want to get them
all. How do I do this given that I am also picking field(s) from other
tables ? Thanks RVince

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.