SlideShare a Scribd company logo
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Python Development Example
Read data from Oracle Database into Pandas DataFrame
Johan Louwers – Chief Customer Architect @ Oracle
Version : Feb 2019
@johanlouwers
Johanlouwers.blogspot.com
Oracle Confidential – Internal/Restricted/Highly Restricted
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
2
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. |
Python Development
with pandas and CX_Oracle
Slide-deck Intention :
• This presentation is intended to provide
a quick introduction example on how to
load data from an Oracle Database into
pandas.
• This example is a part of a wider
workshop deck and shared as a stand-
alone example for ease of sharing.
• The code should only be used as an
educational example and is not
intended to be included in any real-
world application code.
3
Contact details :
Johan Louwers - Chief Customer Architect
@johanlouwers
Johan.louwers@oracle.com
github.com/louwersj
Johanlouwers.blogspot.com
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | 4
Python Development
Pandas – read data from database into DataFrame
A B C D
0 A0 B0 C0 D0
1 A1 B1 C1 D1
2 A2 B2 C2 D2
pd.read_sql
What do we want to achieve?
1) Read data from an Oracle database into a DataFrame based upon a SQL query.
2) We use cx_Oracle in combination with Oracle Database 18c
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | 5
import pandas as pd
import cx_Oracle
orclUserName = 'pandas_test'
orclPassword = 'pandas_test'
orclHost = '192.168.33.10'
orclPort = '1521'
orclServiceName = 'pdb1'
dsn = cx_Oracle.makedsn(host=orclHost,
port=orclPort,
sid=None,
service_name=orclServiceName
)
connection = cx_Oracle.connect(user=orclUserName,
password=orclPassword,
dsn=dsn,
encoding="UTF-8",
nencoding="UTF-8"
)
query = """SELECT * FROM emp"""
df_ora = pd.read_sql(query, con=connection)
print (df_ora.head())
Import
cx_Oracle
Provide needed
details
Define the Data
Source Name
Define the
connection
Define the
query
Execute the
read_sql()
Python Development
Pandas – read data from database into DataFrame
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | 6
Show me the output
1) You can verify the output of df_ora.head() with the content of your database EMP table
Python Development
Pandas – read data from database into DataFrame
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 7
import data from Oracle Database into Python Pandas Dataframe
Ad

Recommended

Connexion point à point (ppp, hdlc)
Connexion point à point (ppp, hdlc)
EL AMRI El Hassan
 
Pfe
Pfe
Maryem Brahem
 
Presentation pfe ingenieur d etat securite reseau et systemes
Presentation pfe ingenieur d etat securite reseau et systemes
Hicham Moujahid
 
QCM Sécurité Informatique
QCM Sécurité Informatique
Zakariyaa AIT ELMOUDEN
 
Algorithme de chiffrement RC4, A5/1 & A5/2
Algorithme de chiffrement RC4, A5/1 & A5/2
Max Benana
 
LES RESEAUX INFORMATIQUES.pdf
LES RESEAUX INFORMATIQUES.pdf
ssuser18776b
 
Rapport_PFE_Securite (1).pdf
Rapport_PFE_Securite (1).pdf
AhmedDhib6
 
Fiche 1 evolution de la notion de risque
Fiche 1 evolution de la notion de risque
Halim ARROUDJ
 
IDS,SNORT ET SÉCURITÉ RESEAU
IDS,SNORT ET SÉCURITÉ RESEAU
CHAOUACHI marwen
 
Rapport de stage développement informatique
Rapport de stage développement informatique
MehdiOuqas
 
Assurance notions de base IMA 2011
Assurance notions de base IMA 2011
PELTIER Claire
 
siem.pdf
siem.pdf
tomtestsecurite
 
Internet et ses services
Internet et ses services
Abdoulaye Dieng
 
mémoire de projet de fin d'études
mémoire de projet de fin d'études
MortadhaBouallagui
 
RADIUS ET TACACS+.pptx
RADIUS ET TACACS+.pptx
ZokomElie
 
Sécurité-Wifi
Sécurité-Wifi
DAmien Gueg'
 
Rapport projet fin d'étude
Rapport projet fin d'étude
HibaFarhat3
 
cours TVA Maroc
cours TVA Maroc
El Mehdi Rachidi
 
