On 6/10/2010 10:29 AM, Aref wrote:
Thank you for the response. However, that is not the problem. If I doupdate = table.update(project.c.ProjectID=='project-name', values = {project.c.ProjectID:'program'}) print update update.execute() everything works fine. if I do this: test = 'table.c.'+columns[0] #columns is a list which contains the columns names update = table.update(test == 'project-name', values={test:'program'}) update.execute() it does not work. I get an error that there is no such column. I need to be able to update columns dynamically where I do not have a prior knowledge of what tables and what are the table columns that may exist. How can I do that if at all? Instead try: update = table.update(eval(test)=='project-name', values={test:'program'}) I can't say for sure that's the best way to do it still, but it would solve your immediate problem. The "test" variable is referencing a string, not a column. You have to eval() it to get the column reference. However, you say your error is that "there is no such column" ... I'd expect a much different error if my suggestion were to actually fix your problem. Anyway good luck. :) Might include your traceback next time if you still have problems. Lance -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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] help please Aref
- [sqlalchemy] Re: help please GHZ
- [sqlalchemy] Re: help please Aref
- Re: [sqlalchemy] Re: help please Lance Edgar
- [sqlalchemy] Re: help please Aref
- Re: [sqlalchemy] Re: help please Lance Edgar
- RE: [sqlalchemy] help please King Simon-NFHD78