superset: Can't connect to Oracle DB

I’m having an issue to connect to an Oracle DB. I’ve already followed the steps to create a requirements-local.txt file into docker/ cx_Oracle package, but still not working.

How to reproduce the bug

  1. touch ./docker/requirements-local.txt
  2. echo "cx_Oracle" >> ./docker/requirements-local.txt
  3. docker-compose build --force-rm
  4. docker-compose up

Expected results

I was expecting to be able to connect into a Oracle database.

Actual results

Actually I got this error message: ERROR: (builtins.NoneType) None (Background on this error at: http://sqlalche.me/e/13/dbapi)

Screenshots

image

Environment

(please complete the following information):

  • browser type and version: Brave
  • superset version: latest
  • any feature flags active: cx_Oracle driver
  • Database: AWS Oracle

Checklist

Make sure to follow these steps before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven’t found one similar.

Additional context

I’m using an AWS Oracle instance to test. I’ve checked the logs of the superset_worker superset_worker_beat containers, and seems that the cx-Oracle lib was successfully installed. image

The superset_app container log: image

I’m using the following string connection: oracle://<username>:<password>@<hostname>:<port> from https://superset.apache.org/docs/databases/oracle/

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 22 (1 by maintainers)

Most upvoted comments

Found a solution to above problem, used docker image apache/superset to build another custom container and that resolved this issue. PSB Dockerfile which is working fine.

FROM apache/superset USER root RUN pip install cx_Oracle RUN apt update RUN apt -y install alien libaio1 wget RUN wget https://download.oracle.com/otn_software/linux/instantclient/185000/oracle-instantclient18.5-basiclite-18.5.0.0.0-3.x86_64.rpm RUN alien -i oracle-instantclient18.5-basiclite-18.5.0.0.0-3.x86_64.rpm RUN sh -c ‘echo /usr/lib/oracle/18.5/client64/lib/ > /etc/ld.so.conf.d/oracle.conf’ RUN ldconfig USER superset

I’m working through a similar problem now. Did you install the Oracle instant client into the Docker container or system you are running superset from? cx_oracle requires either the instant client or full Oracle client. The recently released python-oracledb no longer has this requirement, so installation should get easier in the near future.

I’m using the following in my Docker container to install the latest SQL client:

RUN mkdir -p /usr/share/oracle/network/admin \
    && cd /usr/share/oracle \
    && apt-get update -y \
    && apt-get install -y --no-install-recommends git ca-certificates wget build-essential unzip curl libaio1 libaio-dev \
    && rm -rf /var/lib/apt/lists/* \
    && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
    && wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip \
    && unzip instantclient-basiclite-linuxx64.zip \
    && rm -f instantclient-basiclite-linuxx64.zip \
    && cd  /usr/share/oracle/instantclient* \
    && rm -f *jdbc* *occi* *mysql* *README *jar uidrvci genezi adrci \
    && echo  /usr/share/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf \
    && ldconfig \
    && echo 'local_xe=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=xepdb1)))' > /usr/share/oracle/network/admin/tnsnames.ora```

i had the same issue connecting a docker based superset to a oracle database.

with this very good step by step tutorial i installed a superset instance by scratch and with the following steps (after the installation) my connection to oracle db worked:

cd superset
. superset_env/bin/activate`
sudo pip install cx_Oracle
sudo apt update
sudo  apt -y install alien libaio1 wget
sudo wget https://download.oracle.com/otn_software/linux/instantclient/2113000/oracle-instantclient-basiclite-21.13.0.0.0-1.x86_64.rpm
sudo alien -i oracle-instantclient-basiclite-21.13.0.0.0-1.x86_64.rpm` 
sudo sh -c 'echo /usr/lib/oracle/21.13/client64/lib/ > /etc/ld.so.conf.d/oracle.conf'
sudo ldconfig

the connection string in superset was:

oracle+cx_oracle://USRER:PASSWORD@HOST:PORT/SERVICE_NAME

thank you very much to @shantanukhond for the tutorial and @antiwari001 for the solution to the oracle problem!!

Following this i also sucessfully connected to my oracledb. I did have to use the long connection string from @cofin and manually install the gevent python library

pip install cx_Oracle mkdir -p /opt/oracle cd /opt/oracle wget https://download.oracle.com/otn_software/linux/instantclient/1920000/instantclient-basic-linux.x64-19.20.0.0.0dbru.zip unzip instantclient-basic-linux.x64-19.20.0.0.0dbru.zip apt-get install -y --no-install-recommends libaio1 sh -c “echo /opt/oracle/instantclient_19_20 > /etc/ld.so.conf.d/oracle-instantclient.conf” ldconfig

Running These commands worked for me

hello everyone ,

i got this error ERROR: (builtins.NoneType) None [SQL: (cx_Oracle.DatabaseError) DPI-1047: Cannot locate a 64-bit Oracle Client library: “libclntsh.so: cannot open shared object file: No such file or directory”. See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help (Background on this error at: https://sqlalche.me/e/14/4xp6)] (Background on this error at: https://sqlalche.me/e/14/dbapi)

please can you help it anyone.

One additional note, in case it helps.

I had to connect using a TNS formatted string instead of the easy connect format: oracle+cx_oracle://username:password@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host_or_scan_address)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=db_service_name)))

EDIT: Updated connect string to reference the Oracle driver correctly.