如何在python脚本上打印postgres的存储过程?
postgres中的存储过程示例如下:
create or replace function checktime() returns void
language plpgsql
as $$
DECLARE timestart TIMESTAMP;
FOR id from rt LOOP
SELECT timeofday() into timestart;
RAISE NOTICE 'Time now : %', timestart;
END LOOP;
END;
$$
;
从 python 中,我的脚本是:
import psycopg2
conn = psycopg2.connect(host="", database="",
user="", password="")
print("Database Connected")
cur = conn.cursor()
rowcount = cur.rowcount
cur.callproc('rt_visits_function_gz')
# how can i display the raise notice in here?
我希望在运行 python 时显示每个循环的结果。
谢谢
尝试使用“通知”
打印(conn.通知)
http://initd.org/psycopg/docs/connection.html?highlight=notice#connection.notices
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)