Postgresql Get Index Of Array Python Questions For If Statement