【发布时间】:2016-05-25 22:22:42
【问题描述】:
我正在尝试使用 Python 和 cx_Oracle 将大量记录加载到 Oracle 数据库中。共识似乎是您应该针对行列表准备一个游标和executemany(根据this 帖子)。所以我的代码看起来像:
stmt = "INSERT INTO table (address, shape) VALUES (:1, :2)"
cursor.prepare(stmt)
rows = []
# Make huge list of rows
cursor.executemany(None, rows)
我传入的值如下所示:
['1234 MARKET ST', "SDE.ST_Geometry('POINT (0 0)', 2272)"]
问题是SDE.ST_Geometry() 数据库函数被视为文字字符串而不是被评估,所以我得到了cx_Oracle.DatabaseError: ORA-00932: inconsistent datatypes: expected SDE.ST_GEOMETRY got CHAR。
不能将数据库函数传递给带有cx_Oracle 的准备好的游标吗?
【问题讨论】:
-
这让我朝着正确的方向前进,感谢@PatrickMarchand!