i have two large tables in my database that change every day at 6AM , and I want to archive the most recent month , i decided to use table partitioning to store every day's data in partition , i installed django-postgres-extra
and i'm getting this error when i run the server
note that :
- i have two databases one for users , and the other one 'prev' for my app
- the tables that I want to archive are in prev
- I'm using the extension PostGis on 'prev'
can you help me please ?
here is my settings.py :
> DATABASES = {
> 'default':{
> },
> 'prev': {
> 'ENGINE':'psqlextra.backend',
> 'NAME': '[database_name]',
> 'USER': '[username]',
> 'PASSWORD': '[Password]',
> 'HOST': 'localhost',
> },
> 'users': {
> 'ENGINE': 'django.db.backends.postgresql',
> 'NAME':'[database_name]',
> 'USER': '[username]',
> 'PASSWORD': '[Password]',
> 'HOST': '127.0.0.1',
>
} } POSTGRES_EXTRA_DB_BACKEND_BASE = 'django.contrib.db.backends.postgis'
DATABASE_ROUTERS=['user.router.AuthRouter' ,'prevision.router.PrevRouter']
error :
$ python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/user/Bureau/vig/backend/venv/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/user/Bureau/vig/backend/venv/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
autoreload.raise_last_exception()
File "/home/user/Bureau/vig/backend/venv/lib/python3.8/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/home/user/Bureau/vig/backend/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 398, in execute
autoreload.check_errors(django.setup)()
File "/home/user/Bureau/vig/backend/venv/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/user/Bureau/vig/backend/venv/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/user/Bureau/vig/backend/venv/lib/python3.8/site-packages/django/apps/registry.py", line 116, in populate
app_config.import_models()
File "/home/user/Bureau/vig/backend/venv/lib/python3.8/site-packages/django/apps/config.py", line 304, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/user/Bureau/vig/backend/venv/lib/python3.8/site-packages/psqlextra/models/__init__.py", line 1, in <module>
from .base import PostgresModel
File "/home/user/Bureau/vig/backend/venv/lib/python3.8/site-packages/psqlextra/models/base.py", line 6, in <module>
class PostgresModel(models.Model):
File "/home/user/Bureau/vig/backend/venv/lib/python3.8/site-packages/psqlextra/models/base.py", line 13, in PostgresModel
objects = PostgresManager()
File "/home/user/Bureau/vig/backend/venv/lib/python3.8/site-packages/psqlextra/manager/manager.py", line 23, in __init__
[
File "/home/user/Bureau/vig/backend/venv/lib/python3.8/site-packages/psqlextra/manager/manager.py", line 26, in <listcomp>
if "psqlextra" in db_settings["ENGINE"]
KeyError: 'ENGINE'
and if you have any other solution (package maybe) to solve the archiving problem please suggest it to me
Thank You .