{{announcement.body}}
{{announcement.title}}

Connecting to the Oracle Autonomous Data Warehouse via Oracle Cloud Data Science Service

DZone 's Guide to

Connecting to the Oracle Autonomous Data Warehouse via Oracle Cloud Data Science Service

This tutorial demonstrates how to connect two Oracle cloud services, Oracle Autonomous Data Warehouse and the Cloud Data Science services.

· Cloud Zone ·
Free Resource

In this article, I will link Oracle's two different cloud services. I hope it will be a useful article in terms of awareness.

As it is known, Oracle recently announced the Data Science Cloud Service. This service is a cloud service with features that will speed up the work of professionals dealing with data science, artificial intelligence, machine learning. You can read detailed information about this service by clicking on the link.

Data Science Cloud

Data Science Cloud

The Data Science Cloud service is a platform with a Jupyter Notebook interface. While developing a model in this interface, we have a wide variety of options to read the data that will be the subject of our development. In this study, I will use Autonomous Data Warehouse (ADW) service, which is also a cloud service. I will connect to ADW through the Data Science Cloud service and read the data from the tables here.


You may also enjoy: Connecting an Autonomous Data Warehouse With Python


First of all, we need an Oracle Client to connect to the Oracle ADW service. By typing the following command on the terminal screen we set up above, we can get this client to download on the Oracle Data Science Cloud Service machine.

Shell
 




x


 
1
wget https://download.oracle.com/otn_software/linux/instantclient/195000/instantclient-basic-linux.x64-19.5.0.0.0dbru.zip


Oracle Science Cloud

Yes, after running our command, we can observe that the related client has been downloaded shortly. However, the file we downloaded is a .zip file, so we open this compressed file by running the command below on the terminal screen.

Shell
 




xxxxxxxxxx
1


 
1
unzip instantclient-basic-linux.x64-19.5.0.0.0dbru.zip


We opened our client (you can see that the instantclient_19_5 folder has occurred in the directory) and now let's upload the wallet, which we will connect to ADW and download by the ADW service, to our Oracle Data Science service. We can easily upload via the buttons on the screen.

Upload button

Upload button

After loading our ADW Wallet to the environment, we will move the wallet into the client we opened in the service with the following 2 commands and extract it from the zip file.

Shell
 




xxxxxxxxxx
1


 
1
mv Wallet_DBML19C.zip instantclient_19_5/network/admin/
2
 
          
3
cd instantclient_19_5/network/admin/
4
 
          
5
unzip Wallet_DBML19C.zip


Finally, we need to update the wallet path in the sqlnet.ora file in the wallet we extracted. (sqlnet.ora -> instantclient_19_5 / network / admin / sqlnet.ora)

Let's first look at the content of sqlnet.ora.

Shell
 




xxxxxxxxxx
1


 
1
more sqlnet.ora


Contents of sqlnet.ora

Contents of sqlnet.ora


Open this file. We need to change the part of the “?” character where we open our wallet with the full path and save and close it. We can do this change with vi as well as through the interface. As a result, our sqlnet.ora file should be as follows.

Revised sqlnet.ora

Revised sqlnet.ora


We have now provided all the necessary conditions to connect through the notebook. Now, let's start a new notebook from the interface and try to reach ADW with Python code.

Opening notebook

Opening notebook


Python
 




xxxxxxxxxx
1
13


 
1
import sqlalchemy as db
2
import pandas as pd
3
import numpy as np
4
import os
5
import warnings as w
6
w.filterwarnings("ignore",category=Warning)
7
 
          
8
os.environ['TNS_ADMIN']='instantclient_19_5/network/admin/'
9
engine = db.create_engine('oracle://ADMIN:Welcome1@dbml19c_high')
10
 
          
11
f = pd.read_sql("select * from dba_tables", con=engine)
12
 
          
13
f.head(5)


As you can see, we were able to read a sample data in our ADW Cloud Service and put it in a data frame from a notebook we started in Data Science Cloud Service.

Further Reading

Autonomous Database: Creating an Autonomous 

Big Data: Data Science and Advanced Analytics

Topics:
oracle cloud ,data science ,machine learning ,ai ,autonomous data warehouse ,data science cloud ,oracle services ,cloud ,artificial intelligence

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}