Answer the question
In order to leave comments, you need to log in
How to connect multiple databases?
Hello everyone, this is the story.
I have two databases: db_1, db_2. I want to make sure that all jungian default tables are stored in db_1 and certain models are stored in db_2. However, db_2 has two users. The first is the default postgres and the second is test_user which has read-only permission on all tables in db_2.
1. How do I organize all this history in settings.DATABASES? Is this entry correct? If not, how to do it right?
DATABASES = {
'default': {
'ENGINE': "django.db.backends.postgresql_psycopg2",
'NAME': "db_1",
"USER": "postgres",
"HOST": "localhost",
"PASSWORD": "postgres_password",
"PORT": ""
},
'secondary_postgress': {
'ENGINE': "django.db.backends.postgresql_psycopg2",
'NAME': "db_2",
"USER": "postgres",
"HOST": "localhost",
"PASSWORD": "postgres_password",
"PORT": ""
},
'secondary_test_user': {
'ENGINE': "django.db.backends.postgresql_psycopg2",
'NAME': "db_2",
"USER": "test_user",
"HOST": "localhost",
"PASSWORD": "test_user_password",
"PORT": ""
}
}
Answer the question
In order to leave comments, you need to log in
as information, basically, is not complete.All "integral" information in the dock https://docs.djangoproject.com/en/3.0/topics/db/mu... Default behavior is prescribed in routers, and using is needed when you need to use something other than "default" base. Where to do the migration is also prescribed in the routers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question