Sql While Loop Through Array Python Question