I have a web application in Python django. I need to import users and display data about them from another database, from another existing application. All I need is the user to be able to login and display information about them. What solutions are?
CodePudding user response:
You can set 2 DATABASES in settings.py.
DATABASES = {
'default': {
...
},
'user_data': {
...
}
}
Then in one database store User models with authentication and stuff, in another rest information. You can connect information about specific User with a field that is storing id of User from another database.
CodePudding user response:
Here's what I think.
Sometimes people say "database" when it is, actually, another "schema".
Whichever it is, you'd pick one of schemas to be your "master" schema.
- if it is a different database, you'll need a database link to establish connection
- if it is a different user, one of them will have to
grant selectprivilege to another (which will then be able to fetch data owned by another user)
Then, create a view which would either
- contain only data from another schema (so you'd display it separately), or
- represent
UNIONof data from both schemas (so you'd display all data at once)
That view would, finally, be a source on a page in your web application.
