Hi, I need configure DB Postgres in Ralph, not in Mysql or sqlite as default. In a server installed Postgress, created a user and database, installed psycopg2, configured settings/base.py and set:
DATABASES = {
'default': {
'ENGINE': os.environ.get('DATABASE_ENGINE', 'transaction_hooks.backends.psycopg2'), # noqa
'NAME': os.environ.get('DATABASE_NAME', 'ralph_ng'),
'USER': os.environ.get('DATABASE_USER', 'ralph_ng'),
'PASSWORD': os.environ.get('DATABASE_PASSWORD', 'ralph_ng') or None,
'HOST': os.environ.get('DATABASE_HOST', '127.0.0.1'),
'PORT': os.environ.get('DATABASE_PORT', 5432),
}
}
But not work, not connect the BD, when migrate appear this error:
Traceback (most recent call last):
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 20, in <module>
import psycopg2 as Database
ModuleNotFoundError: No module named 'psycopg2'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/ralph/ralph-core/bin/ralph", line 10, in <module>
sys.exit(prod())
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/ralph/__main__.py", line 28, in prod
main('ralph.settings.prod')
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/ralph/__main__.py", line 14, in main
execute_from_command_line(sys.argv)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/core/management/__init__.py", line 328, in execute
django.setup()
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/apps/config.py", line 86, in create
module = import_module(entry)
File "/opt/ralph/ralph-core/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/ralph/admin/__init__.py", line 2, in <module>
from ralph.admin.mixins import (
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/ralph/admin/mixins.py", line 23, in <module>
from mptt.admin import MPTTAdminForm, MPTTModelAdmin
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/mptt/admin.py", line 26, in <module>
from mptt.models import MPTTModel, TreeForeignKey
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/mptt/models.py", line 377, in <module>
class MPTTModel(six.with_metaclass(MPTTModelBase, models.Model)):
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/utils/six.py", line 808, in __new__
return meta(name, bases, d)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/mptt/models.py", line 264, in __new__
cls = super_new(meta, class_name, bases, class_dict)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/models/base.py", line 139, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/models/base.py", line 324, in add_to_class
value.contribute_to_class(cls, name)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/models/options.py", line 250, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/__init__.py", line 36, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/utils.py", line 241, in __getitem__
backend = load_backend(db['ENGINE'])
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/utils.py", line 112, in load_backend
return import_module('%s.base' % backend_name)
File "/opt/ralph/ralph-core/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/opt/ralph/ralph-core/lib/python3.6/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 24, in <module>
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named 'psycopg2'
Thanks for you time and attention