sqlite3.DatabaseError: database disk image is malformed

When i update using sudo dnf upgrade i m getting some database error

  File "/usr/lib/python3.9/site-packages/dnf/plugin.py", line 104, in _caller
    getattr(plugin, method)()
  File "/usr/lib/python3.9/site-packages/dnf-plugins/generate_completion_cache.py", line 62, in sack
    cur.execute("delete from available")
sqlite3.DatabaseError: database disk image is malformed

I can reproduce error using sudo dnf upgrade --refresh command

You can rebuild the rpm database with

sudo rpm --rebuilddb

That should clean up any database corruption and allow you to start over.

didnt work

Try (generic suggestion similar to your post)

sudo dnf clean all
sudo rpm --rebuilddb

If there is corrupted data in the cache it may bleed over to an error in the database. The dnf clean command will wipe out the cache so the database may be built new.

When you give a reply such as “didnt work” we have no clue what information you may have received on the screen and no way to know what actually may have interfered.

Please post the command that failed and all related following text so we can see the actual error and might possibly be able to give an answer that is directed to the error instead of a general “try this” type answer.

sudo dnf upgrade

Fix the database first. It obviously is causing the dnf upgrade error.

Here is the rpm way to fix that error.

1 Like