You must install either:
psycopg2, which has some prerequisites of its own.
The binary package is a practical choice for development and testing but in production it is advised to use the package built from sources.
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.
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',
},
},
}
CharField
's max_length
is ignored. It uses the same storage as
TextField
so CharField
is introspected by inspectdb
as TextField
.
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()
.
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)'
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.
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:
Known Bugs:
Unsupported queries:
unsupported binary operator: <int> + <float>
value type int doesn't match type FLOAT8 of column <name>
unsupported binary operator: <int> / <int> (desired <int>)
power(): integer out of range
StdDev
and Variance
aggregates
aren't supported.sum(): unsupported binary operator: <float> + <int>
greatest(): expected <arg> to be of type <type>, found type <other type>
SmallAutoField
generates values that are too large for any corresponding foreign keys.SHA224
and SHA384
database functions aren't supported.Savepoints aren't supported. This means a few things:
TestCase
works like TransactionTestCase
. That is,
transactions aren't used to speed up the former.Known Bugs:
date_trunc('week', <value>)
truncates to midnight Sunday rather than MondayUnsupported queries:
unknown signature: extract(string, interval)
unknown signature: extract(string, interval)
timezone(): unknown time zone UTC...