Fix infinite loop in database driver.

Fixes an infinite loop in the database driver class which makes it hard to pull data.