python - 与 execute 一起使用时,INSERT 在 cx_oracle 中不起作用。如何让它工作?

标签 python cx-oracle oracle11gr2

我是 cx_oracle 的新手。我已经建立了一个连接,并且能够使用 execute 创建和删除一个表。

我失败的地方是当我尝试在执行中使用“INSERT INTO ...”时。它没有显示任何错误,但也没有存储任何值(我通过检查是否使用 shell 中的 sqlplus 进行了输入来确认这一点)。我使用的代码是:

table_name = "T1"
column = "D"
insert_value = "test value"

sqlcode = "INSERT INTO "+table_name+" ("+column+") VALUES ('"+insert_value+"')"
cursor.execute(sqlcode)

请帮助我,我们将不胜感激。

提前致谢。 J

最佳答案

当 Cursor 中的方法没有提交时,cursor.commit 如何工作,连接有这个方法,因此它应该是:

    connection.commit()

使用 cursor.commit() 返回:
AttributeError: 'cx_Oracle.Cursor' 对象没有属性 'commit'

关于python - 与 execute 一起使用时,INSERT 在 cx_oracle 中不起作用。如何让它工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5642708/

相关文章:

oracle - Hibernate 2.1.7 可以与 Oracle Database 11gR2 一起使用吗?

oracle - RESULT_CACHE为空的RELIES_ON

python - AttributeError : module 'scipy.misc' has no attribute 'imread'

python - Numpy 多维数组索引交换轴顺序

python - 无法使用来自 Docker 容器的 SSH 隧道连接到远程数据库

python - 如何在python中使用SCAN连接到Oracle-RAC?

sql - 在 Oracle 中返回正则表达式的所有匹配项

python - 配置 Pycharm 以运行 Pyinstaller

python - 有没有办法用 qpython 进行 ssh ?

python - cx_Oracle 错误。 DPI-1047 : Cannot locate a 64-bit Oracle Client library