Connect remotely to ATP

Although ATP provides an SQL developer web interface, you may find yourself in situations where it is required from you to access the ATP instances remotely.

For this purpose, the ATP interface provides a "DB Connection" option, which contains the necessary information to log in to your instance remotely:

Click on "DB Connection" and it will take you to "Download Client Credentials". Choose the "Instance Wallet" type. And click "Download Wallet".

This action (example on Windows OS) will download an archive, wallet.zip, that once unzipped, it contains files as tnsname.ora, ojdbc and sqlnet.ora:

Note: from here on, the implemention of setting up the ATP connection is done in Windows subsystem for Linux (Ubuntu 20.04). This means that next steps can be applied not only on Ubuntu, but on other *nix flavours like CentOS (just replace "apt" with "yum"), and why not MacOS (make sure you use "brew" instead of "apt" command).

For those that do not use WSL yet, the OCI CLI for Autonomous database should be applied just the same way from Powershell terminal.

... need to create a tutorial on how to setup OCI CLI for Windows ...

For setting up OCI CLI on Linux, check tutorial "Install and configure OCI CLI"

Setting up the ATP connection

Find the compartment ID

Since I am in the tenancy (the root compartment), this makes it easier to search for the compartment-id:

Let's add it to an environment variable:

Find the Database ID

Check if database 'testing' exists in that compartment ID:

Now we need to find the database ID, and save it in an environment variable:

Download the Wallet

We have just discovered the database ID. Now we can use these details to download the archive wallet.zip

First of all, create a new directory and file where the wallet will be saved:

Download the wallet.zip:

If no errors, following output should be noticed:

... and unzip the wallet.zip archive:

Change sqlnet.ora

The initial sqlnet.ora looks as below:

Change the DIRECTORY with the path where wallet.zip is located (in our case, /home/ora/wallet). In the end, the sqlnet.ora file would have the following content:

About tnsname.ora

This file contains (among others) the service-name of the database. If you take a look at it, you would find a few lines, each one of them starting with database name, followed by the level of performance

In our case (for low priority) would look like this:

We also need to setup TNS_ADMIN as an environment variable. You will have to provide the path where tnsname.ora is located (in our case, under /home/ora/wallet folder)

Testing the ATP connection

For this step, we will be using the python module, cx_Oracle.

  1. Prepare environment

a) Install the Python module:

b) Install the instantclient-basic libraries, specific to your Operating system (in this case, Linux), not before creating a new folder, where to download it and unpack it:

c) Set-up the LD_LIBRARY_PATH, by specifying the path where instantclient has been downloaded to, and the version (in our case, /opt/oracle/instantclient_21_1)

d) Install libaio1 to use Linux kernel asynchronous I/O system calls

2. Test the connectivity

Now, time to implement a simple test:

Last updated