Skip to main content

Django backend for CockroachDB

Project description

CockroachDB backend for Django

Prerequisites

You must install either:

The binary package is a practical choice for development and testing but in production it is advised to use the package built from sources.

Install and usage

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

pip install django-cockroachdb==4.0.*

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

Configure the Django DATABASES setting similar to this:

DATABASES = {
    'default': {
        'ENGINE': 'django_cockroachdb',
        'NAME': 'django',
        'USER': 'myprojectuser',
        'PASSWORD': '',
        'HOST': 'localhost',
        'PORT': '26257',
        # If connecting with SSL, include the section below, replacing the
        # file paths as appropriate.
        'OPTIONS': {
            'sslmode': 'verify-full',
            'sslrootcert': '/certs/ca.crt',
            # Either sslcert and sslkey (below) or PASSWORD (above) is
            # required.
            'sslcert': '/certs/client.myprojectuser.crt',
            'sslkey': '/certs/client.myprojectuser.key',
            # If applicable
            'options': '--cluster={routing-id}',
        },
    },
}

If using Kerberos authentication, you can specify a custom service name in 'OPTIONS' using the key 'krbsrvname'.

Notes on Django fields

  • IntegerField uses the same storage as BigIntegerField so IntegerField is introspected by inspectdb as BigIntegerField.

  • AutoField and BigAutoField are both stored as integer (64-bit) with DEFAULT unique_rowid().

Notes on Django QuerySets

  • QuerySet.explain() accepts verbose, types, opt, vec, and distsql options which correspond to CockroachDB's parameters. For example:

    >>> Choice.objects.explain(opt=True, verbose=True)
    'scan polls_choice\n ├── columns: id:1 question_id:4 choice_text:2 votes:3\n ├── stats: [rows=1]\n ├── cost: 1.1\n ├── key: (1)\n ├── fd: (1)-->(2-4)\n └── prune: (1-4)'
    

FAQ

GIS support

To use django.contrib.gis with CockroachDB, use 'ENGINE': 'django_cockroachdb_gis' in Django's DATABASES setting.

Disabling CockroachDB telemetry

By default, CockroachDB sends the version of django-cockroachdb that you're using back to Cockroach Labs. To disable this, set DISABLE_COCKROACHDB_TELEMETRY = True in your Django settings.

Known issues and limitations in CockroachDB 22.2.x and earlier

Known issues and limitations in CockroachDB 22.1.x and earlier

  • QuerySet.select_for_update(skip_locked=True) isn't supported.

Known issues and limitations in CockroachDB 21.2.x and earlier

Known issues and limitations in CockroachDB 21.1.x and earlier

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-cockroachdb-4.0.2.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

django_cockroachdb-4.0.2-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

Details for the file django-cockroachdb-4.0.2.tar.gz.

File metadata

  • Download URL: django-cockroachdb-4.0.2.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.2

File hashes

Hashes for django-cockroachdb-4.0.2.tar.gz
Algorithm Hash digest
SHA256 ee4040d50b25b66f2687881741b35da0cc0cd1c51b281f8de8f6ecd252c9cda6
MD5 8a009de6eda2f153600c1efa86cf6cfd
BLAKE2b-256 f334926fdf8ac6e4d8065fcefe34cc78d25c88bb2ef1a73c2c51d3f17153e09f

See more details on using hashes here.

File details

Details for the file django_cockroachdb-4.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_cockroachdb-4.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b33b528f7a9dcff5054290617e57820de0fc279c90b5d1a5d9ce82f857b3e834
MD5 f31e9f02ffc3ea3d564614b5dbcc7fc2
BLAKE2b-256 3b4b019b9fab34c07ca2f810ca94844eebd5bed800c997950d9c24d98f7d3730

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