0

通过使用 Python 和 cx_Oracle,我正在尝试向表中插入行。

con = cx_Oracle.connect(ORACLE_USER+'/'+PASS+'@'+TNS)
cursor = con.cursor()
...
try:
    cursor.executemany("INSERT INTO table(ID,NAME) VALUES(...)"
except cx_Oracle,exc:
    error ,=exc.args
    print error.code
    print error.message
cursor.close()
con.close()

从输入文件中插入所有行后,通过使用 cx_Oracle 中的选择查询,我可以看到插入的行。但是,当我输入“select * from table;”时,sqlplus 没有给出任何结果。我是否错过了 cx_Oracle 的某些内容,或者 oracle 客户端中是否有一个缓冲区在连接到远程数据库时显示 sqlplus 的旧结果?

4

2 回答 2

4

你提交了你的插入吗?

con.commit() #after inserts

或者

con.autocommit = true #before inserts
于 2011-05-04T08:33:05.073 回答
0

我有一个倒置的问题:我使用 sqlquery 添加了行,经过 2 小时的痛苦阅读这篇文章并猜测,我应该关闭我的会话。我关闭了控制台并设法获取了我的数据!

于 2012-02-28T13:58:48.283 回答