I'm using PyGreSQL 4.1.1 with Postgres 9.5, and have written some stored functions. I use RAISE
with different levels inside of the functions for debugging purposes, which works very well in psql
, but I haven't found a way to access those messages in Python.
Example:
CREATE OR REPLACE FUNCTION my_function() RETURNS BOOLEAN AS $_$
BEGIN
RAISE NOTICE 'A notice from my function.';
RETURN TRUE;
END
$_$ LANGUAGE plpgsql;
My Python code looks like this:
conn = pgdb.connect(database = 'mydb', user = 'myself')
cursor = conn.cursor()
cursor.execute("SELECT my_function()"):
How can I access the notice (A notice from my function.
) after running my_function()
?