Administration réseaux sous linux cours 1
Administration réseaux sous linux cours 1
Stephen Salama
 
Cours CyberSécurité - Concepts Clés
Cours CyberSécurité - Concepts Clés
Franck Franchin
 
IoT Toulouse : introduction à mqtt
IoT Toulouse : introduction à mqtt
Julien Vermillard
 
Supervision de réseau informatique - Nagios
Supervision de réseau informatique - Nagios
Aziz Rgd
 
Alphorm.com Formation Hacking et Sécurité 2020 (4of4) : Attaques AD et Web
Alphorm.com Formation Hacking et Sécurité 2020 (4of4) : Attaques AD et Web
Alphorm
 
Projet reseau-de-kherfallah-ipm-2010-2011
Projet reseau-de-kherfallah-ipm-2010-2011
Boubaker KHERFALLAH
 
Rapport de stage à la Banque Marocaine pour le Commerce et l'Industrie (BMCI)
Rapport de stage à la Banque Marocaine pour le Commerce et l'Industrie (BMCI)
Sabrine Aghbal
 
Les risques fiscaux
Les risques fiscaux
bouchra elabbadi
 
Slide 1 l'ouverture de compte
Slide 1 l'ouverture de compte
bellvita_17
 
Avantages fiscaux
Avantages fiscaux
Melek Sellami
 
Python and Oracle : allies for best of data management
Python and Oracle : allies for best of data management
Laurent Leturgez
 
Overview of Oracle Database 18c Express Edition (XE)
Overview of Oracle Database 18c Express Edition (XE)
Todd Bottger
 

More Related Content

What's hot (20)

IDS,SNORT ET SÉCURITÉ RESEAU
IDS,SNORT ET SÉCURITÉ RESEAU
CHAOUACHI marwen
 
Rapport de stage développement informatique
Rapport de stage développement informatique
MehdiOuqas
 
Assurance notions de base IMA 2011
Assurance notions de base IMA 2011
PELTIER Claire
 
siem.pdf
siem.pdf
tomtestsecurite
 
Internet et ses services
Internet et ses services
Abdoulaye Dieng
 
mémoire de projet de fin d'études
mémoire de projet de fin d'études
MortadhaBouallagui
 
RADIUS ET TACACS+.pptx
RADIUS ET TACACS+.pptx
ZokomElie
 
Sécurité-Wifi
Sécurité-Wifi
DAmien Gueg'
 
Rapport projet fin d'étude
Rapport projet fin d'étude
HibaFarhat3
 
cours TVA Maroc
cours TVA Maroc
El Mehdi Rachidi
 
Administration réseaux sous linux cours 1
Administration réseaux sous linux cours 1
Stephen Salama
 
Cours CyberSécurité - Concepts Clés
Cours CyberSécurité - Concepts Clés
Franck Franchin
 
IoT Toulouse : introduction à mqtt
IoT Toulouse : introduction à mqtt
Julien Vermillard
 
Supervision de réseau informatique - Nagios
Supervision de réseau informatique - Nagios
Aziz Rgd
 
Alphorm.com Formation Hacking et Sécurité 2020 (4of4) : Attaques AD et Web
Alphorm.com Formation Hacking et Sécurité 2020 (4of4) : Attaques AD et Web
Alphorm
 
Projet reseau-de-kherfallah-ipm-2010-2011
Projet reseau-de-kherfallah-ipm-2010-2011
Boubaker KHERFALLAH
 
Rapport de stage à la Banque Marocaine pour le Commerce et l'Industrie (BMCI)
Rapport de stage à la Banque Marocaine pour le Commerce et l'Industrie (BMCI)
Sabrine Aghbal
 
Les risques fiscaux
Les risques fiscaux
bouchra elabbadi
 
Slide 1 l'ouverture de compte
Slide 1 l'ouverture de compte
bellvita_17
 
Avantages fiscaux
Avantages fiscaux
Melek Sellami
 
IDS,SNORT ET SÉCURITÉ RESEAU
IDS,SNORT ET SÉCURITÉ RESEAU
CHAOUACHI marwen
 
Rapport de stage développement informatique
Rapport de stage développement informatique
MehdiOuqas
 
Assurance notions de base IMA 2011
Assurance notions de base IMA 2011
PELTIER Claire
 
Internet et ses services
Internet et ses services
Abdoulaye Dieng
 
