Created
October 23, 2015 14:53
-
-
Save t0mst0ne/825f0511bc5e20925481 to your computer and use it in GitHub Desktop.
Using python with cx_Oracle to query Oracle and transform to pandas dataframe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#coding:UTF-8 | |
# Be sure to install the correct version of Oracle library | |
# https://gist.github.com/kimus/10012910 | |
import pandas as pd | |
import pandas.io.sql as psql | |
import cx_Oracle | |
import os | |
os.environ["NLS_LANG"] = "AMERICAN_AMERICA.AL32UTF8" | |
dsn_tns = cx_Oracle.makedsn('IP', 1521, 'name') | |
ora_conn = cx_Oracle.connect('user/pass',dsn=dsn_tns) | |
df1 = psql.read_sql('SELECT * FROM table', con=ora_conn) | |
ora_conn.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment