legacy: dbdump refactoring fix

* Adds missing functions from master to dbquery, which caused e.g.
  dbdump to not work. (closes #2088)

Signed-off-by: Lars Holm Nielsen <lars.holm.nielsen@cern.ch>
legacy: dbquery pep8/257 fixes

* Fixes most PEP8/PEP257 errors in dbquery.

Signed-off-by: Lars Holm Nielsen <lars.holm.nielsen@cern.ch>