Postgresql Function Set In Python Syntax For Loop