Better error logging when can't open database
Better error logging when can't write to database