我是 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/