与execute一起使用时,INSERT在cx_oracle中不起作用。如何使其运作? [英] INSERT not working in cx_oracle when used with execute. How to get it working?

查看:393
本文介绍了与execute一起使用时,INSERT在cx_oracle中不起作用。如何使其运作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am new to cx_oracle. I have established a connection and I am able to create and drop a table using execute.

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

Where I am failing is when I try to use "INSERT INTO ..." in execute. It doesn't show any error but it doesn't store any value either (I confirmed this by checking if the entry had taken place using sqlplus from shell). The code I used was:

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

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

请帮助我,任何帮助将不胜感激。

Please help me, any help would be appreciated.

预先感谢。
J

Thanks in advance. J

推荐答案

cursor.commit 如何工作? Cursor中的方法没有提交,连接具有此方法,因此应为:

How can cursor.commit work when the methods in Cursor do not have commit, connections has this method and hence it should be:

    connection.commit()

使用 cursor.commit()返回:

AttributeError:'cx_Oracle.Cursor'对象没有属性'commit'

这篇关于与execute一起使用时,INSERT在cx_oracle中不起作用。如何使其运作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