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.0.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

django_auth_db_router-1.0.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django-auth-db-router-1.0.0.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.0.0.tar.gz
Algorithm Hash digest
SHA256 e089b08c9a58f42cf8469203689fab4c4c032871a0cf08cc7275a15317b8010c
MD5 c7d8a54962df846c1ddfe91b56d70e09
BLAKE2b-256 26e539a4256a8f9a8b8ece760d2a4c61e7ab369a3f77686384c0e7353edee8d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_auth_db_router-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a8355013d1b7f22b9506df4ec5d942d703ecac45cadb7263c6f278827e19dfa
MD5 9661a8e5f46822754c11b8d7d321e093
BLAKE2b-256 2292c1e2d816ce7bc08753c08dfa22d3a57f0150c87b26af80c2663be9e4583c

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