java中的接口是类吗
306
2022-09-03
Python 使用 cx_Oracle 教程(python是什么意思)
cx_Oracle的使用需要调用Oracle环境,因此需要安装Oracle客户端官网地址:http://oracle.com/technetwork/database/database-technologies/instant-client/overview/index.html
Windows环境
1.下载Windows的即时客户端
官网下载:http://oracle.com/technetwork/topics/winx64soft-089540.html下载安装包:instantclient-basic-windows.x64-11.2.0.4.0 instantclient-sdk-windows.x64-11.2.0.4.0 instantclient-sqlplus-windows.x64-11.2.0.4.0
2.安装instantclient
a.解压在同一个目录下
b.配置环境变量 E:\software\instantclient_11_2
c.测试sqlplus
E:\software\instantclient_11_2>sqlplus.exe username/password@//host:port/sidSQL> select * from database."tablename";
3.安装cx_Oracle
pip install cx_Oracle==5.3报错:error: Microsoft Visual C++ 9.0 is required. Get it from 下载报错:InterfaceError: Unable to acquire Oracle environmen将oracle目录下的几个dll文件copy到python site-package目录下
4.测试cx_Oracle
>>> import cx_Oracle>>> conn = cx_Oracle.connect(username, password, host:port/sid)>>> result = conn.cursor().execute("SELECT * FROM TABLE")>>> for item in result:... print item>>> conn.close()>>> exit()
Linux环境
1.下载Linux的即时客户端
官网下载:instantclient-basic-linux.x64-11.2.0.4.0.zip -d /software/unzip instantclient-sdk-linux.x64-11.2.0.4.0.zip -d /software/unzip instantclient-sqlplus-linux.x64-11.2.0.4.0.zip -d /software/
3.配置监听文件
/software/instantclient_11_2/network/admin要自己创建,包括tnsnames.ora文件 $ORACLE_HOME/network/admin/tnsnames.ora
ORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = XXXX)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )
4.配置环境变量
# vim /etc/profile #文件尾部添加export ORACLE_HOME=/software/oracle/instantclient_12_2export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOMEexport TNS_ADMIN=$ORACLE_HOME/network/admin # 安装了sqlplus 要设置监听export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK # 设置编码集PATH = $ORACLE_HOME:...# source /etc/profile
5.设置软连接
cd /software/instantclient_11_2/ln -s libclntsh.so.11.1 libclntsh.so
6.安装cx_Oracle
pip install cx_Oracle==5.3
7.测试cx_Oracle
(venv) [root@localhost /]# python>>> import cx_Oracle>>> print cx_Oracle.version5.3>>> exit()
01
码虫甲
02
iOS逆向
03
漫步科技人生
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~