Resolving malformed databases in Django SQlite3

You may encounter the error of malformed databases in SQLite3, during web development using Django. This error can get you stuck in your development journey.

A malformed database in Sqlite3 is usually caused by data corruption or corruption in code.

Today, I will show you how to resolve this error without losing any data, and get your development environment up and running again.

Just follow the steps below:
  • Go to your website project folder and delete the  DB.sqlite3 and all migrations files inside the migrations folder, except the init file.
  • Open a command shell, and change your working directory to your website project folder. Like so “cd my_website_project_folder
  • Then copy and paste the following command on the command line, then press enter,  “python manage.py makemigrations“.
  • After that, copy and paste the following command and press enter, “python manage.py migrate”.
  • Then just restart your web server by running “python manage.py runserver“.

Then just visit the URL http://127.0.0.1:8000 on any browser, your website should be back up and running.

That is how simply you resolve the malformed databases in sqlite3 during python web development.

Access more Web Design Tutorials here.

Share this