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
Metadata
Release files for django-multidatabase-queryset 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_multidatabase_queryset-0.9.0.tar.gz | 16.7 kB | Without provenance | Details for django_multidatabase_queryset-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_multidatabase_queryset-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for django_multidatabase_queryset-0.9.0-py3-none-any.whl |
Total release size: 23.1 kB
Release files / django_multidatabase_queryset-0.9.0.tar.gz
| Download URL | django_multidatabase_queryset-0.9.0.tar.gz |
|---|---|
| Size | 16.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5c8c5527a914bdb1930887660f95d6a3f212acb964b9493efacce8de7547d903
|
|
BLAKE2b-256 checksum How to use checksums |
fbeea059514bf2bd3f8863fd544b69b70227d89cf726e6f81128735a89959983
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.25.0
|
Release files / django_multidatabase_queryset-0.9.0-py3-none-any.whl
| Download URL | django_multidatabase_queryset-0.9.0-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
803d84449f7ff311d76fa317f08e2eeaa14d3d1420815d7635f3abf8f9c09517
|
|
BLAKE2b-256 checksum How to use checksums |
7f7ac0131d95c2c64f40e0b532a1f677c60d5804157c7ad9428b6efc39feb7ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.25.0
|
Security for django-multidatabase-queryset 0.9.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.