mémoire de projet de fin d'études
mémoire de projet de fin d'études
MortadhaBouallagui
 
RADIUS ET TACACS+.pptx
RADIUS ET TACACS+.pptx
ZokomElie
 
Rapport projet fin d'étude
Rapport projet fin d'étude
HibaFarhat3
 
Administration réseaux sous linux cours 1
Administration réseaux sous linux cours 1
Stephen Salama
 
Cours CyberSécurité - Concepts Clés
Cours CyberSécurité - Concepts Clés
Franck Franchin
 
IoT Toulouse : introduction à mqtt
IoT Toulouse : introduction à mqtt
Julien Vermillard
 
Supervision de réseau informatique - Nagios
Supervision de réseau informatique - Nagios
Aziz Rgd
 
Alphorm.com Formation Hacking et Sécurité 2020 (4of4) : Attaques AD et Web
Alphorm.com Formation Hacking et Sécurité 2020 (4of4) : Attaques AD et Web
Alphorm
 
Projet reseau-de-kherfallah-ipm-2010-2011
Projet reseau-de-kherfallah-ipm-2010-2011
Boubaker KHERFALLAH
 
Rapport de stage à la Banque Marocaine pour le Commerce et l'Industrie (BMCI)
Rapport de stage à la Banque Marocaine pour le Commerce et l'Industrie (BMCI)
Sabrine Aghbal
 
Slide 1 l'ouverture de compte
Slide 1 l'ouverture de compte
bellvita_17
 

Similar to import data from Oracle Database into Python Pandas Dataframe (20)

Python and Oracle : allies for best of data management
Python and Oracle : allies for best of data management
Laurent Leturgez
 
Overview of Oracle Database 18c Express Edition (XE)
Overview of Oracle Database 18c Express Edition (XE)
Todd Bottger
 
20180921_DOAG_BigDataDays_OracleSpatialandPython_kpatenge
20180921_DOAG_BigDataDays_OracleSpatialandPython_kpatenge
Karin Patenge
 
2015 555 kharchenko_ppt
2015 555 kharchenko_ppt
Maxym Kharchenko
 
18c and 19c features for DBAs
18c and 19c features for DBAs
Connor McDonald
 
Importing Data Sets | Importing Data Sets | Importing Data Sets
Importing Data Sets | Importing Data Sets | Importing Data Sets
Ayxanhmdzad
 
Novinky v Oracle Database 18c
Novinky v Oracle Database 18c
MarketingArrowECS_CZ
 
Hyderabad Mar 2019 - Database 18c / 19c
Hyderabad Mar 2019 - Database 18c / 19c
Connor McDonald
 
Pluggable Databases: What they will break and why you should use them anyway!
Pluggable Databases: What they will break and why you should use them anyway!
Guatemala User Group
 
ITOUG 2019 - 18c, 19c features
ITOUG 2019 - 18c, 19c features
Connor McDonald
 
Database Connectivity using Python and MySQL
Database Connectivity using Python and MySQL
devsuchaye
 
