Postgres Execute Function Python Syntax If Else Statement