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 onlyonUbuntu, 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 ...
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:
root@isaacEXE:/home/ora# oci iam compartment list | grep compartment-id
"ocid1.tenancy.oc1..aaaaaafakeocidahahah4234fasfw12",
root@isaacEXE:/home/ora# oci iam compartment list | grep compartment-id | awk {'print $2'} | sed -e 's/"//g' -e 's/,//g'
ocid1.tenancy.oc1..aaaaaafakeocidahahah4234fasfw12
Let's add it to an environment variable:
root@isaacEXE:/home/ora# export C=`oci iam compartment list | grep compartment-id | awk {'print $2'} | sed -e 's/"//g' -e 's/,//g'`
root@isaacEXE:/home/ora# echo $C
ocid1.tenancy.oc1..aaaaaafakeocidahahah4234fasfw12
Find the Database ID
Check if database 'testing' exists in that compartment ID:
root@isaacEXE:/home/ora# oci db autonomous-database list -c $C | grep display-name
"display-name": "testing",
root@isaacEXE:/home/ora#
Now we need to find the database ID, and save it in an environment variable:
root@isaacEXE:/home/ora# oci db autonomous-database list -c $C --query "data[?\"db-name\"=='testing'].id | [0]" | sed 's/"//g'
ocid1.autonomousdatabase.oc1.eu-frankfurt-1.a123123fakedetailsinherehihi
root@isaacEXE:/home/ora#
root@isaacEXE:/home/ora# export DB=`oci db autonomous-database list -c $C --query "data[?\"db-name\"=='testing'].id | [0]" | sed 's/"//g'`
root@isaacEXE:/home/ora# echo $DB
ocid1.autonomousdatabase.oc1.eu-frankfurt-1.a123123fakedetailsinherehihi
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:
root@isaacEXE:/home/ora# mkdir wallet
root@isaacEXE:/home/ora# # create wallet.zip under newly created folder
root@isaacEXE:/home/ora# touch /home/ora/wallet/wallet.zip
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:
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)
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)
root@isaacEXE:/opt/oracle# # either setup as an environment variable
root@isaacEXE:/opt/oracle# export LD_LIBRARY_PATH=/opt/oracle/instantclient_21_1:$LD_LIBRARY_PATH
root@isaacEXE:/opt/oracle# # or create a link to shared libraries
root@isaacEXE:/opt/oracle# sh -c "echo /opt/oracle/instantclient_21_1 > /etc/ld.so.conf.d/oracle-instantclient.conf"
root@isaacEXE:/opt/oracle# ldconfig
d) Install libaio1 to use Linux kernel asynchronous I/O system calls
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
For this step, we will be using the python module, .