Python Create Postgresql Function