Ha! Ha! On my previous attempts, I had something similar to this, but
instead, I had
query = db.session.query(label('sid',
distinct(a[1].c.patient_sid)))
if (n 1):
for table in join_tables[1:]:
for criterion in join_criteria[1:]:
Yeah, there's no reason to touch eval -- and a lot of reasons not to.
Security issues aside, when you make a mistake the error will be
completely unintelligible.
You can create joins dynamically very easily by just iteratively building
up on it, and using getattr() if needed.
If you're doing
eval() was definitely not doing what I expected. Thanks for the tip about
getattr(), and thanks for helping get my head screwed on right!
Greg--
On Wednesday, March 25, 2015 at 11:33:44 AM UTC-5, Jonathan Vanasco wrote:
Yeah, there's no reason to touch eval -- and a lot of reasons not to.
any reason why you're not building a query like this?
query = db.session.query(label('sid',
distinct(a[1].c.patient_sid)))
if n = 2
query = query.\
join(a[2],a[2].c.patient_sid==a[1].c.patient_sid)
if n = 3
query = query.\