# python连接oracle数据## 介绍------------------------------ python 连接oracle数据库,可以使用cx_oracle模块- 使用如下命令安装```python -m pip install cx_oracle --pre```## 连接oracle代码-----------------------------```pythonimport cx_oracle# 设置 dsn = cx_oracle.makedsn("192.168.0.233", 1521, "tongji")# 连接conn = cx_oracle.connect("sas","tongji123",dsn)curs = conn.cursor()sql = ‘select * from case_...
1.下载oracle包,安装下载地址:http://cx-oracle.sourceforge.net/ 下载rpm包cx_Oracle-5.2.1-11g-py27-1.x86_64.rpm进入root账户,执行sudo rpm -ivh cx_Oracle-5.2.1-11g-py27-1.x86_64.rpm2.安装oracle client包http://www.oracle.com/technetwork/topics/linuxsoft-082809.htmloracle-instantclient12.1-basic-12.1.0.2.0-1.i386.rpmoracle-instantclient12.1-devel-12.1.0.2.0-1.i386.rpmoracle-instantclient12.1-sqlplus-12...
使用python连接oracle数据库;1.安装python3.0;2.安装cx_Oracle模块;3.安装ORACLE_CLIENT ;(ORACLE_CLIENT和python位数保持一致;要么都安装32位要么都用64位)
导入连接oracle的模块
import cx_Oracle
#获取连接
username=用户名
pass=密码
ipadd=数据库地址
sid=数据库实例
conn=cx_Oracle.connect(‘username/pass@ipadd/sid‘)
c=conn.cursor()
sql="sql语句"
#执行sql
x=c.execute(sql)
#得到结果列表
relist = c.fetchal...
前提条件:本地已经安装好oracle单实例,能使用plsql developer连接,或者能使用TNS连接串远程连接到oracle集群读取excel写入数据库的方式有多种,这里介绍的是使用pandas写入,相对来说比较简便,不需要在读取excel后再去整理数据(免费学习推荐:python视频教程)整个过程需要分两步进行:一、配置python连接oracle并测试成功网上有不少教程,但大部分都没那么详细,并且也没有说明连接单实例和连接集群的区别,这里先介绍连接or...
1.首先安装cx_Oracle包2.解压instantclient-basic-windows.x64-11.2.0.4.0.zip到c:\oracle3.拷贝instantclient_11_2下所有.dll文件到c:\python34\Lib\site-packages\下(根据自己的python版本拷贝到相应的site-packages文件夹下)python连接示例代码:# -*- coding: utf-8 -*-import cx_Oracleconn=cx_Oracle.connect(reporter,password,localhost:1521/ORCL)
cursor=conn.cursor()
sql="select * from test"cursor.execute(sql)
d...
#!/usr/bin/env python
import time
start = time.clock()import cx_Oracle
tns = cx_Oracle.makedsn(127.0.0.1, 1534, dsn)
db = cx_Oracle.connect(username, password, tns)
def sqlSelect(sql, db):cur=db.cursor()cur.execute(sql)result=cur.fetchall()cur.close()return resultsql_1 = " "
sql_2 = " "
sql_3 = " "sql_list = [sql_1, sql_2, sql_3]
for sql in sql_list:result = sqlSelect(sql, db)print(result[0][0])en...
本文实例讲述了python连接oracle数据库的方法,分享给大家供大家参考。具体步骤如下:
一、首先下载驱动:(cx_Oracle)
http://www.python.net/crew/atuining/cx_Oracle/
不过要注意一下版本,根据你的情况加以选择。
二、安装:
首先配置oracle_home环境变量
执行那个exe安装程序就可以了,它会copy一个cx_Oracle.pyd到Libsite-packages目录下。
如果是linux,执行代码如下:python setup.py build
python setup.py install
三、执...
1.下载oracle包,安装
下载地址:http://cx-oracle.sourceforge.net/
下载rpm包cx_Oracle-5.2.1-11g-py27-1.x86_64.rpm
进入root账户,执行
sudo rpm -ivh cx_Oracle-5.2.1-11g-py27-1.x86_64.rpm
2.安装oracle client包
http://www.oracle.com/technetwork/topics/linuxsoft-082809.html
oracle-instantclient12.1-basic-12.1.0.2.0-1.i386.rpm
oracle-instantclient12.1-devel-12.1.0.2.0-1.i386.rpm
oracle-instantclient12.1-s...
下载cx_Oracle
在Python连接操作Oracle数据前,我们先要导入相应的模块包,Python有一个模块cx_Oracle可以与Oracle相连。
要使用cx_Oracle,就要先下载安装。我这里默认的是用windows系统,下载即点击这里
Python连接Oracle数据库标签:本文系统来源:http://www.cnblogs.com/Jims2016/p/5858689.html
# python连接oracle数据
## 介绍------------------------------ python 连接oracle数据库,可以使用cx_oracle模块
- 使用如下命令安装```python -m pip install cx_oracle --pre```
## 连接oracle代码-----------------------------```pythonimport cx_oracle
# 设置 dsn = cx_oracle.makedsn("192.168.0.233", 1521, "tongji")# 连接conn = cx_oracle.connect("sas","tongji123",dsn)
curs = conn.cursor()sql = ‘select * from ...
cx_Oracleconn = cx_Oracle.connect(‘用户名/密码@IP/ServiceName‘) #1个参数conn = cx_Oracle.connect(‘用户名‘, ‘密码‘, ‘IP/ServiceName‘) #3个参数打开 D:\app\username\product\11.2.0\client_1\NETWORK\ADMIN路径下的tnsnames.ora
此处的IP为下列连接描述的HOST,ServiceName为SERVICE_NAME
(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 111.111.111.111)(PORT = 1521)...
win1064、oracle64、python3.6 64,但cx-oracle版本是32位,这样的话,就会出现版本不一致的方法
解决方法:
要使版本一致即可,要么下载一个cx-oracle-64,但没有。那么怎么办?难道要去装一个32的数据库?不用,只要装个32位的即时数据库客户端即可,就是提示中的链接
https://oracle.github.io/odpi/doc/installation.html#windows
点击它,在window模块下,点击去下载对应的版本即可
下载最新的一版,然后解压到同一个文...
import cx_Oracle #导入模块2 3 conn=cx_Oracle.connect("c##scott/tiger@localhost/mldn") #(用户名/密码@主机IP地址/数据库)4 cur=conn.cursor() #获取操作游标5 sql="select * from dept" #sql语句6 cur.execute(sql) #执行括号中的sql语句7 biao=cur.fetchall() #接收全部返回结果8 print(biao)9 conn.commit() #提交
10 cur.close()
11 conn.close()
12 input(‘Pre...
pip install cx_Oracle-6.0rc1-cp35-cp35m-win_amd64.whl
2、安装ORACLE,并建用户TEST/TEST_lu
二、编写PY文件import cx_Oracleconn = cx_Oracle.connect(‘test/test_lu@orcl1‘)print (conn.version)sql = ‘select * from lu_test‘cr=conn.cursor()cr.execute(sql) #执行sql语句if cr.print("\nThis is Fetchall!")rs = cr.fetchall() #一次返回所有结果集print("print all:(%s)" % rs)print("\n print by row:")for x1 in rs...
pip install cx_Oracle下载oracel 客户端 instantclient-basic-windows.x64-18.5.0.0.0dbru.zip ,不下载客户端可能有以下报错:DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "The specified module could not be found". See https://oracle.github.io/odpi/doc/installation.html#windows for help解压文件到脚本 的下级目录,或者设置路径到环境变量#encoding=utf-8
import cx_Oracle as oracle
impor...