Fixed #22879 -- Wrapped cursor iterator to intercept database errors coming from __next__ method.

...ethod.

This is needed for django-sqlserver driver.

Ticket #22879