$wget http://download.oracle.com/otn/linux/instantclient/10204/basic-10.2.0.4.0-linux-x86_64.zip
$unzip instantclient-basic-linux.x64-10.2.0.4.0.zip $cd instantclient_10_2 $cp * /usr/lib #直接放到动态库搜索路径中,不需要额外的环境配置 或 $unzip instantclient-basic-linux.x64-10.2.0.4.0.zip $cp -rf instantclient_10_2 /opt/ $vi /etc/profile export ORACLE_HOME=/opt/instantclient_10_2 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME $source /etc/profile
$wget http://downloads.sourceforge.net/project/cx-oracle/5.1.2/cx_Oracle-5.1.2-10g-py26-1.x86_64.rpm $rpm -ivh cx_Oracle-5.1.2-10g-py26-1.x86_64.rpm $ls /usr/lib/python2.6/site-packages/cx_Oracle.so #有这个文件表示安装成功,根据python的位置,也可能在其他地方,自己找一下吧
$python >>import cx_Oracle
Google的信息:There is nothing wrong with Debian. Python supports two incompatible modes of operation for Unicode, UCS2 (the default), and UCS4. Debian uses the default, Redhat uses UCS4. You need to recompile the extension for UCS-2 mode (i.e. using a Debian installation); this would fix the undefined symbol: PyUnicodeUCS4_Decode
$./configure --prefix=/usr/local/python2.6.5 --enable-shared -enable-unicode=ucs4 $make;make install
connection =cx_Oracle.connect("tp/tp@ocn_test")
#查看tns alias命令
cmd>tnsping ocn_test
TNS Ping Utility forLinux: Version 9.2.0.8.0-Production on 27-SEP-201110:47:48
Copyright (c) 1997, 2006, Oracle Corporation. Allrights reserved.
Used parameter files:
/opt/……/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION =(ADDRESS_LIST =(ADDRESS =(PROTOCOL =TCP)(HOST =10.20.36.19)(PORT =1520))) (CONNECT_DATA =(SID =ocntest)))
OK (10msec)
pwd =getpass.getpass()
connection =cx_Oracle.connect("tp",pwd,"ocn_test")
connection =cx_Oracle.connect(sys.argv[1])
connection =cx_Oracle.connect('tp','tp','10.20.36.19:1521/ocntest')
#or
connection =cx_Oracle.connect('tp/tp@10.20.36.19:1521/ocntest')
tns_name =cx_Oracle.makedsn('10.20.36.19','1521',' ocntest ')
connection =cx_Oracle.connect('tp','tp',tns_name)
connection =cx_Oracle.connect('tp/tp@ocn_test', mode=cx_Oracle.SYSDBA)
#or as SYSOPER
connection =cx_Oracle.connect('tp/tp@ocn_test', mode=cx_Oracle.SYSOPER)
TNS:listener does not currently know of service requested in connect descriptor
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有