工作中要用Python调用我的写的存储过程
昨天已经写好给同事了
他晚上试了不行
今天来我写了个小例子,仅供参考啊:
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import cx_Oracle

username = "aa"
userpwd = "bb"
dbname = "cc"
host="db.com"
port = 1521

dsn=cx_Oracle.makedsn(host, port, dbname)
conn = cx_Oracle.connect(username, userpwd, dsn)
cur = conn.cursor()

PARA_A = None#入参
PARA_B = None#入参
PARA_C = '123'#入参
PARA_D = cur.var(cx_Oracle.NUMBER)#返回值
PARA_E = cur.var(cx_Oracle.STRING)#返回值

sql_str = "AA.PROC_TEST"

result = cur.callproc(sql_str, [PARA_A, PARA_B, PARA_C, PARA_D, PARA_E])
r = result[-1]
rr = result[-2]
print r
print rr

conn.commit

cur.close

conn.close
 

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