Skip to main content

Tools for working with an Oracle database from Pandas

Project description

This package includes methods for:

  1. Running a specified query, passed in as a string, on an Oracle database and returning the result to a Pandas data frame.

  2. Executing a command with no return data.

  3. Inserting the contents of a Pandas data frame into an Oracle database table.


pip install pandas_oracle


Sample usage:

from as oradf

query1 = "select id, name from students where name like '%Oscar%'"
query2 = "select class, avg(age) from students group by class"

## opening conn
conn = oradf.open_connection("config.yml")

## passing the conn object to the query_to_df
df1 = oradf.query_to_df(query, conn, 10000)

## passing the conn object to the query_to_df , without to open again
df2 = oradf.query_to_df(query2, conn, 10)

## close connection


          ID                NAME
0    3298272         Meyer,Oscar
1    2304928         Wilde,Oscar
2    7654321        Grouch,Oscar
.        ...                 ...
128  2234879    De La Hoya,Oscar
129  9872322      Peterson,Oscar
130  9082394       Sanchez,Oscar

[131 rows x 2 columns]

Sample config file:

    username: "OGROUCH"
    password: "SECR3TPASSWORD"
    sysdba: "n"
    host: >
            (DESCRIPTION =
                    (ADDRESS = (PROTOCOL = TCP)
                               (HOST =
                               (PORT = 1521)
                    (CONNECT_DATA = (SERVER = DEDICATED)
                                    (SID = dbname)

If you don’t wish to store your password in the configuration file, you can omit that line. If a password isn’t present in the configuration file, you will be prompted for it at runtime.

You can choose whether or not to connect with the SYSDBA role. If the yaml file doesn’t include the “sysdba” property, it will connect like a normal user.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pandas_oracle-1.2.0.tar.gz (3.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page