前置工作
可以直接采用pip install cx_Oracle
安装cx_Oracle库
连接Oracle
import numpy as np
import cx_Oracle as oracle
def connectOracle(userName,passWord,dataBaseIp,dataBasePort=None,serviceName):
connectStatement = ""
if userName:
connectStatement = userName + "/"
else:
print("userName is Null!")
return "userName is Null!"
if passWord:
connectStatement += passWord + "@"
if dataBaseIp:
connectStatement += dataBaseIp
else:
print("dataBaseIp is Null!")
return "dataBaseIp is Null!"
if dataBasePort:
connectStatement += ":" + dataBasePort + "/"
if serviceName:
connectStatement += serviceName
else:
print("serviceNameis Null!")
return "serviceNameis Null!"
try:
db = oracle.connect(connectStatement)
except Exception as e:
print(e)
return