blog-banner

Announcing CockroachDB support for Django ORM

Last edited on January 27, 2020

0 minute read

    ```

    Django includes a full-featured ORM that simplifies interactions with a database--it’s one of the reasons it’s become one of the most popular web frameworks. Even so, you’re still left to manage scale yourself, and ensure the database is resilient and always on. That can be really hard to do with common Django databases like Postgres, SQLite, and MySQL. And that’s why today, we’re excited to announce a new CockroachDB backend for the Django ORM.

    ```

    Using CockroachDB and Django gives you the ease of writing in Python while getting all the benefits of an open source, distributed SQL database. CockroachDB shards automatically, is naturally resilient, and is highly available. Here’s how to get started:

    Installing django-cockroachdbCopy Icon

    1. Use the version of django-cockroachdb that corresponds to your version of Django. For example, to get the latest compatible release for Django 3.0.x:

    pip install django-cockroachdb==3.0.*

    The minor release number of Django doesn't correspond to the minor release number of django-cockroachdb, so use the latest minor release of each.

    2. Configure the Django DATABASES setting similar to this:

    DATABASES = {     'default': {         'ENGINE': 'django_cockroachdb',         'NAME': 'django',         'USER': 'root',         'PASSWORD': '',         'HOST': 'localhost',         'PORT': '26257',         # If connecting with SSL, remove the PASSWORD entry above and include         # the section below, replacing the file paths as appropriate.         'OPTIONS': {             'sslmode': 'require',             'sslrootcert': '/certs/ca.crt',             'sslcert': '/certs/client.myprojectuser.crt',             'sslkey': '/certs/client.myprojectuser.key',        },    }, }

    Helpful links:Copy Icon

    ORM
    applications
    python
    django

    Keep reading

    View all posts