Newbie - Connecting to a Oracle 12c database

Hello everyone,

I’m new to Django development and I’m having a database connection problem that I would love your help with.

I’m using version 4.2 of Django, 8.3.0 of cx_Oracle, and 21.9 of Instant Client. My Oracle server is version 12.2 and I can’t update it.

When trying to connect, I get the following exception: Oracle 19 or later is required (found

Here’s my file:

os.environ["TNS_ADMIN"] = r"C:/app/oracleconfig"

    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'xxxx',
        'USER': 'xxxx',
        'PASSWORD': 'xxxx',
        'HOST': 'xxxx',
        'PORT': 'xxxx',
    'oracle': {
        'ENGINE': '',
        'NAME': 'xxxx',
        'USER': 'xxxx',
        'PASSWORD': 'xxxx',
        'HOST': 'xxxx',
        'PORT': 'xxxx',

And here’s my function:

from django.db import connections

def test_oracle_connection():
        connection = connections['oracle']
        cursor = connection.cursor()
        cursor.execute('SELECT 1 FROM DUAL')
        result = cursor.fetchone()
        return result[0] == 1
    except Exception as e:
        return False

Thanks for your help!

Oracle 12.2 is not supported by Django 4.0+, see:

1 Like

Maybe there’s some other way to do this? A third-party backend, odbc or anything else?

If you want to use Django and Oracle 12.2 you must stick with Django 3.2 (LTS).