I have a standalone utility using a model based on Declarative on MySQL using SQLAlchemy 0.5.2. Most of the code is at the SQL level but at one point I use the ORM to update or insert a summary record. So I figured I'd use create_session because it's a single-threaded utility.
=== sess = orm.create_session(bind=conn) q = sess.query(model.Monthly).filter_by(...) monthly = q.first() if not monthly: monthly = model.Monthly() ... sess.add(monthly) ... sess.commit() === That raises "sqlalchemy.exc.InvalidRequestError: No transaction is begun." To work around that I have to put "sess.begin()" after creating the session. But why? I don't have to do this when using scoped_session in Pylons. The SQLAlchemy docs seem to say that it automatically manages transactions if you don't change the default session arguments, and that this works identically with Session, create_session, and sessionmaker. So why is it behaving differently here? -- Mike Orr <sluggos...@gmail.com> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---