Want to update using dnf returns rpmdb open failed

So I wanted to update using
sudo dnf update
but then it failed saying rpmdb open failed

error: sqlite failure: CREATE TABLE IF NOT EXISTS ‘Packages’ (hnum INTEGER PRIMARY KEY AUTOINCREMENT,blob BLOB NOT NULL): disk I/O error
error: cannot open Packages index using sqlite - No such file or directory (2)
error: cannot open Packages database in /usr/lib/sysimage/rpm
Error: Error: rpmdb open failed