Re: [sqlalchemy] SQLAlchemy before_update called instead after_delete when I delete instance

2014-04-23 Thread uralbash
Thanks Michael, It turns out that when remove node with children, sqlalchemy by defaults first update children (set parent_id=None) and then delete node. When I set cascade=all,delete it's delete node one by one (w/o update). вторник, 22 апреля 2014 г., 20:39:21 UTC+6 пользователь Michael

Re: [sqlalchemy] Logging query in a single line

2014-04-23 Thread Jonathan Vanasco
the easiest trick i came up with for this, was to create a logging table in sqlalchemy/postgres and directly log the query into it. my table looks roughly like this: id , timestamp, request_id ( if under pyramid ), query_id (if available, guid assigned to different queries ), query, vars,

[sqlalchemy] update where using the ORM

2014-04-23 Thread Tim Kersten
I'd like to run a data migration on a live server, but only update rows if the data hasn't changed since I've read it, and would like to do so optimistically, so without locking the row. Doing so like below works and prevents me updating rows that have changed since I last read the row.

Re: [sqlalchemy] update where using the ORM

2014-04-23 Thread Michael Bayer
perhaps I'm missing something but wouldn't you just change the update() here to all(), so that you SELECT only those rows you care about into memory, then change each foo as needed and flush? I'm not seeing what the issue is. The row isn't locked if you aren't using SELECT..FOR UPDATE. On