On 09/02/2011 03:31 AM, Michael Bayer wrote:
With SQLAlchemy you should have an ongoing transaction/session defined externally to individual operations on your mapped objects - SQLA uses the "unit of work" pattern which specifically is about grouping related persistence/query operations together. The usage you have above is still thinking in the "active record" style of things - "session per individual persistence operation" - and won't take full advantage of SQLA's way of doing things.
I can see this being useful if you need a id generated by a serial though. In places where I need something like that I use object_session(self), which seems to work well.
Wichert. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@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.