python 连接Oracle 的步骤

1、 安装 cx_Oracle

pip install cx_Oracle

2、配置  oci.dll 与 oraociei11.dll 添加到环境变量path中

下载地址:百度搜索下载,Oracle  PLSQL 进行下载

3、连接步骤

# coding:utf-8

import pandas as pd

import sys
import codecs
#sys.stdout = codecs.getwriter("gbk")(sys.stdout.detach())

from sqlalchemy import create_engine

import cx_Oracle

#db=cx_Oracle.connect(‘admin‘,‘admin‘,‘172.16.1.452:1521/orcl‘,encoding = "UTF-8", nencoding = "UTF-8")
db=cx_Oracle.connect(‘你的账号‘,‘密码‘,‘IP:端口/服务名‘,encoding = "UTF-8", nencoding = "UTF-8")
print (db.version)

cr=db.cursor()

SQL2 = ‘‘‘SELECT * FROM OA_W_BAOXIAOMXYWB‘‘‘

cr.execute(SQL1)

rs=cr.fetchall()

zz=pd.DataFrame(rs)

print (zz)

db.close()

原文地址:https://www.cnblogs.com/wuzaipei/p/11594243.html

时间: 2024-08-13 12:18:29

python 连接Oracle 的步骤的相关文章

python连接Oracle数据库

# python连接oracle数据 ## 介绍------------------------------ python 连接oracle数据库,可以使用cx_oracle模块 - 使用如下命令安装```python -m pip install cx_oracle --pre``` ## 连接oracle代码-----------------------------```pythonimport cx_oracle # 设置 dsn = cx_oracle.makedsn("192.168.

python 连接oracle 报错 cx_Oracle.DatabaseErro

1,python 连接oracle的时候报错如下 cx_Oracle.DatabaseError: ORA-24315: 非法的属性类型 ,2,导致这个错误的原因是服务器oracle版本和客户端cx_oracle客户端版本不一致引起的,所以通过下面命令询oracle版本. select * from v$version 3,然后到 http://sourceforge.net/projects/cx-oracle 下载对应的客户端版本即可

用python连接oracle(11g)数据库

准备: 1.下载对应版本的oracle-instantclient(我这里是11.2.0.1.0) http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html 2.安装 rpm -ivh oracle-instantclient11.2-basic-11.2.0.1.0-1.x86_64.rpm 3.配置环境变量 export LD_LIBRARY_PATH=/usr/lib/oracl

Python 连接 Oracle数据库

1.环境设置 [[email protected] ~]# cat /etc/redhat-release CentOS release 6.9 (Final) [[email protected] ~]# python -V Python 2.6.6 版本:Oracle 12c 2.前提:安装cx_Oracle模块依赖包 由于使用Python连接Oracle,所以需要下载oracle客户端包 官网:http://www.oracle.com/technetwork/topics/linuxx8

python 连接oracle(cx_Oracle模块)

使用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/[email protected]/sid')

Python连接Oracle,从安装到基本用法

本文将介绍如何使用Python连接Oracle数据库进行数据读取与写入.首先介绍环境的安装,此部分借鉴网友的博客,后一部分介绍连接数据库和读书取数等基本使用语法. 1. 环境安装 借鉴网友阑珊的博客,感谢分享! https://www.cnblogs.com/lansan0701/p/8039332.html 2. 使用语法 (1) 连接数据库 #加载cx_Oracle模块 import cx_Oracle #创建连接 conn = cx_Oracle.connect('用户名/密码@主机IP地

windows下python连接oracle数据库

python连接oracle数据库的方法,具体如下 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 c

Python连接Oracle实例

最近需要用Python连接Oracle操作,之前接触过,没自己手写过,特此记录.数据库是Oracle 11,python版本2.7的. 这个需求是两个库A和B,假设现在需要识别一张表在A库里面有没记录,如果没有,将表名写入一个log,如果有再去B库里查有没有该表,如果没有,表名计入另外一个log文件. 查库的sql语句 select t.* from all_objects t where t.object_name = upper(&table_name); Python连接oracle需要的

python连接oracle配置

环境: 操作系统:win7 64位,CPU是inter的pc机 Oracle服务端:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production Oracle本地客户端:Release 11.2.0.1.0  32bit Production Python版本:python2.7.5 (安装路径:C:\Python27\) cx_Oracle版本:cx_Oracle-5.2.1-11g.win-amd64