Execute Sql Query In Python Iteration