Python and Advanced PostgreSQL with psycopg2 - User-defined functions in PostgreSQL