Giter Club home page Giter Club logo

django-cockroachdb's Introduction

CockroachDB backend for Django

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.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. Use the latest minor release of each.

If a release series of django-cockroachdb only has pre-releases (alphas or betas), you'll see an error with a list of the available versions. In that case, specify the exact version that you want. For example, if django-cockroachdb 3.0 alpha 1 is available:

$ pip install django-cockroachdb==3.0.*`
ERROR: Could not find a version that satisfies the requirement
django-cockroachdb==3.0.* (from versions: 3.0a1)

$ pip install django-cockroachdb==3.0a1
...
Successfully installed django-cockroachdb-3.0a1 psycopg2-2.8.4

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',
        },
    },
}

Notes on Django fields

  1. CharField's max_length is ignored. It uses the same storage as TextField so CharField is introspected by inspectdb as TextField.

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

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

FAQ

Why do I get the error psycopg2.errors.InvalidName: no database specified?

You may need to create the database. You can use cockroach sql --insecure on the command line to get a SQL prompt.

Known issues and limitations (as of cockroachdb 19.2.2)

  1. CockroachDB doesn't support savepoints. This means a few things:

    1. Django's transaction.atomic() can't be nested.
    2. Django's TestCase works like TransactionTestCase. That is, transactions aren't used to speed up the former.
  2. CockroachDB can't disable constraint checking, which means certain things in Django like forward references in fixtures aren't supported.

  3. Migrations have some limitations. CockroachDB doesn't support:

    1. changing column type
    2. dropping or changing a table's primary key
  4. Known Bugs:

    1. The extract() function doesn't respect the time zone.
    2. Interval math across daylight saving time is incorrect.
    3. date_trunc('week', <value>) truncates to midnight Sunday rather than Monday
    4. date_trunc() results are incorrectly localized.
    5. cast() timestamptz to time doesn't respect the time zone.
    6. Interval math may be incorrect on date columns.
  5. Unsupported queries:

    1. Mixed type addition in SELECT: unsupported binary operator: <int> + <float>
    2. UPDATE float column with integer column: value type int doesn't match type FLOAT8 of column <name>
    3. Division that yields a different type: unsupported binary operator: <int> / <int> (desired <int>)
    4. The power() database function doesn't accept negative exponents: power(): integer out of range
    5. The StdDev and Variance aggregates aren't supported.
    6. extract() doesn't support interval columns (DurationField): unknown signature: extract(string, interval)
    7. The log() function doesn't support custom bases: unknown signature: extract(string, interval)
    8. sum() doesn't support arguments of different types: sum(): unsupported binary operator: <float> + <int>
    9. greatest() doesn't support arguments of different types: greatest(): expected <arg> to be of type <type>, found type <other type>
    10. The isoyear lookup isn't supported: extract(): unsupported timespan: isoyear
    11. timezone() doesn't support UTC offsets: timezone(): unknown time zone UTC...
    12. SmallAutoField generates values that are too large for any corresponding foreign keys.
    13. The SHA224 and SHA384 database functions aren't supported.

django-cockroachdb's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.