Postgres Call Function Within A Function In Python