Fix malformed database in case pkg update is interrupted

Ignore the malformed failure and rebuild the database from scratch.
Modify get_pragma() for it to be able to not emit errors if emission of
errors is not needed