Skip to content

Instantly share code, notes, and snippets.

@pablocastelo
Created November 23, 2016 18:35
Show Gist options
  • Save pablocastelo/1b5b065a3fb478145797a7f09c4aa70b to your computer and use it in GitHub Desktop.
Save pablocastelo/1b5b065a3fb478145797a7f09c4aa70b to your computer and use it in GitHub Desktop.
import pandas as pd
import cx_Oracle
ora_conn = cx_Oracle.connect('your_connection_string')
df_ora = pd.read_sql('select * from user_objects', con=ora_conn)
print 'loaded dataframe from Oracle. # Records: ', len(df_ora)
ora_conn.close()
import MySQLdb
mysql_cn= MySQLdb.connect(host='myhost',
port=3306,user='myusername', passwd='mypassword',
db='information_schema')
df_mysql = pd.read_sql('select * from VIEWS;', con=mysql_cn)
print 'loaded dataframe from MySQL. records:', len(df_mysql)
mysql_cn.close()
import sqlite3
with sqlite3.connect("whatever.sqlite") as con:
sql = "SELECT * FROM table_name"
df = pd.read_sql_query(sql, con)
print df.shape
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment