小编Dma*_*man的帖子

为什么使用 cx_Oracle 插入脚本挂起

我是 Python 新手,使用 cx_Oracle.execute 在表中插入一行。

我准备了insert适用于 SQL 开发人员的语句。

print执行之前的语句表明它在执行时挂起。一个简单的select语句使用相同的包。

  • Python 版本是 2.7
  • Oracle 版本是 11g
  • cx_Oracle 版本是 5.2.1
  • Eclipse 是 4.4.2
  • Pydev 是 4.5.5

我也在 Anaconda 上试过这个,结果相同。

import cx_Oracle

Connection = cx_Oracle.connect('connectioninfo')
cursor = connection.cursor()
print(cx_Oracle.__file__) 
print(cx_Oracle._version)

sql1 = "insert into date_dim(dateid) values (20170523)"
print(sql1)
cursor.execute(sql1) # hangs here 
count = cursor.rowcount 

print(count)
connection.commit() # Never gets to this statement        
cursor.close()
connection.close()
Run Code Online (Sandbox Code Playgroud)

python oracle

8
推荐指数
1
解决办法
1010
查看次数

标签 统计

oracle ×1

python ×1