开发者

Is there a way to have SQLAlchemy NOT wrap SQL writes within a BEGIN and COMMIT?

I'm using SQLAlchemy 0.开发者_JAVA技巧6.4 on the Pylons 1.0 framework. I've tried every permutation of setting autoflush and autocommit to True and False, but I've found that SQLAlchemy wants to wrap all SQL sessions or writes with a BEGIN/COMMIT. I've configured the scoped_session in models/meta.py as below:

"""SQLAlchemy Metadata and Session object"""

from sqlalchemy import MetaData

from sqlalchemy.ext.declarative import declarative_base

from sqlalchemy.orm import scoped_session, sessionmaker

__all__ = ['Base', 'Session']

# SQLAlchemy session manager. Updated by model.init_model()
Session = scoped_session(sessionmaker(autoflush=False, autocommit=True))

# The declarative Base
Base = declarative_base()

metadata = MetaData()


If your problem is the slowness of this behaviour, the solution might be to begin/end transactions in some sensible way explicitly in your application.


Does not look like it:

While many DBAPIs implement a flag called autocommit, the current SQLAlchemy behavior is such that it implements its own autocommit. This is achieved by detecting statements which represent data-changing operations, i.e. INSERT, UPDATE, DELETE, etc., and then issuing a COMMIT automatically if no transaction is in progress.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