Oracle DB 11g R2 Research (Installation, Users and Privileges, Audit Trail, E...
Oracle DB 11g R2 Research (Installation, Users and Privileges, Audit Trail, E...
Duc Lai Trung Minh
 
Download full ebook of Oracle Sql Developer Narayanan Ajith instant download pdf
Download full ebook of Oracle Sql Developer Narayanan Ajith instant download pdf
dakorarampse
 
ROracle
ROracle
Mohamed Magdy
 
pandas.(to/from)_sql is simple but not fast
pandas.(to/from)_sql is simple but not fast
Uwe Korn
 
What's New in Oracle SQL Developer for 2018
What's New in Oracle SQL Developer for 2018
Jeff Smith
 
database-concepts for oracle aasdaasdasadsa
database-concepts for oracle aasdaasdasadsa
deyaamesh1
 
Oracle python pandas merge DataFrames
Oracle python pandas merge DataFrames
Johan Louwers
 
Oracle SQL Developer for the DBA
Oracle SQL Developer for the DBA
Jeff Smith
 
Oracle SQL Developer: 3 Features You're Not Using But Should Be
Oracle SQL Developer: 3 Features You're Not Using But Should Be
Jeff Smith
 
Python and Oracle : allies for best of data management
Python and Oracle : allies for best of data management
Laurent Leturgez
 
Overview of Oracle Database 18c Express Edition (XE)
Overview of Oracle Database 18c Express Edition (XE)
Todd Bottger
 
20180921_DOAG_BigDataDays_OracleSpatialandPython_kpatenge
20180921_DOAG_BigDataDays_OracleSpatialandPython_kpatenge
Karin Patenge
 
18c and 19c features for DBAs
18c and 19c features for DBAs
Connor McDonald
 
Importing Data Sets | Importing Data Sets | Importing Data Sets
Importing Data Sets | Importing Data Sets | Importing Data Sets
Ayxanhmdzad
 
Hyderabad Mar 2019 - Database 18c / 19c
Hyderabad Mar 2019 - Database 18c / 19c
Connor McDonald
 
Pluggable Databases: What they will break and why you should use them anyway!
Pluggable Databases: What they will break and why you should use them anyway!
Guatemala User Group
 
ITOUG 2019 - 18c, 19c features
ITOUG 2019 - 18c, 19c features
Connor McDonald
 
Database Connectivity using Python and MySQL
Database Connectivity using Python and MySQL
devsuchaye
 
Oracle DB 11g R2 Research (Installation, Users and Privileges, Audit Trail, E...
Oracle DB 11g R2 Research (Installation, Users and Privileges, Audit Trail, E...
Duc Lai Trung Minh
 
Download full ebook of Oracle Sql Developer Narayanan Ajith instant download pdf
Download full ebook of Oracle Sql Developer Narayanan Ajith instant download pdf
dakorarampse
 
pandas.(to/from)_sql is simple but not fast
pandas.(to/from)_sql is simple but not fast
Uwe Korn
 
What's New in Oracle SQL Developer for 2018
What's New in Oracle SQL Developer for 2018
Jeff Smith
 
database-concepts for oracle aasdaasdasadsa
database-concepts for oracle aasdaasdasadsa
deyaamesh1
 
Oracle python pandas merge DataFrames
Oracle python pandas merge DataFrames
Johan Louwers
 
Oracle SQL Developer for the DBA
Oracle SQL Developer for the DBA
Jeff Smith
 
Oracle SQL Developer: 3 Features You're Not Using But Should Be
Oracle SQL Developer: 3 Features You're Not Using But Should Be
Jeff Smith
 
Ad

More from Johan Louwers (20)

Multi Domain REST API routing for Data Mesh based Data Products
Multi Domain REST API routing for Data Mesh based Data Products
Johan Louwers
 
TClab Dynamic Solar Panel Positioning Systems
TClab Dynamic Solar Panel Positioning Systems
Johan Louwers
 
Oracle Cloud With Azure DevOps Pipelines
Oracle Cloud With Azure DevOps Pipelines
Johan Louwers
 
Oracle Cloud native functions - create application from cli
Oracle Cloud native functions - create application from cli
Johan Louwers
 
Oracle Labs - research mission & project potfolio
Oracle Labs - research mission & project potfolio
Johan Louwers
 
Install Redis on Oracle Linux
Install Redis on Oracle Linux
Johan Louwers
 
Fn project quick installation guide
Fn project quick installation guide
Johan Louwers
 
Voice assistants for the insurance industry
Voice assistants for the insurance industry
Johan Louwers
 
Enterprise wide publish subscribe with Apache Kafka
Enterprise wide publish subscribe with Apache Kafka
Johan Louwers
 
Industry 4.0 and Oracle Cloud
Industry 4.0 and Oracle Cloud
Johan Louwers
 
Docker and microservices - moving from a monolith to microservices
Docker and microservices - moving from a monolith to microservices
Johan Louwers
 
Cloud native applications for banking
Cloud native applications for banking
Johan Louwers
 
Conversational retail
Conversational retail
Johan Louwers
 
Oracle Cloudday security
Oracle Cloudday security
Johan Louwers
 
Oracle Cloudday - the future of retail
Oracle Cloudday - the future of retail
Johan Louwers
 
Capgemini Oracle Cloud Access Security Broker
Capgemini Oracle Cloud Access Security Broker
Johan Louwers
 
Microservices in the oracle cloud
Microservices in the oracle cloud
Johan Louwers
 
Oracle cloud, private, public and hybrid
Oracle cloud, private, public and hybrid
Johan Louwers
 
RethinkDB on Oracle Linux
RethinkDB on Oracle Linux
Johan Louwers
 
Oracle Cloud Hybrid Storage Tiering
Oracle Cloud Hybrid Storage Tiering
Johan Louwers
 
Multi Domain REST API routing for Data Mesh based Data Products
Multi Domain REST API routing for Data Mesh based Data Products
Johan Louwers
 
TClab Dynamic Solar Panel Positioning Systems
TClab Dynamic Solar Panel Positioning Systems
Johan Louwers
 
Oracle Cloud With Azure DevOps Pipelines
Oracle Cloud With Azure DevOps Pipelines
Johan Louwers
 
Oracle Cloud native functions - create application from cli
Oracle Cloud native functions - create application from cli
Johan Louwers
 
Oracle Labs - research mission & project potfolio
Oracle Labs - research mission & project potfolio
Johan Louwers
 
Install Redis on Oracle Linux
Install Redis on Oracle Linux
Johan Louwers
 
Fn project quick installation guide
Fn project quick installation guide
Johan Louwers
 
Voice assistants for the insurance industry
Voice assistants for the insurance industry
Johan Louwers
 
Enterprise wide publish subscribe with Apache Kafka
Enterprise wide publish subscribe with Apache Kafka
Johan Louwers
 
Industry 4.0 and Oracle Cloud
Industry 4.0 and Oracle Cloud
Johan Louwers
 
Docker and microservices - moving from a monolith to microservices
Docker and microservices - moving from a monolith to microservices
Johan Louwers
 
Cloud native applications for banking
Cloud native applications for banking
Johan Louwers
 
Conversational retail
Conversational retail
Johan Louwers
 
Oracle Cloudday security
Oracle Cloudday security
Johan Louwers
 
Oracle Cloudday - the future of retail
Oracle Cloudday - the future of retail
Johan Louwers
 
Capgemini Oracle Cloud Access Security Broker
Capgemini Oracle Cloud Access Security Broker
Johan Louwers
 
Microservices in the oracle cloud
Microservices in the oracle cloud
Johan Louwers
 
Oracle cloud, private, public and hybrid
Oracle cloud, private, public and hybrid
Johan Louwers
 
RethinkDB on Oracle Linux
RethinkDB on Oracle Linux
Johan Louwers
 
Oracle Cloud Hybrid Storage Tiering
Oracle Cloud Hybrid Storage Tiering
Johan Louwers
 
Ad

Recently uploaded (20)

Best Software Development at Best Prices
Best Software Development at Best Prices
softechies7
 
From Code to Commerce, a Backend Java Developer's Galactic Journey into Ecomm...
From Code to Commerce, a Backend Java Developer's Galactic Journey into Ecomm...
Jamie Coleman
 
Best AI-Powered Wearable Tech for Remote Health Monitoring in 2025
Best AI-Powered Wearable Tech for Remote Health Monitoring in 2025
SEOLIFT - SEO Company London
 
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
Shane Coughlan
 
HYBRIDIZATION OF ALKANES AND ALKENES ...
HYBRIDIZATION OF ALKANES AND ALKENES ...
karishmaduhijod1
 
A Guide to Telemedicine Software Development.pdf
A Guide to Telemedicine Software Development.pdf
Olivero Bozzelli
 
Why Edge Computing Matters in Mobile Application Tech.pdf
Why Edge Computing Matters in Mobile Application Tech.pdf
IMG Global Infotech
 
Which Hiring Management Tools Offer the Best ROI?
Which Hiring Management Tools Offer the Best ROI?
HireME
 
Sap basis role in public cloud in s/4hana.pptx
Sap basis role in public cloud in s/4hana.pptx
htmlprogrammer987
 
Heat Treatment Process Automation in India
Heat Treatment Process Automation in India
Reckers Mechatronics
 
arctitecture application system design os dsa
arctitecture application system design os dsa
za241967
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Advance Doctor Appointment Booking App With Online Payment
Advance Doctor Appointment Booking App With Online Payment
AxisTechnolabs
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Streamlining CI/CD with FME Flow: A Practical Guide
Streamlining CI/CD with FME Flow: A Practical Guide
Safe Software
 
Complete Guideliness to Build an Effective Maintenance Plan.ppt
Complete Guideliness to Build an Effective Maintenance Plan.ppt
QualityzeInc1
 
Introduction to Agile Frameworks for Product Managers.pdf
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
 
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
 
Best Software Development at Best Prices
Best Software Development at Best Prices
softechies7
 
From Code to Commerce, a Backend Java Developer's Galactic Journey into Ecomm...
From Code to Commerce, a Backend Java Developer's Galactic Journey into Ecomm...
Jamie Coleman
 
Best AI-Powered Wearable Tech for Remote Health Monitoring in 2025
Best AI-Powered Wearable Tech for Remote Health Monitoring in 2025
SEOLIFT - SEO Company London
 
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
Shane Coughlan
 
HYBRIDIZATION OF ALKANES AND ALKENES ...
HYBRIDIZATION OF ALKANES AND ALKENES ...
karishmaduhijod1
 
A Guide to Telemedicine Software Development.pdf
A Guide to Telemedicine Software Development.pdf
Olivero Bozzelli
 
Why Edge Computing Matters in Mobile Application Tech.pdf
Why Edge Computing Matters in Mobile Application Tech.pdf
IMG Global Infotech
 
Which Hiring Management Tools Offer the Best ROI?
Which Hiring Management Tools Offer the Best ROI?
HireME
 
Sap basis role in public cloud in s/4hana.pptx
Sap basis role in public cloud in s/4hana.pptx
htmlprogrammer987
 
Heat Treatment Process Automation in India
Heat Treatment Process Automation in India
Reckers Mechatronics
 
arctitecture application system design os dsa
arctitecture application system design os dsa
za241967
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Advance Doctor Appointment Booking App With Online Payment
Advance Doctor Appointment Booking App With Online Payment
AxisTechnolabs
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Streamlining CI/CD with FME Flow: A Practical Guide
Streamlining CI/CD with FME Flow: A Practical Guide
Safe Software
 
Complete Guideliness to Build an Effective Maintenance Plan.ppt
Complete Guideliness to Build an Effective Maintenance Plan.ppt
QualityzeInc1
 
Introduction to Agile Frameworks for Product Managers.pdf
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
 
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
 

import data from Oracle Database into Python Pandas Dataframe

  • 1. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Python Development Example Read data from Oracle Database into Pandas DataFrame Johan Louwers – Chief Customer Architect @ Oracle Version : Feb 2019 @johanlouwers Johanlouwers.blogspot.com Oracle Confidential – Internal/Restricted/Highly Restricted
  • 2. Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 2
  • 3. Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Python Development with pandas and CX_Oracle Slide-deck Intention : • This presentation is intended to provide a quick introduction example on how to load data from an Oracle Database into pandas. • This example is a part of a wider workshop deck and shared as a stand- alone example for ease of sharing. • The code should only be used as an educational example and is not intended to be included in any real- world application code. 3 Contact details : Johan Louwers - Chief Customer Architect @johanlouwers [email protected] github.com/louwersj Johanlouwers.blogspot.com
  • 4. Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | 4 Python Development Pandas – read data from database into DataFrame A B C D 0 A0 B0 C0 D0 1 A1 B1 C1 D1 2 A2 B2 C2 D2 pd.read_sql What do we want to achieve? 1) Read data from an Oracle database into a DataFrame based upon a SQL query. 2) We use cx_Oracle in combination with Oracle Database 18c
  • 5. Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | 5 import pandas as pd import cx_Oracle orclUserName = 'pandas_test' orclPassword = 'pandas_test' orclHost = '192.168.33.10' orclPort = '1521' orclServiceName = 'pdb1' dsn = cx_Oracle.makedsn(host=orclHost, port=orclPort, sid=None, service_name=orclServiceName ) connection = cx_Oracle.connect(user=orclUserName, password=orclPassword, dsn=dsn, encoding="UTF-8", nencoding="UTF-8" ) query = """SELECT * FROM emp""" df_ora = pd.read_sql(query, con=connection) print (df_ora.head()) Import cx_Oracle Provide needed details Define the Data Source Name Define the connection Define the query Execute the read_sql() Python Development Pandas – read data from database into DataFrame
  • 6. Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | 6 Show me the output 1) You can verify the output of df_ora.head() with the content of your database EMP table Python Development Pandas – read data from database into DataFrame
  • 7. Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted 7