Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django admin and SQLite: database disk image is malformed

I have developed a Django powered web-pages where I am storing pretty much all content inside a database, let's say sqlite.db

Django properly reads all information from the database and displays the webpage correctly.

Using the admin interface however (on the production server -> the development server coming with the pydev plugin from Eclipse is working fine) the database cannot be accessed. If I just copy the database file it tells me it cannot read and I don't even get the log-on screen to the admin app of django. If I change the file and directory permissions as suggested in many forums I am getting the admin login screen, however django returns the "DatabaseError at /admin/ - database disk image is malformed" Error.

I am using Django 1.6.5 and sqlite3 3.7.13

Any ideas?

EDIT: I found out that only the main page of the django admin interface is affected. I can navigate to the app settings with no problems.

like image 462
EvilSmurf Avatar asked Sep 22 '14 15:09

EvilSmurf


People also ask

How do I fix SQLite database disk image is malformed?

If you find the 'SQLite Database Disk Image is malformed' error, export your database into an SQL file. To export the data, click the File tab followed by Export>>Database to SQL file. The Export SQL dialog box appears on the screen; select the objects you want to export and define the other options.

How do I fix database disk image is malformed?

You may see the "database disk image is malformed" error in TekRADIUS log. This could happen during unplanned shutdown or reboot. The error indicates that one or more of the sqlite3 databases may have become corrupted. You need to have sqlite3.exe to diagnose and fix the problem.


2 Answers

Only three steps.

  1. delete db.sqlite3 and all migrations files
  2. run python manage.py makemigrations
  3. run python manage.py migrate
like image 149
vikas thakur Avatar answered Sep 21 '22 09:09

vikas thakur


As Joel pointed out "SQLite3 database or disk is full / the database disk image is malformed" has a solution in its comment sections (https://askubuntu.com/questions/30185/banshee-encountered-a-fatal-error-sqlite-error-11-database-disk-image-is-malfo). Thank you Joel Goldstick for the help!

like image 45
EvilSmurf Avatar answered Sep 18 '22 09:09

EvilSmurf