> ## Documentation Index
> Fetch the complete documentation index at: https://docs.domino.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect to Oracle Database

This topic describes how to connect to [Oracle Database](https://www.oracle.com/database/) from Domino. You must have network connectivity between Oracle and your Domino deployment.

The easiest way to connect to Oracle from Domino is to create a Domino Data Source as described below.

## Create an Oracle Data Source

1. From the navigation pane, click **Data > Data Sources**.

2. Click **Create a Data Source**.

3. In the New Data Source window, from **Select Data Store**, select **Oracle**.

4. Enter the **Host**, **Port**, and name of the **Database**.

5. Enter the **Data Source Name**.

6. Optional: Enter a **Description** to explain the purpose of the Data Source to others.

7. Click **Next**.

8. Enter the **Username** and **Password** to connect to Oracle. The Domino secret store backed by HashiCorp Vault securely stores the credentials.

9. Click **Test Credentials**.

10. If the Data Source authenticates, click **Next**.

11. Select who can view and use the Data Source in projects.

12. Click **Finish Setup**.

## Alternate way to connect to Oracle

<Warning>
  This section describes an alternate method to connect to Oracle. Domino does not officially support this method.
</Warning>

1. Before you can connect to Oracle, you must install the following client software your environment:

   * The basic package: `instantclient-basic-linux.x64-<oracle-version>dbru.zip`

   * The SDK package: `instantclient-sdk-linux.x64-<oracle-version>dbru.zip`

     You must download these files from the [Instant Client Downloads page](https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html).

     1. Use your Oracle customer login.

     2. Host an internal mirror of the files somewhere accessible to your Domino hosts.

     3. Install the software manually. In the example environments in this topic, these files are retrieved from a private S3 bucket with [Wget](https://www.gnu.org/software/wget/). You must make them available in a similar manner for your Domino deployment.

### Python and cs\_Oracle

1. To interact with Oracle databases from Python, Domino recommends the [cx\_Oracle](https://oracle.github.io/python-cx_Oracle/) library.

2. Use the following Dockerfile instruction to install the Oracle client drivers and cx\_Oracle in your environment.

   <Note>
     You cannot copy and paste this Dockerfile directly, because you must set up your own internal host of the Oracle clients and modify the `wget` step shown here to retrieve them.
   </Note>

   ```dockerfile theme={null}
   USER root

   RUN \
       wget https://download.oracle.com/otn_software/linux/instantclient/2350000/instantclient-sdk-linux.x64-23.5.0.24.07.zip -O /home/ubuntu/instantclient-sdk-linux.x64-23.5.0.24.07.zip && \
       cd /home/ubuntu && \
       unzip instantclient-sdk-linux.x64-23.5.0.24.07.zip && \
       mv instantclient_23_5 /usr/local/lib && \
       rm instantclient-sdk-linux.x64-23.5.0.24.07.zip && \
       apt-get install -y libaio1

   RUN \
       echo 'export OCI_LIB=/usr/local/lib/instantclient_23_5' \
             >> /home/ubuntu/.domino-defaults && \
       echo 'export OCI_INC=/usr/local/lib/instantclient_23_5/sdk/include' \
             >> /home/ubuntu/.domino-defaults && \
       echo 'export LD_LIBRARY_PATH=/usr/local/lib/instantclient_23_5:$LD_LIBRARY_PATH' \
             >> /home/ubuntu/.domino-defaults

   RUN \
       cd /usr/local/lib/instantclient_23_5 && \
       ln -sf libclntsh.so.23.5 libclntsh.so && \
       chown -R ubuntu:ubuntu /usr/local/lib/instantclient_23_5

   RUN \
       echo '/usr/local/lib/instantclient_23_5' \
             > /etc/ld.so.conf.d/oracle-instantclient.conf && \
       ldconfig -v

   RUN pip install cx_Oracle --upgrade

   USER ubuntu
   ```

3. Set the following Domino environment variables to store secure information about your Oracle connection.

   * `ORACLE_HOST`

     Hostname where your database is running. Make sure your Oracle host and network firewall are configured to accept connections from Domino.

   * `ORACLE_SERVICE`

     The service name of the Oracle service running on the target host.

   * `ORACLE_USER`

     The Oracle user you want to authenticate as.

   * `ORACLE_PASSWORD`

     Password for the user specified previously.

     See [Store Project credentials](/cloud/platform-capabilities/core-concepts/projects/configure-projects/store-project-credentials) to learn more about Domino environment variables.

4. See the [cx\_Oracle documentation](https://cx-oracle.readthedocs.io/en/latest/index.html) for information about how to use the package. The following is an example to connect to Oracle with cx\_Oracle where:

   * You have set up environment variables with the hostname, service name, username, and password.

   * Your user has access to a database named `houses` in the target Oracle instance.

   ```python theme={null}
   from __future__ import print_function
   import cx_Oracle
   import os

   # fetch values from environment variables and set the target database
   hostname = os.environ['ORACLE_HOST']
   service  = os.environ['ORACLE_SERVICE']
   username = os.environ['ORACLE_USER']
   password = os.environ['ORACLE_PASSWORD']
   connection_string = hostname + "/" + service

   # Connect as user "hr" with password "welcome" to the "oraclepdb" service running on this computer.
   connection = cx_Oracle.connect(username, password, connection_string)

   cursor = connection.cursor()
   cursor.execute("""
       SELECT address
       FROM houses
       WHERE zip = 90210""")
   for address in cursor:
       print("Address:", address)
   ```

### R and ROracle

1. To interact with Oracle databases from R, Domino recommends the [ROracle](https://cran.r-project.org/web/packages/ROracle/index.html) library.

2. Use the following Dockerfile instruction to install the Oracle client drivers and RODBC in your environment.

   <Note>
     You cannot copy and paste this Dockerfile directly because you must set up your own internal host of the Oracle clients and modify the `wget` step shown here to retrieve them.
   </Note>

   ```dockerfile theme={null}
   USER root

   RUN \
       wget https://download.oracle.com/otn_software/linux/instantclient/2350000/instantclient-sdk-linux.x64-23.5.0.24.07.zip -O /home/ubuntu/instantclient-sdk-linux.x64-23.5.0.24.07.zip && \
       cd /home/ubuntu && \
       unzip instantclient-sdk-linux.x64-23.5.0.24.07.zip && \
       mv instantclient_23_5 /usr/local/lib && \
       rm instantclient-sdk-linux.x64-23.5.0.24.07.zip && \
       apt-get install -y libaio1

   RUN \
       echo 'export OCI_LIB=/usr/local/lib/instantclient_23_5' \
             >> /home/ubuntu/.domino-defaults && \
       echo 'export OCI_INC=/usr/local/lib/instantclient_23_5/sdk/include' \
             >> /home/ubuntu/.domino-defaults && \
       echo 'export LD_LIBRARY_PATH=/usr/local/lib/instantclient_23_5:$LD_LIBRARY_PATH' \
             >> /home/ubuntu/.domino-defaults

   RUN \
       cd /usr/local/lib/instantclient_23_5 && \
       ln -s libclntsh.so.23.5 libclntsh.so && \
       chown -R ubuntu:ubuntu /usr/local/lib/instantclient_23_5

   RUN \
       echo '/usr/local/lib/instantclient_23_5' \
             > /etc/ld.so.conf.d/oracle-instantclient.conf && \
       ldconfig -v

   RUN \
       cd /home/ubuntu && \
       wget https://cran.r-project.org/src/contrib/ROracle_1.3-1.tar.gz && \
       R CMD INSTALL --configure-args='--with-oci-inc=/usr/local/lib/instantclient_23_5/sdk/include --with-oci-lib=/usr/local/lib/instantclient_23_5' ROracle_1.3-1.tar.gz

   USER ubuntu
   ```

3. Set up the following Domino environment variables to store secure information about your Oracle connection.

   * `ORACLE_HOST`

     Hostname where your database is running. Make sure your Oracle host and network firewall are configured to accept connections from Domino.

   * `ORACLE_SERVICE`

     The service name of the Oracle service running on the target host.

   * `ORACLE_USER`

     The Oracle user you want to authenticate as.

   * `ORACLE_PASSWORD`

     Password for the user specified previously.

     See [Store Project credentials](/cloud/platform-capabilities/core-concepts/projects/configure-projects/store-project-credentials) to learn more about Domino environment variables.

4. See the [ROracle documentation](https://www.rdocumentation.org/packages/ROracle/versions/1.3-1/topics/dbConnect-methods) for usage details.

## Next steps

* After connecting to your Data Source, learn how to [Use Data Sources](/cloud/platform-capabilities/core-concepts/data/data-source-connectors/use-data-sources).

* [Share this Data Source](/cloud/platform-capabilities/core-concepts/data/sharing-and-security/share-data-sources) with your collaborators.
