how can I check database connection to mysql in django

All you need to do is start a application and if its not connected it will fail. Other way you can try is on shell try following –

from django.db import connections
from django.db.utils import OperationalError
db_conn = connections['default']
    c = db_conn.cursor()
except OperationalError:
    connected = False
    connected = True

Leave a Comment