check err on db query