On Feb 6, 2013, at 03:05 , Jonathan Vanasco <jonat...@findmeon.com> wrote:
> I use SqlAlchemy in a Pyramid app. All my models, connections, etc > are within and set up by Pyramid. > > I'm trying to do a maintenance script, and am a bit confused. > > In my script, thanks to a bootstraped commandline Pyramid feature, i > have a Session which can query objects. great. > > results = dbSession.query( model.core.Useraccount )\ > .filter(\ > model.core.Useraccount.last_login.op("IS")(None) > )\ > .all() > > here's my problem. i want to do execute a command like this: > > > stmt = model.core.Useraccount.update()\ > .where( model.core.Useraccount.id.in_( list_of_uids ) )\ > .values( last_login = 'now()' ) > connection.execute(stmt) > > I'm not actually updating the last_login field. just using this as an > example. Is your problem possibly that you are not commiting your changes? Without that your transaction is aborted when your script ends. Try adding this at the end of your script: import transaction transaction.get().commit() and see if that helps. Wichert. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.