cx_Oracle
cx_Oracle
安装
pip install cx_Oracle
只是我没用那个安装成功过。我找了rpm 包。
http://nchc.dl.sourceforge.net/project/cx-oracle/5.1.2/cx_Oracle-5.1.2-11g-py26-1.x86_64.rpm
然后直接rpm安装了你懂的。
只是你在python中运行import cx_Oracle时还会报找不到lib的错误
[root@iZ23dnwecebZ ~]# python
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libclntsh.so.11.1: cannot open shared object file: No such file or directory
事实上libclntsh.so.11.1这个是有的,用find 能够找到。
/data/oms/agent/core/12.1.0.2.0/instantclient/libclntsh.so.11.1
把这个文件夹加到/etc/ld.so.conf
[root@iZ23dnwecebZ ~]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
/data/oms/agent/core/12.1.0.2.0/instantclient
[root@iZ23dnwecebZ ~]# ldconfig
之后运行import cx_Oracle就没有问题了。
写个小的test程序去连一下oracle
import cx_Oracle
db = cx_Oracle.connect('system', 'oracle', '10.168.xx.xx:1521/xxx')
print db.version
显示出oracle的版本
[oracle@iZ23dnwecebZ ~]$ python t.py
11.2.0.4.0
使用
能够參看
http://www.oracle.com/technetwork/articles/dsl/python-091105.html
fetchone,fetchall的使用方法和mysql的python调用差点儿相同。我也仅仅是用作最简单的查询。
基本使用方法:
import cx_Oracle
con = cx_Oracle.connect('pythonhol/welcome@127.0.0.1/orcl')
cur = con.cursor()
sql='select * from departments order by department_id'
cur.execute(sql)
res = cur.fetchall()
for r in res
print r
cur.close()
con.close()
拿来做简单的查询是够了。
cx_Oracle的更多相关文章
- cx_Oracle摘记
由于想使用python操作oracle所以查看了cx_Oracle的官方文档,同时也查看了twisted中cx_Oracle的使用.下面是摘自文档中一些我认为有用的内容 cx_Oracle is a ...
- ubuntu 下安装 cx_Oracle库
1.下载3个zip包: 下载地址:http://www.oracle.com/technetwork/database/features/instant-client/index-097480.htm ...
- 使用pip安装 cx_Oracle 模块
1. 系统环境,linux, python3.5, pip以下命令的执行均使用root用户. 2. 执行 pip install cx_Oracle出错,提示不能定位Oracle的安装.出现该问题的原 ...
- python导入cx_Oracle报错的问题!
import cx_Oracle 总是报错:ImportError: DLL load failed: 找不到指定的模块. 或者:ImportError: DLL load failed: %1 不是 ...
- install cx_Oracle on Linux
step 1 : install oracle client library url: http://www.oracle.com/technetwork/topics/linuxsoft-08280 ...
- cx_Oracle 报错 Reason: image not found
(Study_env) ➜ DAL python -c "import cx_Oracle"Traceback (most recent call last): File &quo ...
- Python导入cx_Oracle报错
系统环境:RHEL5.4 python2.5(手动编译安装,系统带有2.4版本) 在使用python脚本访问数据库时,需要导入cx_Oracle模块 $>>>import cx_ ...
- Linux搭建python环境中cx_Oracle模块安装遇到的问题与解决方法
安装或使用cx_Oracle时,需要用到Oracel的链接库,如libclntsh.so.11.1,否则会有各种各样的错误信息. 安装Oracle Instant Client就可得到这个链接库,避免 ...
- Python中通过cx_oracle操作ORACLE数据库的封闭函数
哈哈,看来我的SQL自动化发布,马上就全面支持ORACLE,MYSQL,POSTGRESQL,MSSQL啦... http://blog.csdn.net/swiftshow/article/deta ...
- Python中通过cx_Oracle访问数据库遇到的问题总结
以下是Python中通过cx_Oracle操作数据库的过程中我所遇到的问题总结,感谢我们测试组的前辈朱勃给予的帮助最终解决了下列两个问题: 1)安装cx_Oracle会遇到的问题:在Windo ...
随机推荐
- @Transactional 事务注解
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.SERIALIZABLE, rollbackFor = ...
- Ubunut PPA源概述
Ubuntu 自带的“软件”应用,可以安装海量软件,既包括发行者支持的软件.社区支持的软件,也包括专有驱动和版权软件.有时,我们需要的软件通过这些渠道仍然无法找到.这时,可以到 PPA 软件源中查找. ...
- Vuejs2.0构建一个彩票查询WebAPP(3)
整个工程的目录及截图如下,源码下载 使用心得: 1.了解Vue的生命周期很有必要,详情参见博文Vue2.0 探索之路——生命周期和钩子函数的一些理解 2.Vuex全局状态管理真是美味不可言 st ...
- mescroll报错
1.Cannot read property 'insertBefore' of null:说明你的容器id未找到,应确认你的容器id名与你NEW的容器名一致:
- 什么是PV和UV?
技术角度 1个PV是指从浏览器发出一个对网络server的Request,网络server接到Request之后.会開始把该Request相应的一个Page(Page就是一个网页)发送到client的 ...
- 算法题:给你一个自然数N,求[6, N]之内的全部素数中, 两两之和为偶数的那些偶数。
/* 算法题:给你一个自然数N,求[6, N]之内的全部素数中. 两两之和为偶数的那些偶数. */ #include <iostream> using namespace std; voi ...
- 【LeetCode-面试算法经典-Java实现】【121-Best Time to Buy and Sell Stock(最佳买卖股票的时间)】
[121-Best Time to Buy and Sell Stock(最佳买卖股票的时间)] [LeetCode-面试算法经典-Java实现][全部题目文件夹索引] 原题 Say you have ...
- vue --- 解读vue的中webpack.base.config.js
const path = require('path') const utils = require('./utils')// 引入utils工具模块,具体查看我的博客关于utils的解释,utils ...
- javafx ComboBox Event and change cell color
public class EffectTest extends Application { public static void main(String[] args) { launch(args); ...
- 运动识别之HOJ3D和HMM
http://cvrc.ece.utexas.edu/Publications/Xia_HAU3D12.pdf View Invariant Human Action Recognition Us ...