在Python中使用cx_Oracle调用Oracle存储过程
发表于:2024-09-30 作者:千家信息网编辑
千家信息网最后更新 2024年09月30日,本文测试在Python中通过cx_Oracle调用PL/SQL。首先,在数据库端创建简单的存储过程。create or replace procedure test_msg(i_user in var
千家信息网最后更新 2024年09月30日在Python中使用cx_Oracle调用Oracle存储过程
本文测试在Python中通过cx_Oracle调用PL/SQL。
首先,在数据库端创建简单的存储过程。
create or replace procedure test_msg(i_user in varchar2, o_msg out varchar2) isbegin o_msg := i_user ||', Good Morning!';end;
然后,开始在Python命令行中进行存储过程调用。
import cx_Orace as cxconn = cx.connect('database connecting string')cursor = conn.cursor()#声明变量user = 'Nick' #plsql入参msg = cursor.var(cx_Oracle.STRING) #plsql出参#调用存储过程cursor.callproc('test_msg', [user, msg]) #['Nick', 'Nick, Good Morning!']#打印返回值print msg #print msg.getvalue() #Nick, Good Morning!#资源关闭cursor.close()conn.close()
延伸阅读:
存储过程、cx_Oracle、Python的对象类型之间存在转换关系。具体如下:
Oracle | cx_Oracle | Python |
VARCHAR2 | cx_Oracle.STRING | str |
CHAR | cx_Oracle.FIXED_CHAR | |
NUMBER | cx_Oracle.NUMBER | int |
FLOAT | float | |
DATE | cx_Oracle.DATETIME | datetime.datetime |
TIMESTAMP | cx_Oracle.TIMESTAMP | |
CLOB | cx_Oracle.CLOB | cx_Oracle.LOB |
BLOB | cx_Oracle.BLOB |
过程
存储
之间
变量
命令
对象
数据
数据库
类型
资源
中通
测试
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
海南网络安全保卫总队的职责
河北省网络安全和信息化委员会网
常州小型工控机服务器
中央网络安全应急指导中心
设计师软件开发
软件开发绩效报告
软件开发实训室介绍
平台如何导出数据库
浙江师范大学数据库试卷
网络安全学习实训心得
网络安全攻防演练科普视频
腾讯云服务器怎么撤销退款
计算机网络技术大一学啥
红杏出墙小说软件开发
南京vr软件开发公司
网络安全周的重要意义
app软件开发 价格
手机软件开发公
丰弘互联网科技
葫芦岛学习软件开发
人像比对的数据库
php上传ftp服务器
久游互联网科技有限公司
电子表格里怎么做数据库
软件开发深耕业务
vps服务器租
网络安全态势分析应用前景
通过id查询数据库信息
单机移动软件开发与应用
godaddy服务器管理