Support nested sqlalchemy transactions

Currently the session.begin_nested() and session.commit() pattern does not work.

This allows using subtransactions. In my (limited) testing it seems to work.