Python调用ORACLE存储过程
工作中要用Python调用我的写的存储过程昨天已经写好给同事了他晚上试了不行今天来我写了个小例子,仅供参考啊:#!/usr/bin/python# -*- coding: UTF-8 -*-import cx_Oracleusername = "aa"userpwd = "bb"dbname = "cc"host="db.com"port = 1521dsn=cx_Oracle.makedsn(h
工作中要用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
更多推荐
所有评论(0)