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()
自动化学习。