windows下Python连接Oracle
2016-08-31 16:36
537 查看
安装出错:
distutils.errors.DistutilsSetupError: cannot locate Oracle include files in
或者运行出错:
cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle
均可参考该文章
环境:
windows10(同样适用于windows7,8),python2.7
1.下载cx_Oracle
在windows下不要使用easy_install或者pip,因为这样安装不会同步环境,并报错:
distutils.errors.DistutilsSetupError: cannot locate Oracle include files in...
因此下载.exe文件安装
https://pypi.python.org/pypi/cx_Oracle 下载cx_Oracle-5.2.1-12c.win-amd64-py2.7.exe (md5)
2.下载Oracle Instant Client
去http://www.oracle.com/technetwork/topics/winx64soft-089540.html下载 instantclient-basic-windows.x64-12.1.0.2.0.zip
下载后解压到某一路径,并将该路径添加到系统的环境变量,命名为ORACLE_HOME,将ORACLE_HOME添加到path下,否则会报错
cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle
3.Python下测试
输出正确
注意:不需要再本机上安装Oracle,也不需要新建NETWORK/ADMIN目录添加tnsnames.ora文件,更不要把oci.dll移到site-packages
distutils.errors.DistutilsSetupError: cannot locate Oracle include files in
或者运行出错:
cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle
均可参考该文章
环境:
windows10(同样适用于windows7,8),python2.7
1.下载cx_Oracle
在windows下不要使用easy_install或者pip,因为这样安装不会同步环境,并报错:
distutils.errors.DistutilsSetupError: cannot locate Oracle include files in...
因此下载.exe文件安装
https://pypi.python.org/pypi/cx_Oracle 下载cx_Oracle-5.2.1-12c.win-amd64-py2.7.exe (md5)
2.下载Oracle Instant Client
去http://www.oracle.com/technetwork/topics/winx64soft-089540.html下载 instantclient-basic-windows.x64-12.1.0.2.0.zip
下载后解压到某一路径,并将该路径添加到系统的环境变量,命名为ORACLE_HOME,将ORACLE_HOME添加到path下,否则会报错
cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle
3.Python下测试
import cx_Oracle dsn=cx_Oracle.makedsn("192.168.0.233", 1521, "TONGJI") conn=cx_Oracle.connect("SAS","Tongji123",dsn) curs=conn.cursor() sql='select * from CASE_INFO where rownum<10' rr=curs.execute (sql) row=curs.fetchone() print row[0] curs.close() conn.close()
输出正确
注意:不需要再本机上安装Oracle,也不需要新建NETWORK/ADMIN目录添加tnsnames.ora文件,更不要把oci.dll移到site-packages
相关文章推荐
- windows下python连接oracle
- Windows下python连接、操作oracle数据库(cx_Oracle)
- Jsp 连接 mySQL、Oracle 数据库备忘(Windows平台) 选择自 dazern 的 Blog
- 浅谈Windows下 PHP4.0与oracle 8的连接设置
- python之oracle连接 cx_Oracle
- Windows 2008 x64的Oracle连接
- Windows下,关于Oracle新建数据库之后,无法通过 / as sysdba 连接到orcl 问题
- Jsp 连接 mySQL、Oracle 数据库备忘(Windows平台)
- python 连接oracle
- windows PLSQL 连接 linux oracle 10g
- windows不能在本地计算机启动dbconsole//Environment variable ORACLE_SID not defined. Please define it错误//启动OEM时--选择连接到Management Server 后,在O
- Windows下PHP4.0与Oracle8的连接设置
- 浅谈Windows下 PHP4.0与oracle 8的连接设置
- oracle 10g安装在windows 2003 32位操作系统,连接数到120个就不能连接,报ora12518
- 在Windows NT IIS环境中 php连接oracle配置的一些步骤的总结
- python3 用ceODBC 在windows下连接mysql
- Jsp 连接 mySQL、Oracle 数据库备忘(Windows平台)
- Windows 2003上Oracle通过端口映射访问连接超时的解决办法
- Windows 2008 x64的Oracle连接
- windows下安装oracle,sqlplus连接启动oracle(oracle 主机字符串输入是什么)