M ILHAMSYAH
M ILHAMSYAH

Reputation: 31

Failed to connect Superset to Oracle Database

Error when add new database

Hi, i try to install superset with docker on ubuntu, but when i tried to connect with my oracle database i get this error. i already add RUN pip install cx_Oracle ini Dockerfile but still not work.

How to resolve this problem, i have try to add config install cx_Oracle module in Dockerfile and i already installed cx_Oracle in ubuntu

Upvotes: 2

Views: 368

Answers (1)

Christopher Jones
Christopher Jones

Reputation: 10691

I got Superset working with python-oracledb (the replacement for cx_Oracle, see the release announcement). The advantage is that you won't need to install Oracle Instant Client libraries.

Steps with screenshots are in my blog.

You'll need to run this, or equivalent, in your Dockerfile:

python -m pip install oracledb --upgrade

If you have more than one version of Python installed, make sure you are using the version of Python that Superset uses.

Running it in the container host won't help.

Then in superset_config.py I added this which makes Superset use python-oracledb in place of cx_Oracle:

import sys
import oracledb
oracledb.version = "8.3.0"
sys.modules["cx_Oracle"] = oracledb
import cx_Oracle

To make the SQLAlchemy connection string easy, I created a tnsnames.ora file $HOME/config/tnsnames.ora with my database connect descriptor:

echo 'cjdb = (description=(address=(protocol=tcps)(port=1521)(host=xxx.oraclecloud.com))(connect_data=(service_name=xxxx.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))' > $HOME/config/tnsnames.ora

and set:

export TNS_ADMIN=$HOME/config

I started my superset server:

superset run -h 0.0.0.0 -p 8088 --with-threads --reload --debugger

Then on the Superset web console, I chose "+" in top right menu -> Data -> Connect Database. In the SUPPORTED DATABASES field, I selected 'Oracle' and added the SQLAlchemy URI like: oracle://cj:mysecret password@cjdb

Upvotes: 2

Related Questions