Check instance of queryset (EmptyQuerySet) instead of catching EmptyResultSet exception in ListSqlQueryKeyBit and RetrieveSqlQueryKeyBit