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.2.0.tar.gz (6.0 kB view hashes)

Uploaded Source

Built Distribution

django_auth_db_router-1.2.0-py3-none-any.whl (7.2 kB view hashes)

Uploaded Python 3

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