Django backend for CockroachDB
Project description
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 2.2.x:
pip install django-cockroachdb==2.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.
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 2.2 alpha 1 is available:
$ pip install django-cockroachdb==2.2.*`
ERROR: Could not find a version that satisfies the requirement
django-cockroachdb==2.2.* (from versions: 2.2a1)
$ pip install django-cockroachdb==2.2a1
...
Successfully installed django-cockroachdb-2.2a1 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
-
CharField
'smax_length
is ignored. It uses the same storage asTextField
soCharField
is introspected byinspectdb
asTextField
. -
IntegerField
uses the same storage asBigIntegerField
soIntegerField
is introspected byinspectdb
asBigIntegerField
. -
AutoField
andBigAutoField
are both stored as integer (64-bit) withDEFAULT 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)
-
CockroachDB doesn't support savepoints. This means a few things:
- Django's transaction.atomic() can't be nested.
- Django's
TestCase
works likeTransactionTestCase
. That is, transactions aren't used to speed up the former.
-
CockroachDB can't disable constraint checking, which means certain things in Django like forward references in fixtures aren't supported.
-
Migrations have some limitations. CockroachDB doesn't support:
- changing column type
- dropping or changing a table's primary key
-
Known Bugs:
- The extract() function doesn't respect the time zone.
- Interval math across daylight saving time is incorrect.
date_trunc('week', <value>)
truncates to midnight Sunday rather than Monday- date_trunc() results are incorrectly localized.
- cast() timestamptz to time doesn't respect the time zone.
- Interval math may be incorrect on date columns.
-
Unsupported queries:
- Mixed type addition in SELECT:
unsupported binary operator: <int> + <float>
- UPDATE float column with integer column:
value type int doesn't match type FLOAT8 of column <name>
- Division that yields a different type:
unsupported binary operator: <int> / <int> (desired <int>)
- The power() database function doesn't accept negative exponents:
power(): integer out of range
- The
StdDev
andVariance
aggregates aren't supported. - extract() doesn't support interval columns (DurationField):
unknown signature: extract(string, interval)
- The log() function doesn't support custom bases:
unknown signature: extract(string, interval)
- sum() doesn't support arguments of different types:
sum(): unsupported binary operator: <float> + <int>
- greatest() doesn't support arguments of different types:
greatest(): expected <arg> to be of type <type>, found type <other type>
- The isoyear lookup isn't supported:
extract(): unsupported timespan: isoyear
- timezone() doesn't support UTC offsets:
timezone(): unknown time zone UTC...
- Mixed type addition in SELECT:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-cockroachdb-2.2b1.tar.gz
.
File metadata
- Download URL: django-cockroachdb-2.2b1.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb9c288e2b868bea1db9542e0ef31016a14a1166959d06a8bf8ca0910b49b30e |
|
MD5 | bf000eaabc46a37e924bdba0ab44a45e |
|
BLAKE2b-256 | f7facf27da29b0bf2c62c74031b66b0c0b1a8424078bb53277ba267665db8daf |
File details
Details for the file django_cockroachdb-2.2b1-py3-none-any.whl
.
File metadata
- Download URL: django_cockroachdb-2.2b1-py3-none-any.whl
- Upload date:
- Size: 22.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e81bb10ac6caa8918b720656a078c7d778075d22d75419a0b5aff18ec1309ca1 |
|
MD5 | a59ded18401a70e3bf2171adb1b9f248 |
|
BLAKE2b-256 | 3febec89328f5397162d662af23650a11d7d8c5e230efcbf0eb9eea079375077 |