Skip to content
Related Articles

Related Articles

How to integrate Mysql database with Django?

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 16 Mar, 2021

Django is a Python-based web framework that allows you to quickly create efficient web applications. It is also called batteries included framework because Django provides built-in features for everything including Django Admin Interface, default database – SQLlite3, etc. 

How to integrate Mysql database with Django ?

Install Mysql database

After downloading install the setup and set the admin and password.

Install Django

pip install django

Then install another library to use mysql database

pip install mysqlclient

Create new project

django-admin startproject MyDB
cd MyDB


    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'mydb',
        'USER': 'root',
        'PASSWORD': 'admin',

Open here inside the DATABASES variable configure mysql database values, and add values of your database.

python migrate

Then create new app

python startapp main



from django.db import models
from django.contrib.auth.models import User
#Create your models here.
class PublishedArticle(models.Model):
    todo = models.CharField(max_length=40)
    date = models.DateField(auto_now=True)

python migrate

The published article table would have been created in the Database. Hence, Mysql database is successfully integrated

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!