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. flowable一个简单的例子

    holiday-request.bpmn20.xml: <?xml version="1.0" encoding="UTF-8"?> <def ...

  2. dubbo+zookeeper+springMVC +maven

    pom:                    <dependency>             <groupId>com.github.sgroschupf</grou ...

  3. 初学Larevel 2014-08-21 11:24 90人阅读 评论(0) 收藏

    添加第一个路由时就遇到了 404错误,查了一下说要这样才能 版权声明:本文为博主原创文章,未经博主允许不得转载.

  4. 是时候抛弃web.xml了?

    你是否再为配置文件web.xml容易出错而烦恼?是否为web.xml文件存放位置而不知所措?是否为web.xml为什么要这样配?怎么才能更好的配置web.xml而烦恼?那么一种新的方式出现了: spr ...

  5. android的HTTP框架之Volley

    Volley是android官方开发的一个HTTP框架,简化了利用java中原生的HTTP操作API-HttpURLConnection和HttpClient的操作. 一.首先是Volley的简单使用 ...

  6. Python(九) Python的高级语法与用法

    本章节我们揭开Python进阶部分的高级特性,详细讲解枚举.闭包,并对函数式编程做出介绍 一. 枚举其实是一个类 from enum import Enum #枚举类 class VIP(Enum): ...

  7. 通过域 组策略禁用U盘(只允许部份许可U盘可在客户端读取)

    U盘禁用设置步骤: 1.客户端 注册表修改,USBStor  的start改为4 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbSto ...

  8. 【使用uWSGI和Nginx来设置Django和你的Web服务器】

    目录 安装使用uWSGI 配置Nginx结合uWSGI supervisor Django静态文件与Nginx配置 @ *** 所谓WSGI . WSGI是Web服务器网关接口,它是一个规范,描述了W ...

  9. 5G时代即将到来,有线网络WiFi会消失不见吗?

    说到WiFi大家都不陌生了,特别是智能手机出现后,WiFi发展的速度更是可以用“神速”来形容,几乎到处都有WiFi覆盖.以致于现在大家无论去到哪里,往往第一句话就是问“这里有没有WiFi?”或者“Wi ...

  10. 手动连接数据库(jdbc)

    import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import ...