小编leo*_*ovp的帖子

插入表时处理 SQLAlchemy 中的触发器

我已经使用flask-SQLAlchemy 映射了数据库中名为Proposal 的表之一,但在从应用程序插入数据库时​​遇到了问题。这是错误:

sqlalchemy.exc.ProgrammingError: (pyodbc.ProgrammingError) ('42000', "[42000]

[Microsoft][ODBC SQL Server Driver][SQL Server]The target table 'Proposal' of
the DML statement cannot have any enabled triggers if the statement contain an
OUTPUT clause without INTO clause. (334) (SQLExecDirectW); [42000] [Microsoft]
[ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared
Run Code Online (Sandbox Code Playgroud)

数据库是MSSQL类型。

SQLAlchemy生成的sql语句是

SQL: 'INSERT INTO [Proposal] (proposal_fee, contract1, contract,
proposal_disb, source, sid, value_per_hr, team_hrs, reason_for_loss,
incharge, [Country_id], [manner], [Manager_id], preparer_id,
task_id, date_received, proposal_deadline, industry_id,
proposal_currency_id, contract_currency_id, service_description_id,
business_unit_id, status_id, associated_cost) OUTPUT inserted.[ID] VALUE …
Run Code Online (Sandbox Code Playgroud)

python sqlalchemy sql-server-2008 flask-sqlalchemy

4
推荐指数
1
解决办法
5271
查看次数