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 ...
随机推荐
- css3 文字溢出 换行实现方案
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Linux 终端仿真程序Putty
PuTTY是一个Telnet.SSH.rlogin.纯TCP以及串行接口连接软件.较早的版本仅支持Windows平台,现在的版本中开始支持各类Unix平台. 用linux作为桌面系统,身为工程师很多时 ...
- ArcGIS engine中Display类库 (局部刷新)
转自原文 ArcGIS engine中Display类库 (局部刷新) Display类库包括了用于显示GIS数据的对象.除了负责实际输出图像的主要显示对象(display object)外,这个类库 ...
- 新浪新闻按keyword抓取实例
import urllib2 import requests #import MySQLdb import webbrowser import string import re from Beauti ...
- I帧、P帧和B帧的特点
I帧:帧内编码帧 I帧特点: 1.它是一个全帧压缩编码帧.它将全帧图像信息进行JPEG压缩编码及传输; 2.解码时仅用I帧的数据就可重构完整图像; 3.I帧描写叙述了图像背景和运动主体的详情; 4.I ...
- hdu1856 More is better (并查集)
More is better Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 327680/102400 K (Java/Others) ...
- CentOS 开启 IPV6
编辑网卡地址:#vi /etc/sysconfig/network-scripts/ifcfg-eth0IPV6INIT=yesIPV6FORWARDING=yesIPV6ADDR=2607:9000 ...
- Scott Hanselman的问题-3
.Net程序员面试 中级篇 (回答Scott Hanselman的问题) 继<.Net 程序员面试 C# 语言篇 (回答Scott Hanselman的问题)>跟<.Net程序员 ...
- WinRAR 5.21 去弹窗 疑惑
WinRAR 突然就有弹窗广告了 ,找了个方法,重新写一下安装目录下的 rarreg.key,确实有效果但是重写的和之前的完全一样啊,至少在文本中完全一样,怎么回事. 下面附上两个文件, 1.key ...
- centos6.5 数据库的安装
mongo https://www.cnblogs.com/layezi/p/7290082.html