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的更多相关文章

  1. cx_Oracle摘记

    由于想使用python操作oracle所以查看了cx_Oracle的官方文档,同时也查看了twisted中cx_Oracle的使用.下面是摘自文档中一些我认为有用的内容 cx_Oracle is a ...

  2. ubuntu 下安装 cx_Oracle库

    1.下载3个zip包: 下载地址:http://www.oracle.com/technetwork/database/features/instant-client/index-097480.htm ...

  3. 使用pip安装 cx_Oracle 模块

    1. 系统环境,linux, python3.5, pip以下命令的执行均使用root用户. 2. 执行 pip install cx_Oracle出错,提示不能定位Oracle的安装.出现该问题的原 ...

  4. python导入cx_Oracle报错的问题!

    import cx_Oracle 总是报错:ImportError: DLL load failed: 找不到指定的模块. 或者:ImportError: DLL load failed: %1 不是 ...

  5. install cx_Oracle on Linux

    step 1 : install oracle client library url: http://www.oracle.com/technetwork/topics/linuxsoft-08280 ...

  6. cx_Oracle 报错 Reason: image not found

    (Study_env) ➜ DAL python -c "import cx_Oracle"Traceback (most recent call last): File &quo ...

  7. Python导入cx_Oracle报错

    系统环境:RHEL5.4   python2.5(手动编译安装,系统带有2.4版本) 在使用python脚本访问数据库时,需要导入cx_Oracle模块 $>>>import cx_ ...

  8. Linux搭建python环境中cx_Oracle模块安装遇到的问题与解决方法

    安装或使用cx_Oracle时,需要用到Oracel的链接库,如libclntsh.so.11.1,否则会有各种各样的错误信息. 安装Oracle Instant Client就可得到这个链接库,避免 ...

  9. Python中通过cx_oracle操作ORACLE数据库的封闭函数

    哈哈,看来我的SQL自动化发布,马上就全面支持ORACLE,MYSQL,POSTGRESQL,MSSQL啦... http://blog.csdn.net/swiftshow/article/deta ...

  10. Python中通过cx_Oracle访问数据库遇到的问题总结

    以下是Python中通过cx_Oracle操作数据库的过程中我所遇到的问题总结,感谢我们测试组的前辈朱勃给予的帮助最终解决了下列两个问题:     1)安装cx_Oracle会遇到的问题:在Windo ...

随机推荐

  1. django 笔记3

    FBV function base view url.py index -> 函数名 view.py def 函数(requset): ... CBV class base view /inde ...

  2. shell的结构化命令

    shell在逻辑流程控制这里会根据设置的变量值的条件或其他命令的结果跳过一些命令或者循环执行的这些命令.这些命令通常称为结构化命令 1.if-then语句介绍 基本格式 if command then ...

  3. shell中IF的用法介绍

    一.语法结构 if [ condition ] then      statements  [elif condition      then statements. ..]  [else       ...

  4. Python excel 功能扩展库 ——> openpyxl 的基本使用

    说明:本文档内容参考自 https://www.cnblogs.com/zeke-python-road/p/8986318.html (作者:关关雎鸠`)的文档 from openpyxl impo ...

  5. 关于idea开发工具常用的快捷键

    自动补全缺失的import    alt+enter 自动优化import ctrl+alt+o 自动补全返回代码:IDEA的ctrl+alt+v ,eclipse的CTRL+F1 main    p ...

  6. vim 插件之commentary

    下载地址 http://www.vim.org/scripts/script.php?script_id=3695 如果是使用vundle来管理这个插件的话,你可以添加如下配置 tpope/vim-c ...

  7. html5页面怎么播放音频和视频

    html5页面怎么播放音频和视频 一.总结 一句话总结:html5 音频和视频标签:(audio And video),局限是不同浏览器对音频视频的格式支持很让人头痛 1.最基础的音频和视频标签的使用 ...

  8. git 回滚到任意版本

    git回滚到任意版本 1.先显示提交的log $ git log -3 commit 4dc08bb8996a6ee02f Author: Mark <xxx@xx.com> Date: ...

  9. pipPython运维日记

    一 Python 工作环境管理 1.1 使用 pyenv 管理不同的Python 版本 克隆项目安装 git clone https://github.com/yyuu/pyenv.git ~/.py ...

  10. Android自定义组件系列【13】——Android自定义对话框如此简单

    在我们的日常项目中很多地方会用到对话框,但是Android系统为我们提供的对话框样子和我们精心设计的界面很不协调,在这种情况下我们想很自由的定义对话框,或者有的时候我们的对话框是一个图片,没有标题和按 ...