GitHub user abedalawieh created a discussion: Workaround: Oracle connection
fails due to cx_Oracle lookup even when using oracledb
🧩 Context
In Apache Superset, Oracle connections are officially supported via SQLAlchemy
using the newer oracledb driver.
However, Superset still internally looks for cx_Oracle, which causes connection
failures when cx_Oracle is not installed.
This is especially common in Docker-based deployments where only oracledb is
installed.
❌ Problem
Even after installing oracledb, Superset still raises errors similar to:
ModuleNotFoundError: No module named 'cx_Oracle'
This happens because some parts of SQLAlchemy / Superset still reference
cx_Oracle explicitly.
🔍 Root Cause
Although oracledb is the modern replacement for cx_Oracle, Superset (or its
dependencies) still imports cx_Oracle by name, even when oracledb is present.
So:
oracledb is installed ✅
Superset still searches for cx_Oracle ❌
✅ Solution / Workaround
1️⃣ Ensure oracledb is installed
Add it to requirements-local.txt:
oracledb
Rebuild the Superset image after this.
2️⃣ Alias oracledb as cx_Oracle in superset_config_docker.py
This bridges the compatibility gap cleanly.
try:
import sys
import oracledb
sys.modules["cx_Oracle"] = oracledb
oracledb.version = "8.3.0" # optional, for compatibility
except Exception:
pass
This makes Superset believe cx_Oracle exists while actually using oracledb.
🔗 Connection String Used
After applying the workaround, the Oracle connection works using:
oracle://<USER>:<PASSWORD>@<HOST>:1521/?service_name=<SERVICE_NAME>
✔ Verification
Superset starts successfully
Oracle database connection validates correctly
Datasets and SQL Lab queries work as expected
GitHub link: https://github.com/apache/superset/discussions/37428
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]