I want to call a plpgsql function through psycopg2 and see the warning messages. I.e, I have this function:
create or replace function test_warning() returns void as $$
begin
raise warning 'this is only a test';
end;
$$
language plpgsql;
and call it so in python:
import psycopg2
conn = psycopg2.connect(conn_string)
cursor = conn.cursor()
cursor.callproc("test_warning")
# or so:
cursor.execute('SELECT test_warning()')
Unfortunately the warning message as defined in plpgsql does not appear anywhere in the python output. Is there a way to get the warning message printed in the python output?