我有一个如下所示的存储过程,当我在 DBeaver 中运行该过程时,我能够在控制台中看到
RAISE INFO
的输出,但是我想在从 python 运行时记录相同的输出
使用cursor.execute('call testing_proc()')
我该怎么做?
CREATE OR REPLACE PROCEDURE testing_proc()
AS $$
declare
cntr int :=1 ;
max_cntr int := 200;
time_counter timestamp ;
perc_cmp real;
time_taken real ;
tempp int ;
begin
time_counter = getdate() ;
while( cntr <= max_cntr)
loop
INSERT INTO table2 SELECT * FROM table1;
perc_cmp = cntr*100/max_cntr ;
RAISE INFO '****Total Processed = %
Total Processed = % ***',cntr , perc_cmp;
cntr = cntr+1;
end loop;
time_taken = datediff(second, time_counter , getdate() );
RAISE INFO '******* Total Time Taken = % seconds ', time_taken ;
end;
$$ LANGUAGE plpgsql;
PS:请不要纠结于理解我刚刚分享的代码的细节,供参考