I'm currently working on a Django application that interacts with an Oracle database. My application needs to execute SQL queries on a remote Oracle database, which is configured in the settings.py file.
The SQL queries I'm trying to execute have a syntax similar to:
SELECT * FROM table@source
Here, source is a different database than the one currently executing the query. Both the source and target databases are Oracle databases.
Despite the remote database being configured in settings.py, I encounter the following error when executing the first query:
ORA-02019: connection description for remote database not found
I'm looking for guidance on how to resolve this error. Here's some additional information that might be helpful:
I've confirmed that the remote database is accessible outside of the Django environment. The user credentials used in settings.py have the necessary privileges. The application works fine with local database queries. Has anyone encountered a similar issue or can provide insights into what might be going wrong? Any advice on configuring Django to work seamlessly with remote Oracle databases using database links would be greatly appreciated.
Thank you in advance for your help!
@sourcemeans that your client (python/django on your local machine) talks to one database (presumably, in this case, thetargetdatabase) and then thattargetdatabase opens a database link to thesourcedatabase where thetabletable is located and performs the query and then the result set is sent back to thetargetdatabase and then back to the client.When you use a database link, you are NOT connecting directly to the
sourcedatabase so anything specified in thesettings.pyis irrelevant.Either:
Do not use database links and use:
And tell Django to use the connection to the
sourcedatabase that is specified in thesettings.py(See the Multiple Databases - Django Documentation for more details); orOnly specify the
targetdatabase insettings.pyand create a database link ontargetto thesource. Something like:(Read the documentation link above and adapt as appropriate.)
Then you can connect to
targetand use: