Many DB API methods do a few queries to a DB (e. g. SELECT
and then UPDATE, or SELECT and then DELETE, etc). By default,
a Session instance is used with autocommit=True, which means,
that each query to a DB is done in a separate transaction. This
is error-prone (as it may lead to race conditions or returning
of unexpected results) and makes rollbacks harder (if one of
transactions fail, the previous ones can not be rolled back).
This patch ensures that all DB API methods, which do a few
queries (or call private DB API methods), are executed inside
a single transaction.