【问题标题】:why cx_Oracle and sqlplus give different results for the same select query为什么 cx_Oracle 和 sqlplus 对同一个选择查询给出不同的结果
【发布时间】:2011-05-04 08:26:34
【问题描述】:

通过使用 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 的旧结果?

【问题讨论】:

  • 可能与您的问题无关,但 except cx_Oracle,exc: 不应该类似于 except cx_Oracle.EXCEPTION_NAME,exc: 吗? `

标签: python sqlplus cx-oracle


【解决方案1】:

你提交了插入吗?

con.commit() #after inserts

con.autocommit = true #before inserts

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 这是答案还是评论?
    猜你喜欢
    • 2012-06-22
    • 1970-01-01
    • 1970-01-01
    • 2011-01-14
    • 2021-06-02
    • 1970-01-01
    • 1970-01-01
    • 2012-02-17
    • 2017-04-29
    相关资源
    最近更新 更多