pythondjangooracle-databaseinstantclient

How to identify Oracle Instant Client in a Django project?


I try to link an external Oracle database on which I have read-only privileges to my Django project and then only send it raw SQL queries.

So I first created a second table in my project settings (because I still need the default database)

settings.py

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.sqlite3',
    'NAME': BASE_DIR / 'db.sqlite3',
},
'oracleDB':{
    'ENGINE': 'django.db.backends.oracle',
    'NAME': 'my_dsn',
    'USER': 'my_user',
    'PASSWORD': 'my_password',
    'HOST': 'my_host',
    'PORT': 'my_port',
    'OPTIONS':{
        'threaded':True
    }
}

Then in my view I call it this way (seen on a forum):

views.py

from django.db import connections
def my_function(request):
    with connections['oracleDB'].cursor() as cur:
        cur.execute( "SOME SQL QUERY")
        print(cur.fetchall())

And I get this error

DPI-1047: Cannot locate a 64-bit Oracle Client library: “C: ProgramData Oracle12c product 12.1.0 client_1 bin oci.dll is not the correct architecture”. See cx_Oracle 8 Installation — cx_Oracle 8.3.0 documentation for help

I know that I need the Oracle instantclient to connect, I used to use it in connection with the cx_Oracle package and it worked well (so i'm certain the version is good). Except that now I connect with Django and its settings where I can’t specify the path to my Oracle instantclient.

Do you have any idea how to enable Django to detect this client?

I am under Windows 10 64bits.

Thank you in advance, please feel free to ask me to develop


Solution