How to Configure Database in Django.

  • Sharad Jaiswal
  • 22nd Feb, 2020

1 answer(s) :

  •   Reply
    img

    Shashank Garg

    03rd Oct, 2018
    "

    In Django database can be configured by setting the 'DATABASES' constant in settings.py file. For example:

    If you want to configure and use SQLite as the default database then.

    DATABASES = {
            'default': {
                            'ENGINE': 'django.db.backends.sqlite3',
    			'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    		       }
    	     }
    

    or in order to define multiple databases in Django use the below configuration.

           DATABASES = {'default': {
    				'ENGINE': 'django.db.backends.sqlite3',
    				'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),   
    				 },
    				 'mysql': {
    				          'ENGINE': 'django.db.backends.mysql',
    					  'NAME': 'DbName',       
    					  'USER': 'User',       
    					  'PASSWORD': 'password',       
    					  'HOST': 'db',          
    					  'PORT': '3306',   
    					 }
    				   }
    

Post your Answer :

Valid name is required.

Valid name is required.

Valid email id is required.