Postgresql Loop Through Array Python Methods String