No project description provided
Project description
django-multidatabase-queryset
Use multi database as one.
It's a common scenario that you want to
store hot data in the default database (using SSD) and
store cold data in the db_cold database (using HDD).
You want to use it like normal queryset without considering it.
Table of Contents
Usage
# add django_multidatabase_queryset to your project apps
INSTALLED_APPS = [
...
"django_multidatabase_queryset",
]
# inherit the django_multidatabase_queryset.models.MultiDataBaseModel, set the database used
class UserAction(MultiDataBaseModel):
DATABASES = ["default", "db_cold"]
type = models.TextField(default="")
detail = models.JSONField(default=dict)
# Use the objects as normal objects
data1 = UserAction(id=1, type="type4")
data1.save(using="default")
data2 = UserAction(id=2, type="type3")
data2.save(using="db_cold")
data3 = UserAction(id=3, type="type1")
data3.save(using="db_cold")
order_qs = UserAction.objects.order_by(
"type", "pk")
data = list(order_qs)
LOGGER.info(data)
self.assertEqual(data[0].type, "type1")
self.assertEqual(data[1].type, "type3")
self.assertEqual(data[2].type, "type4")
self.assertEqual(order_qs.count(), 3)
Installation
pip install django-multidatabase-queryset
License
django-multidatabase-queryset
is distributed under the terms of the MIT license.
TODO
- multi queryset slice
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
Close
Hashes for django_multidatabase_queryset-0.8.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43124e11ad21c4401c9822bcd312a56c1cffd9d3a465372311f0c92f6c4a29a1 |
|
MD5 | 5f792ff513b77a96a328ad6a34d4436d |
|
BLAKE2b-256 | 4246c6db75a10539dd4fb59d29e6f3d917d4a070acd4b4f5cf9bc4932a1283e4 |
Close
Hashes for django_multidatabase_queryset-0.8.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b43568977fcd93e8f197495221d4cc13fab986d03f65908f65390afee9d1f7b9 |
|
MD5 | 0a06379c8ee29b420570833b6fcf3b39 |
|
BLAKE2b-256 | d4472b3bc1402b50e8990eeb68721795a530c9ae19eeb295b37149e3f45862e5 |