Django postgres refresh materialized views
Project description
Installation
$ [sudo] pip install django-postgres-refresh-matviews
How it works
refresh_pg_matviews
- refresh allpg_matviews
matviewsrefresh_pending_matviews
- refreshMatview
model matviews:repeat_seconds
- seconds interval to refresh matviewis_pending
- setTrue
to force refresh
settings.py
INSTALLED_APPS+=['django_postgres_refresh_matviews']
migrate
$ python manage.py migrate
Examples
from django_postgres_refresh_matviews.utils import refresh_pg_matviews
refresh_pg_matviews()
from django_postgres_refresh_matviews.models import Matview
from django_postgres_refresh_matviews.utils import refresh_pending_matviews
Matview.objects.get_or_create(schemaname='public',matviewname='matview1')
refresh_pending_matviews()
Matview.objects.filter(schemaname='public').update(is_pending=False)
Log
from django_postgres_refresh_matviews.models import Log
for l in Log.objects.filter(schemaname='public',matviewname='matview1'):
l.started_at, l.completed_at
cli
$ python manage.py clear_matviews # clear matviews
$ python manage.py init_matviews # init postgres matviews
$ python manage.py refresh_pg_matviews # refresh pg_matviews
$ python manage.py refresh_pending_matviews # refresh pending Matview matviews
raw sql
INSERT INTO refresh_matview(schemaname,matviewname)
SELECT schemaname,matviewname
FROM pg_matviews
ON CONFLICT (schemaname,matviewname) DO NOTHING;
UPDATE refresh_matview SET is_pending=true
WHERE schemaname='public' AND matviewname='matview1';
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
File details
Details for the file django-postgres-refresh-matviews-2020.12.5.tar.gz
.
File metadata
- Download URL: django-postgres-refresh-matviews-2020.12.5.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05ae2967884501d128516cb5e8bca550b55bf44c453ebfd521fa2dccf3f33e4b |
|
MD5 | ab0a4c3b9d49ed9306c54effd0019503 |
|
BLAKE2b-256 | 628a860b2df9ab1445e80b4bfeb52b43be5f25dbab9b4a7bc5b400488e42180d |