下面是一个简化的模式:
Runs:
- status
Run_Runs:
- parentRunId
- childRunId
我想实例化一个新的子运行并设置其父运行。对sqlite(应用程序中的设置)或外部postgres数据库执行此操作的效果与预期一样。在对Oracle数据库运行此操作时,我看到以下错误:
sqlalchemy.exc.StatementError:(exceptions.TypeError)float()参数
必须是字符串或数字[SQL:u'插入示例。“Runs\u Runs”
(“parentRunId”,“childRunId”)值(:parentRunId,:childRunId)]
参数:[{'parentRunId':4.0,'childRunId':[634.0]}]
下面是一段
mapper
gist
.
runJoinTable = tables['Runs_Runs']
runTable = tables['Runs']
saOrm.mapper(Run, runTable, version_id_col=runTable.columns.revision,
properties={
"children": saOrm.relationship(Run,
secondary=runJoinTable,
primaryjoin = runTable.c.runId == runJoinTable.c.parentRunId,
secondaryjoin = runTable.c.runId == runJoinTable.c.childRunId,
backref='parents')
})
这就是我的oracle安装程序出现错误的地方:
parentRun = session.query(Run).filter_by(runId=4).first()
childRun = Run(status='queued', parents=[parentRun])
session.add(childRun)
session.commit() # Error occurs here
我不确定原因,但Oracle连接器在插入到Runs_Runs表之前正在包装childRun in列表。
-
macOs 10.13.6
-
Python 2.7.14
-
SQLAlchemy 1.2.9
-
cx Oracle 7.0.0(libclntsh.dylib.12.1)