Skip to main content

Simple database router was originally written for personal and work purposes.

Project description

Django auth DB router.

Simple database router that helps to split your main database and authentication database. This may be necessary, for example, when splitting a project into microservices.

Quickstart

  1. Add django_auth_db_router to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'django_auth_db_router',
        ...
    ]
    
  2. Add DATABASE_ROUTERS setting in settings.py file:

    DATABASE_ROUTERS = [
        'django_auth_db_router.routers.AuthRouter',
    ]
    
  3. Add auth_db section to DATABASES:

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': BASE_DIR / 'default.sqlite3',
        },
        'auth_db': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': BASE_DIR / 'auth.sqlite3',
        },
    }
    
  4. Finally, add AUTH_DB setting:

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

    Without this setting router will use default db connection.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-auth-db-router-1.1.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

django_auth_db_router-1.1.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file django-auth-db-router-1.1.1.tar.gz.

File metadata

  • Download URL: django-auth-db-router-1.1.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for django-auth-db-router-1.1.1.tar.gz
Algorithm Hash digest
SHA256 eabb86991519852197f285fc201f6dd1888584c99eb52c75381553c6a4befa02
MD5 e99544f4ca444df9534d87bbec85e8ac
BLAKE2b-256 c6d5141202b320b22590eb66e1bc6766d2c27f008cc053f6f7ec3fe7545c1bbb

See more details on using hashes here.

File details

Details for the file django_auth_db_router-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_auth_db_router-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d9c4b5f301c6e4409d68be5ef351f6772b9c088a1781f03cbfa02206640a1af
MD5 945e1deb1ad1344f20faa36c7dc6f84b
BLAKE2b-256 23d5fd79cb7f47120e7c233f18be1884400e1e27d4a88affc55b452dfb8c7584

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page