On Oct 18, 2008, at 10:20 AM, J Stam wrote: > >> Is there a way to do executemany() semantic updates? Suppose I > have a list > >> of employee id's and I want to do something like: > >> > >> ids = [1, 2, 3, 4, 5, 6] > >> session.execute( tbl_employees.update(tbl_employees.c.id == ids), > >> tbl_employees.c.status="you're fired" ) > > > >Just us the in_ syntax > > > >session.execute( tbl_employees.update(tbl_employees.c.id.in_(ids)), > >status="you're fired" ) > > Thanks. The actually list would have a couple thousand items, so I > think in_ would generate a huge query string.
thats the breaks with IN. On the rare occasions I've had to merge an external set of data with a relational schema, I batch the statements in groups of 500 or so. an alternative is to get your external data into another table, such as a temp table, and do an update with criterion that correlates to the other table. > I'm having a tough time understanding how to do executemany style > operations. I need to do them for insert and deleting too. a walkthrough of statement execution styles including executemany is at http://www.sqlalchemy.org/docs/05/sqlexpression.html#sql_execmany . --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
