Hello,
I'm new to SQLAlchemy and have searched high and low for a solution to my
problem so I'm hoping someone here can help. I have a query where I need to
apply the 'order by' clause dynamically (both the column and the
direction). So a 'static' version of my query would be:
studies =
On Feb 13, 2014, at 6:21 PM, Tony Garcia tnyr...@gmail.com wrote:
Hello,
I'm new to SQLAlchemy and have searched high and low for a solution to my
problem so I'm hoping someone here can help. I have a query where I need to
apply the 'order by' clause dynamically (both the column and the
Hmm.. I see what you're saying, but the column can be from any of the
tables queried from, not just the Study table. So it could be
Study.study_id, System.system_name, Site.site_id, etc. Also won't that
getattr() call just return a string? I was under the impression that you
had to pass a column
Oops -- disregard the [start:end] at the end of the query and replace that
with .all()
On Thu, Feb 13, 2014 at 7:50 PM, Tony Garcia tnyr...@gmail.com wrote:
Hmm.. I see what you're saying, but the column can be from any of the
tables queried from, not just the Study table. So it could be
Actually, now I see that your suggestion would get me the column object
(not a string), but it would still restrict me to the study table.
On Thu, Feb 13, 2014 at 7:53 PM, Tony Garcia tnyr...@gmail.com wrote:
Oops -- disregard the [start:end] at the end of the query and replace that
with
everything in python is ultimately in a namespace, the names are strings, the
values are the objects.
like if you had “myapp.model” as a module, and in that module were Study and
Site, you could say:
from myapp import model
Study = getattr(model, “Study”)
same thing.
If you want to poke
Gotcha. Thanks Michael. Once I get the code working I'll post it here. Off
to bed now, though.
Cheers,
Tony
On Thursday, February 13, 2014 8:49:14 PM UTC-5, Michael Bayer wrote:
everything in python is ultimately in a namespace, the names are strings,
the values are the objects.
like
I don't know if this is what you're thinking, but you can also just build a
query object in different ways if you want to
query = session.query(Study).options(
joinedload(Study.system),
joinedload(Study.site)).