Home / Docs

Database Setup

By default an SQLite database will be set up for the project, in case you wish to change the database of your choice, please use the below reference to do the same.

Postgresql

To set up a postgresql database for the project, first you have to install the PostgreSQL and its python package psycopg2 .

pip install psycopg2
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': '',
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    }
}

Replace <database_name>, <database_user>, <database_password>, <database_host>, and <database_port> with your PostgreSQL database settings.


python manage.py makemigrations
python manage.py migrate

For more details: Django PostgreSQL Database

MySQL

To configure a MySQL database in Django, follow these steps:


pip install mysqlclient

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '',
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    }
}

Replace <database_name>, <database_user>, <database_password>, <database_host>, and <database_port> with your MySQL database settings.


python manage.py makemigrations
python manage.py migrate

For more details: Django MySQL Database

MariaDB

To configure a MariaDB database with Django, you can follow the same steps used for MySQL database configuration as shown above. 

For more details: Django MariaDB Database

SQLite

To configure a SQLite database with Django, you can follow these steps:


DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

This will create a SQLite database in your project directory named db.sqlite3.


python manage.py makemigrations
python manage.py migrate

Note that SQLite has some limitations compared to other databases, so you may need to consider these limitations if you have a large amount of data or a high level of concurrency in your application.

For more details: Django SQLite Database

OracleDB

To configure an Oracle database with Django, you can follow these steps:

Pip install cx_Oracle


DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.oracle',
        'NAME': '',
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    }
}

Replace <database_name>, <database_user>, <database_password>, <database_host>, and <database_port> with the appropriate values for your Oracle installation.
Run migrations to create the necessary database tables

python manage.py makemigrations
python manage.py migrate

For more details: Django Oracle Database

 

Replace <database_name>, <database_user>, <database_password>, <database_host>, and <database_port> with the appropriate values for your Oracle installation.


python manage.py makemigrations
python manage.py migrate

Note that Oracle has some specific requirements for its database setup, so you may need to consult Oracle’s documentation for more information on how to set up your database correctly.

For more details: Django Oracle Database