Thank you for the response. However, that is not the problem. If I do update = 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? On Jun 10, 7:21 am, GHZ <geraint.willi...@gmail.com> wrote: > you should access column names via lower case > > i.e. > > columns = 'projectid', 'program', 'progmanger'] > > On 10 Jun, 03:39, Aref <arefnamm...@gmail.com> wrote: > > > > > Hello All, > > > I just began learning sqlalchemy and am not quite used to it yet so > > please excuse my ignorance and which might be a trivial question to > > some of you. > > I am writing a database module and need to load a table and possibly > > modify a record in the table. I can get the connection established and > > everything works fine. The problem I am running into is that I do not > > necessarily know the column name before hand to code it in the update > > method. I want to be able to find out to send a generic column name > > which will be updated (gets the column name dynamically). > > > I tried the following: > > > columns=['ProjectID', 'Program', 'progmanger'] > > test = str('table.c.'+columns[1]) > > update = table.update(test=='project-name', values = {test:'program'}) > > print update > > update.execute() > > > I get a error when I try to run it. It does not recognize the column > > for some reason even though if I print test everything seems to be OK. > > I get 'project.c.Program' > > > Is there something I am missing here? How can I send the project and > > column name to the update method dynamically? > > > Thank you so much in advance for any help or insight you could provide.- > > Hide quoted text - > > - Show quoted text - -- 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.