Postgresql Loop Through Array Python Initialize 2d