python连接甲骨文配置

  


python

cx_Oracle-5.2.1-11g.win-amd64-py2.7.exe

http://blog.csdn.net/huzhenwei/article/details/3946308指点,去甲骨文网站下载了客户机实例,地址是

"

路径

cx_Oracle接口错误:无法获得oracle环境处理。启动PLSQL登陆打开的是刚才的tns,但登陆就报错ORA-1以为实例是客户和之前安装的32位oracle客户端冲突,ora - 12557。感觉是这个64位的客户端实例与之前装的32位oracle客户端冲突了。于是把环境变量里的ORACLE_PATH删掉,就可以登陆PLSQL了。但测试语句还是报那个错。折腾了半天,最后死马当活马医吧,尝试着把C: \ instantclient_11_2里面的dll文件都拷贝到了python的C: \ Python27 \ Lib \网站目录下,又跑了一下,居然不报错了。然后逐个删掉,最后发现oraociei11。dll删掉会报的错,而其它dll删掉重新运行都不会报错。

PLSQL登陆还是会报错,只好把环境变量ORACLE_HOME删掉了,并不影响cx_Oracle的使用。原理不太清楚,先记录下来。

# !/usr/bin/python   #=utf - 8编码   import  cx_Oracle      时间=username “smb”   时间=passwd “czty_smb”   时间=host “192.168.150.233”   时间=port “1521”   时间=sid “zsms”   dsn =, cx_Oracle.makedsn(主机,港口,sid)   时间=con  cx_Oracle.connect(用户名,密码,,dsn)   光标=,con.cursor ()   sql =, ' SELECT  smbms, prtms ,得到t_user_mobile_dz”   cursor.execute (sql)   时间=result  cursor.fetchall ()   print “总:”,+,str (cursor.rowcount)   for  row 结果:拷贝   print 行   cursor.close ()   con.close ()


python连接甲骨文配置