English 中文(简体)
甲型六氯环己烷 交易不活跃,因为次交易出现倒退。
原标题:Python + SQLAlchemy problem: The transaction is inactive due to a rollback in a subtransaction

我有一个问题,即Salph +kouAlchemy。

当出现错误时(在我的案件中,由于种族状况而是一种正直错误),并出现数据库错误时,以下所有要求都产生了错误:

InvalidRequestError: The transaction is inactive due to a rollback in a subtransaction.  Issue rollback() to cancel the transaction.

虽然我可以防止出现这一最初的错误(宽限期),但我希望有一个更强有力的解决办法,但我想防止一个单一错误冲撞整个申请。

这样做的最佳方式是什么? 是否有办法指责沙捞越失败的交易?

最佳回答

最容易的事情是,在你开始在你的控制员工作时,确保你利用新的“卡勒”会议。 在项目/校准/基.py中,增加基地主计长的方法:

def __before__(self):
    model.Session.close()

会议结束,如有任何公开交易,则结束公开交易。 你希望确保每次在你在控制人工作时使用会议时都予以清除。 在控制员处理申请时,如果事先提出的申请有例外,而且等待延期,那么将保证申请始终得到批准。

问题回答

您是否在控制器中使用yoursapp.lib.base.BaseController?

You can look at Handle mysql restart in SQLAlchemy

也可在<斯特隆>巴塞尔主计长上追捕南非航空公司的例外情况,并确实进行届会的退约(英文)。

在基地主计长办公室,会议删除了。 http://www.sqlalchemy.org/docs/05/session.html#lifespan-of-a-contextual-session





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签