1. 安装python 3.6.3 x64的版本, 同时选择安装pip等component
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
pip信息
pip 9.0.1 from d:workpython36libsite-packages (python 3.6)
2. 增加环境Oracle的instant client 并且放到环境变量中,
3. 安装cx_Oracle
pip install cx_Oracle
我已经安装过了 所以提示.
Requirement already satisfied: cx_Oracle in d:workpython36libsite-packages
4. 尝试连接字符串
在python 中引入 cx_Oracle
import cx_Oracle
创建db
db=cx_Oracle.connect('LCOI709999/Test6530@10.24.13.85/ora12cr2')
定义SQL变量
sql='select count(1) from gspuser'
创建游标
cur=db.cursor()
定义执行
cur.execute(sql)
获取结果
usercount=cur.fetchall()
打印结果
print('%s' %usercount)