Skip to content

ret0rn/django-database-settings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Django database settings


PostgreSQL

PostgreSQL_img

Install

pip install psycopg2

Use

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',

        'NAME': '<db_name>',

        'USER': '<db_username>',

        'PASSWORD': '<password>',

        'HOST': 'localhost',

        'PORT': '5432',
    }
}

MySQL

MySQL_img

Install

pip install mysqlclient

Use

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',

        'NAME': '<db_name>',

        'USER': '<db_username>',

        'PASSWORD': '<password>',

        'HOST': 'localhost',
        
        'PORT': '3306',
    }
}

Oracle

Oracle_img

Install

pip install cx_Oracle

Use

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.oracle',

        'NAME': '<db_name>',

        'USER': '<db_username>',

        'PASSWORD': '<password>',

        'HOST': 'localhost',

        'PORT': '1540',
    }
}

MongoDB (Djongo)

MongoDB_img

Install

pip install djongo

Use

DATABASES = {
    'default': {
        'ENGINE': 'djongo',
        
        'NAME': '<db_name>',
    }
}

OR

DATABASES = {
    'default': {
        'ENGINE': 'djongo',
        
        'NAME': '<db_name>',
        
        'ENFORCE_SCHEMA': False,
        
        'CLIENT': {
            'host': 'mongodb+srv://<db_username>:<password>@<atlas cluster>/<myFirstDatabase>?retryWrites=true&w=majority'
        }
    }
}

SQLite

SQLite_img

Use

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