As long as we're on the topic of dynamic creation of where clauses ... maybe
this is helpful?
I have been working on a script that involves the creation of a table based
on a dynamic set of requirements and got it to work using eval(). This
probably isn't best-practice, but hey ... it makes me my tables from a set
of requirements gathered based on a list of fields with some details about
the fields (the max string length, whether it is unique or null):
rollingfields = "Table('%s', meta" % (filename)
for row in self.fields:
rollingfields = rollingfields + ",
Column('"+row['fieldname']+"', String("+str(row['fieldlength'])+")"
if row['unique'] == True:
rollingfields = rollingfields + ", unique=True"
if row['notnull'] == True:
rollingfields = rollingfields + ", nullable=False"
rollingfields = rollingfields + ")"
rollingfields = rollingfields + ")"
eval(rollingfields)
meta.create_all(execengine)
-----
Luke Peterson
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---