Connecting Jupyter Notebook to Oracle Autonomous Database

Jupyter Notebook is an open source web application for Machine Learning and Data Exploration.

In this post I will show you how to connect a Jupyter Notebook to Oracle Autonomous Database and explore the data using Python.

The assumption is we already have a Jupyter notebook sandbox running on Oracle Cloud compute instance.


Connect to your OCI compute instance via SSH.

Start your Jupyter notebook environment and create a new notebook.

$jupyter notebook

or if running as root

#jupyter notebook --allow-root

Access your notebook using the browser > http://<your public IP>:8888

Install the required Python libraries.

# Install required libraries
!pip install sqlalchemy pandas numpy cx_oracle matplotlib

Import the libraries

import sqlalchemy as db
import pandas as pd
import numpy as np
import os
import matplotlib.pyplot as plt

Create a new connection with Oracle Autonomous Database:

os.environ['TNS_ADMIN']='<path to your Oracle db wallet on OCI instance>'

engine = db.create_engine('oracle://<user>:<password>@<service type>')


os.environ['TNS_ADMIN'] = '/opt/oracle/instantclient_19_3/network/admin/'

engine = db.create_engine('oracle://ADMIN:Welcome!@smatATP_TP')

Import this data set to your Oracle Autonomous Database using the Jupyter notebook:

Since you are using OCI compute, you will have to upload the dataset on your compute instance. Then using the Jupyter notebook, load the data to your Database.


df = pd.read_csv('/home/opc/applications/Data/iris.csv')
 df.to_sql('iris', engine, index=False, if_exists='replace')

Retrieve data from the table you just created.

df = pd.read_sql("select * from iris", con=engine)




total = pd.read_sql("select count(*) from iris", con=engine)


Use Matplotlib to visualize the data.

plt.scatter(df.sepal_length, df.sepal_width)


Happy Coding!


Build a machine learning sandbox on Oracle Cloud

Connect to Oracle ATP through Jupyter Notebook

Python, Oracle ADWC and Machine Learning

Object Storage with Oracle Integration Cloud – Part 1

Over the past few years, in everything from personal photo storage to enterprise development there has been an incredible uptake of cloud storage buckets which provide a simple, low-cost mechanism for storing unstructured data. For much longer than that, there has been a need to consume, stage and produce unstructured data in enterprise integration scenarios. File servers accessible via protocols such as FTP/SFTP, etc. are commonly used to meet the staging requirements of traditional file-based integration use cases.

The practice of using an FTP/SFTP server alongside Oracle’s cloud integration platform – Oracle Integration Cloud (henceforth, OIC), is nothing new and is well documented.

In a series of upcoming blogs, I will explore how we can use Oracle’s cloud storage buckets (Oracle Cloud Infrastructure – Object Storage) instead of a traditional FTP server in cloud-based integrations. In this initial blog I will focus on:

  • Connecting to Object Storage with Oracle Integration Cloud
  • Writing Files to Object Storage with Oracle Integration Cloud
  • Enforcing an archival policy for files at rest