CentOS+Python + cx_Oracle 配置

编辑时间2018-05-28

下载依赖包cx_Oracle 驱动包

conda info  cx_Oracle 

conda install cx_Oracle

链接oracel 语句

import cx_Oracleas db

import os

os.environ['NLS_LANG'] ='SIMPLIFIED CHINESE_CHINA.UTF8'

def queryOracle(sql):

   username ="AI_ROAD_CLASSIFY"

    passwd ="AI_ROAD_CLASSIFY"

    host ="192.168.0.215"

    port ="1521"

    serverName ="orcl"

    dsn = db.makedsn(host, port, serverName)

con = db.connect(username, passwd, dsn)

cur = con.cursor()

cur.execute(sql)

result = cur.fetchall()

cur.close()

con.close()

return result

if __name__ =="__main__":

   sql ="select sysdate from dual"

    result = queryOracle(sql)

print result

你可能感兴趣的:(CentOS+Python + cx_Oracle 配置)