一个包含在你的项目中的锐利的应用程序,这样你就可以粉碎你的数据。
django_sharding的Python项目详细描述
#[django sharding](https://github.com/jbkahn/django sharding)
注意:由于[版本中的错误](https://github.com/jbkahn/django sharding/issues/48)不支持django 1.10.3。
以一致的方式跨越多个数据库的数据。
[![构建状态](https://travis-ci.org/jbkahn/django-sharding.svg?branch=master)(https://travis ci.org/jbkahn/django sharding)
[![PYPI版本](https://badge.fury.io/py/django sharding.svg)(https://badge.fury.io/py/django sharding)
[![PYPI下载](https://img.shields.io/PYPI/dm/django sharding.svg)(https://crate.io/packages/django sharding/)
[![覆盖状态](https://coveralls.io/repos/jbkahn/django-sharding/badge.svg?branch=master&service=github)(https://coveralls.io/github/jbkahn/django-sharding?branch=master)
分片是一种通过在多个数据库的多个表中存储同一表的不同行来对数据进行水平分区的方法。这有助于增加到给定资源的连接数,并提高应用程序的读取性能。
\[请阅读文档](http://josephkahn.io/django sharding/)。
我们需要的是功能强大、可扩展和可定制的产品。这个库就是为了这个目的而创建的,它至少包含了管道每个部分的一个实现,其中包含了替换任何单个组件的空间。
[安装部分](http://josephkahn.io/django-sharding/docs/installation/settings.html)用于基本包设置的文档。
在这里,我们将使用Django.Curb.Author的用户模型:从DjangoSaRiang-Loopar中导入AbjixAb/R>
。ShardedByMixin:< BR/> >使用字符串类路径将自定义用户添加到您的设置文件:
By/>‘Python’Br/> AuthuSuuleMyLase=’& lt;AppySuxUsRyMead & G.;用户'BR/> ` BR/>< BR/>α>创建您的第一个SARED模型
BR/>定义您的新模型,例如:
`` python
来自django.db import models
shardedCarids(TableStrategyModel):
通过
@model\u config(sharded=true)
类车(models.model):
id=tableShardEdField(primary\u key=true,source_table_name='app.shardedcarids')
ignition_type=models.charfield(max_length=120)
company=models.foreignkey('companys.company')
def get_shard(self):
return self.company.user.shard
````
running migrations
例如:
````
./manage.py makemigrations<;app廑name>;
=<;数据库别名>;
```
``python
``todo:使用方法更新此数据。
shard=user.shard
car.objects.using(shard).get(id=123)
``````
注意:由于[版本中的错误](https://github.com/jbkahn/django sharding/issues/48)不支持django 1.10.3。
以一致的方式跨越多个数据库的数据。
[![构建状态](https://travis-ci.org/jbkahn/django-sharding.svg?branch=master)(https://travis ci.org/jbkahn/django sharding)
[![PYPI版本](https://badge.fury.io/py/django sharding.svg)(https://badge.fury.io/py/django sharding)
[![PYPI下载](https://img.shields.io/PYPI/dm/django sharding.svg)(https://crate.io/packages/django sharding/)
[![覆盖状态](https://coveralls.io/repos/jbkahn/django-sharding/badge.svg?branch=master&service=github)(https://coveralls.io/github/jbkahn/django-sharding?branch=master)
分片是一种通过在多个数据库的多个表中存储同一表的不同行来对数据进行水平分区的方法。这有助于增加到给定资源的连接数,并提高应用程序的读取性能。
\[请阅读文档](http://josephkahn.io/django sharding/)。
我们需要的是功能强大、可扩展和可定制的产品。这个库就是为了这个目的而创建的,它至少包含了管道每个部分的一个实现,其中包含了替换任何单个组件的空间。
[安装部分](http://josephkahn.io/django-sharding/docs/installation/settings.html)用于基本包设置的文档。
在这里,我们将使用Django.Curb.Author的用户模型:从DjangoSaRiang-Loopar中导入AbjixAb/R>
。ShardedByMixin:< BR/> >使用字符串类路径将自定义用户添加到您的设置文件:
By/>‘Python’Br/> AuthuSuuleMyLase=’& lt;AppySuxUsRyMead & G.;用户'BR/> ` BR/>< BR/>α>创建您的第一个SARED模型
BR/>定义您的新模型,例如:
`` python
来自django.db import models
shardedCarids(TableStrategyModel):
通过
@model\u config(sharded=true)
类车(models.model):
id=tableShardEdField(primary\u key=true,source_table_name='app.shardedcarids')
ignition_type=models.charfield(max_length=120)
company=models.foreignkey('companys.company')
def get_shard(self):
return self.company.user.shard
````
running migrations
例如:
````
./manage.py makemigrations<;app廑name>;
=<;数据库别名>;
```
``python
``todo:使用方法更新此数据。
shard=user.shard
car.objects.using(shard).get(id=123)
``````