Configuration

Oracle Cloud Infrastructure Configuration File

Before you start using ADS, you must create or upload your Oracle Cloud Infrastructure configuration and key files inside of the notebook session environment. The Oracle Cloud Infrastructure configuration file contains the necessary credentials to authenticate your user against the model catalog and other Oracle Cloud Infrastructure services like Object Storage. The configuration file is necessary to pull data from Oracle Cloud Infrastructure in the notebook session environment.

We have included a getting-started.ipynb notebook in the home directory of the notebook session environment. This notebook provides all the steps needed to create the configuration file and the keys. Follow the steps in that notebook before importing and using ADS in your notebooks.

Note

If you already have an Oracle Cloud Infrastructure configuration file (config) and associated keys, you can upload them directly to /home/datascience/.Oracle Cloud Infrastructure using the JupyterLab Upload Files button or the drag-and-drop option.

Setup for ADB

There are two different configurations of the Autonomous Database (ADB). They are the Autonomous Data Warehouse (ADW) and the Autonomous Transaction Processing (ATP) database. The steps to connect to ADW and ATP are the same. To access an instance of the ADB from the notebook environment, you need the client credentials and connection information. The client credentials include the wallet, which is required for all types of connections.

Use these steps to access Oracle ADB:

  1. On the page ADW or ATP instance you want to load dataset from, click DB Connection.

../../_images/DB-Connection.png
  1. Download the Wallet file by clicking Download Wallet. You need to create a password to for the Wallet to download it. You do not need this password to connect from the notebook.

  2. Unzip the wallet.

../../_images/Download-Wallet.png
  1. Create a <path_to_wallet_folder> folder for your wallet on the notebook environment environment.

  2. Upload your wallet files into the <path_to_wallet_folder> folder using the Jupyterlab Upload Files button:

../../_images/Upload_Wallet.png
  1. Open the sqlnet.ora file from the wallet files, then configure the METHOD_DATA to be:

METHOD_DATA = (DIRECTORY="<path_to_wallet_folder>")
  1. To find the location of the sqlnet.ora file, the TNS_ADMIN environment variable must point to that location. We suggest that you create a Python dictionary to store all of the connection information. In this example, this dictionary is called creds. It is generally poor security practice to store credentials in your notebook. We recommend that you use the notebook ads-examples/ADB_working_with.ipynb demonstrates how to store them outside the notebook in a configuration file.

    The environment variable should be set in your notebooks, for example:

# Replace with your TNS_ADMIN value here:
creds = {}
creds['tns_admin'] = <path_to_wallet_folder>
os.environ['TNS_ADMIN'] = creds['tns_admin']
  1. You can find SID names from the tnsname.ora file in the wallet file. Create a dictionary to manage your credentials. In this example, the variable creds is used. The SID is an identifier that identifies the consumer group of the the Oracle Database:

# Replace with your SID name here:
creds['sid'] = <your_SID_name>
  1. Ask your database administrator for the username & password and add them to your creds dictionary. For example:

creds['user'] = <database_user>
creds['password'] = <database_password>
  1. Test the connection to the ADB by running these commands:

os.environ['TNS_ADMIN'] = creds['tns_admin']
connect = 'sqlplus ' + creds['user'] + '/' + creds['password'] + '@' + creds['sid']
print(os.popen(connect).read())

Messages similar to the following are displayed if the connection is successful:

../../_images/Test_connection.png

An introduction to loading data from ADB into ADS using cx_Oracle and ``SQLAlchemy``n is in Loading Data.