Python的Oracle数据库包cx_Oracle。win7x64位,cx_Oracle-5.1.2-11g.win-amd64-py2.7。
进入Python的编辑环境
>>> import cx_Oracle
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import cx_Oracle
ImportError: DLL load failed: %1 不是有效的 Win32 应用程序。
重新下载Python 2.7.7的64位版,换掉环境变量,安装cx_Oracle-5.1.2-11g.win-amd64-py2.7,import 成功。
cx_Oracle是要调用OCI来联接Oracle数据库,11gx64 对应64python 和cx_Oracle。
Python下载 http://www.python.org/
cx_Oracle下载 http://cx-oracle.sourceforge.net/
http://sourceforge.net/projects/cx-oracle/files/5.1.2/
在环境变量中添加一个变量名字为TNS_ADMIN的变量,值为ora文件目录
cxoracle
import cx_Oracle
con = cx_Oracle.connect("duser/pswd@db")
print con.version
con.close()