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 3.2.x:

pip install django-cockroachdb==3.2.*

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 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 21.2.x and earlier

Known issues and limitations in CockroachDB 21.1.x and earlier

Known issues and limitations in CockroachDB 20.2.x and earlier

  • Changing a column's type isn't supported.

  • Timezones after 2038 use incorrect DST settings.

  • The SHA224 and SHA384 database functions aren't supported.

  • The BoundingCircle, LineLocatePoint, and MemSize GIS database functions aren't supported.

  • You can't use the libgeos_c.so bundled with CockroachDB. If you try this Django setting:

    `GEOS_LIBRARY_PATH = '/usr/local/lib/cockroach/libgeos_c.so'`
    

    It will fail with OSError: libgeos.so.3.8.1: cannot open shared object file: No such file or directory.

  • 3D geometries aren't supported.

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

Uploaded Source

Built Distribution

django_cockroachdb-3.2.3-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django-cockroachdb-3.2.3.tar.gz
  • Upload date:
  • Size: 25.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for django-cockroachdb-3.2.3.tar.gz
Algorithm Hash digest
SHA256 64b93912f5b4bca7cf436015e6108d321892867408798fdc1b6e30fb286fe0f8
MD5 18877b28ba5e089c1434831b9e1272e5
BLAKE2b-256 76a6b31868fe624874ce99dcc73c56b3e7467c371b4d205ad1090458c94ae15b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_cockroachdb-3.2.3-py3-none-any.whl
  • Upload date:
  • Size: 27.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for django_cockroachdb-3.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 dc5bf7b794f634d7c64a4499938e01021643f18374c1190295ba7c5bd117d4ee
MD5 3a2e0289f7126933e8796a7a5b31a12b
BLAKE2b-256 74c9717bd5c8552eb5e9ac197e07c6cf04d641a3f096a478cf9b51f51b6fcc8b

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