python cx_Oracle 模块安装记录
2015-06-07 19:55
567 查看
max os(Linux也适用)环境:
1、 安装oracle
client:
在http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html下载需要的oracleclient,我的系统是64位,所以下的64位max的版本,要下的名称为:instantclient-basic-macos.x64-11.2.0.3.0.zip;instantclient-sdk-macos.x64-11.2.0.3.0.zip
其它的,可以根据你自己的需求决定。
解压到/opt/instantclient_11_2,并进入此目录,ln
–s libclntsh.dylib.11.1libclntsh.dylib及ln
–s libocci.dylib.11.1 libocci.dylib
创建network/admin目录,及在此目录下生成你自己的tnsnames.ora文件。
Sudo su - root
vim /etc/profile,在最后增加:
exportORACLE_HOME="/opt/instantclient_11_2"
exportDYLD_LIBRARY_PATH=$ORACLE_HOME
exportLD_LIBRARY_PATH=$ORACLE_HOME
PATH=$PATH:$ORACLE_HOME
保存。
Source /etc/profile
将instantclient-sdk-macos.x64-11.2.0.3.0.zip解压出来的.h文件全部copy到/usr/include下
2、 安装cx_oracle:
下载cx_Oracle-5.0.4.tar.gz,并解压。
Python setup.py build
Python setup.py install
在python命令行:
import cx_Oracle
con =cx_Oracle.connect(“username","password","tnsname")
cursor = con.cursor()
cursor.execute('select * from tab').fetchone()
打印出:('ACCESS_CTEST_LOG','TABLE', None),果然成功了。
中文乱码问题解决:
>>> import os
>>> os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'
1、 安装oracle
client:
在http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html下载需要的oracleclient,我的系统是64位,所以下的64位max的版本,要下的名称为:instantclient-basic-macos.x64-11.2.0.3.0.zip;instantclient-sdk-macos.x64-11.2.0.3.0.zip
其它的,可以根据你自己的需求决定。
解压到/opt/instantclient_11_2,并进入此目录,ln
–s libclntsh.dylib.11.1libclntsh.dylib及ln
–s libocci.dylib.11.1 libocci.dylib
创建network/admin目录,及在此目录下生成你自己的tnsnames.ora文件。
Sudo su - root
vim /etc/profile,在最后增加:
exportORACLE_HOME="/opt/instantclient_11_2"
exportDYLD_LIBRARY_PATH=$ORACLE_HOME
exportLD_LIBRARY_PATH=$ORACLE_HOME
PATH=$PATH:$ORACLE_HOME
保存。
Source /etc/profile
将instantclient-sdk-macos.x64-11.2.0.3.0.zip解压出来的.h文件全部copy到/usr/include下
2、 安装cx_oracle:
下载cx_Oracle-5.0.4.tar.gz,并解压。
Python setup.py build
Python setup.py install
在python命令行:
import cx_Oracle
con =cx_Oracle.connect(“username","password","tnsname")
cursor = con.cursor()
cursor.execute('select * from tab').fetchone()
打印出:('ACCESS_CTEST_LOG','TABLE', None),果然成功了。
中文乱码问题解决:
>>> import os
>>> os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'
相关文章推荐
- [转载]Oracle Merge的使用
- Oracle复习重点
- java 连接数据库(oracle)之加载驱动包
- Oracle基本概念与数据导入
- Oracle Data Pump 导出和导入数据
- oracle分页
- oracle异常
- oracle 体系结构详解
- oracle分组函数
- Java调用Oracle存储过程
- oracle的多表查询
- Oracle游标-提取记录、游标循环
- Oracle 游标 隐式游标,显示游标,游标循环,动态SELECT语句和动态游标,异常处理,自定义异常
- ORACLE集合操作函数:UNION、INTERSECT、MINUS
- Oracle 10046事件详解
- Oracle Certified Master 11g
- Oracle之constraint/index/view/sequence/grant
- Ubuntu15.04下切换openJRE7到Oracle JDK8的记录,网上其他资料不全!update-alternatives!
- oracle 多表连接 内连接 外连接
- Oracle dump函数