Fix infinite loop in database driver.

Signed-off-by: Sam Moffatt <pasamio@gmail.com>
Merge pull request #15 from pasamio/database

Fix infinite loop in database driver.