蟑螂Django后端
django-cockroachdb的Python项目详细描述
Django的CockroachDB后端
先决条件
必须安装:
- 在
psycopg2,它有一些 prerequisites的 它自己的。在
在 - 在 在
二进制包是开发和测试的一个实用选择,但是 生产-建议使用来源构建的包。在
安装和使用
使用与您的版本相对应的django cockroachdb版本 詹戈。例如,要获取Django 3.1.x的最新兼容版本:
pip install django-cockroachdb==3.1.*
Django的次要版本号与次要版本不对应 django蟑螂数量。使用每个版本的最新次要版本。在
配置DjangoDATABASES
设置,如下所示:
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':'require','sslrootcert':'/certs/ca.crt',# Either sslcert and sslkey (below) or PASSWORD (above) is# required.'sslcert':'/certs/client.myprojectuser.crt','sslkey':'/certs/client.myprojectuser.key',},},}
如果使用Kerberos身份验证,则可以在中指定自定义服务名称
'OPTIONS'
使用键'krbsrvname'
。在
关于Django油田的注记
- 在
在IntegerField
使用与BigIntegerField
相同的存储,因此IntegerField
被inspectdb
反思为BigIntegerField
。在 - 在 在
关于Django QuerySets的注记
- 在
^{
^{pr2}$ 在} 接受verbose
、types
、opt
、vec
和{}选项 对应于CockroachDB's parameters。 例如:
常见问题解答
为什么我得到错误psycopg2.errors.InvalidName: no database specified
?
您可能需要create the database。
您可以在命令行中使用cockroach sql --insecure
来获得SQL提示。在
已知问题和限制(从CockroachDB 20.2.0开始)
- 在
蟑螂, 这意味着Django中的某些东西,比如fixture中的前向引用 不支持。在
在 - 在
迁移有一些限制。蟑螂不支持:
在 - 在
已知错误:
在 - 在
不支持的查询:
- 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
- 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>
- ^{
} generates values that are too large for any corresponding foreign keys 。在 - The ^{
} and ^{ 。在} database functions aren't supported
- Mixed type addition in SELECT:
蟑螂20.1.x中的附加限制
- 不支持
StdDev
和Variance
聚合。在 - 不支持更改列的类型。在
- 项目
标签: