If you try to connect to Oracle Database 11.2 using python-oracledb's default 'Thin' mode you will get the error:
DPY-3010: connections to this database server version are not supported by python-oracledb in thin mode
How can I connect to this old version of Oracle Database?
Python-oracledb's default Thin mode can connect to Oracle Database 12.1 or later. If
you want to connect to Oracle Database 11.2 you need to enable Thick mode by
calling oracledb.init_oracle_client()
in your code. See the user documentation Enabling python-oracledb Thick mode:
import os
import oracledb
ld = None # On Linux, pass None
if platform.system() == 'Darwin' and platform.machine() == 'arm64':
ld = str(os.environ.get('HOME'))+'/Downloads/instantclient_23_3'
elif platform.system() == 'Darwin' and platform.machine() == 'x86_64':
ld = str(os.environ.get('HOME'))+'/Downloads/instantclient_19_16'
elif platform.system() == 'Windows':
ld = r'C:\oracle\instantclient_19_23'
oracledb.init_oracle_client(lib_dir=ld)
c = oracledb.connect(user="yourusername", password=whatever, dsn="thedbhost:thedbport/thedbservicename")
Oracle DB 11.2 is very old. There is a newer, free releases of Oracle Database available for Linux and Windows: Oracle Database 23c Free.