+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

Extend Django Queryset to add partition information to select specific partition while querying

发布于2021-03-06 18:31     阅读(942)     评论(0)     点赞(15)     收藏(0)


0

1

2

3

4

5

I am working with table partitioning in MYSQL. I have partitioned my data according to Month such that there are 12 partition for each month. I have applied partition in database level but now want to introduce a queryset method in Django which lets me to select specific partition to query.

from django.db import models
def Person(models.Model):  # My partitioned Model
    name = models.CharField(max_length=100)
    created_month = models.IntegerField()
# I want query like this
Person.objects.using_partition("p0", "p1").filter(name="Kamal")
# Generated SQL(MYSQL): SELECT * FROM person_person PARTITION(p0,p1) where name='kamal'

As seen above I want to add PARTITION(p0,p1) but after FROM table_name.


解决方案


暂无回答

0

1

2

3

4

5

6

7

8

9



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接: https://www.pythonheidong.com/blog/article/879591/4e0229b1762562ad3679/

来源: python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

15 0
收藏该文
已收藏

评论内容:(最多支持255个字符)