On 17 Apr 2014, at 04:43, Chip Kellam <blackroomd...@gmail.com> wrote:

> I have an application in which I primarily rely on MySQL/InnoDB and using the 
> SQLAlchemy ORM and leveraging the transaction python module.  Everything is 
> good.
> 
> My problem is that, try as I might, using code similar to the following, I 
> can't get the transaction to commit:
> 
> with transaction.manager:
>     session.execute("INSERT INTO table (c1, c2) VALUES (v1, v2)")
> 
> All I get is a rollback.  Is there a pre-defined way to do this with issuing 
> raw SQL BEGIN/END statements?

>From the zope.sqlalchemy documentation at 
>https://pypi.python.org/pypi/zope.sqlalchemy :

By default, zope.sqlalchemy puts sessions in an 'active' state when they are 
first used. ORM write operations automatically move the session into a 
'changed' state. This avoids unnecessary database commits. Sometimes it is 
necessary to interact with the database directly through SQL. It is not 
possible to guess whether such an operation is a read or a write. Therefore we 
must manually mark the session as changed when manual SQL statements write to 
the DB.

Which you do like this:

from zope.sqlalchemy import mark_changed
mark_changed(session)

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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to