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

Uploaded Source

Built Distribution

django_auth_db_router-0.1.7-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for django-auth-db-router-0.1.7.tar.gz
Algorithm Hash digest
SHA256 f2c5786b8593b61fb3f1b12d3b0f1d75dc0a612128e16579b8bd32919e001d40
MD5 823313a2cbf336cc81a9be10e1b026f2
BLAKE2b-256 dfe052c851edce893eb0fd9b45cf4ea133ab417fff97205037568e78815d81af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_auth_db_router-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ec621013d54c728fa11805f189ecbece4d3c31644a6080b47ae2aa9194787d7e
MD5 612a2714114944ce37adcf11c4f5d3d5
BLAKE2b-256 f5744c9dbe90b787584381e1b89aa77857ba642cf1a6c6fb0b189359f161f126

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