fix ZeroDivisionError if there was only one query to database - issue #7