Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import pypyodbc
- q0 = '''
- select *
- from weatherview x
- where x.WeatherNodeRCIKey IN (481, 562, 563, 561, 564, 565, 560, 658)
- and x.WeatherDate >= '01-jan-2016'
- '''
- try:
- con = pypyodbc.connect(driver='{Oracle in OraClient11g_home1}',
- server='oracle', uid='acct', pwd='Pass', dbq='table')
- with con:
- cur = con.cursor()
- cur.execute(q0)
- q0_rows = cur.fetchall()
- q0_hdnm = [i[0] for i in cur.description]
- except Exception as e:
- print("Error: " + str(e))
- df0 = pd.DataFrame(q0_rows, columns=q0_hdnm)
- df0.head()
- import pandas as pd
- import cx_Oracle
- q0 = '''
- select *
- from weatherview_historical x
- where x.WeatherNodeRCIKey IN (481, 562, 563, 561, 564, 565, 560, 658)
- and x.WeatherDate >= '01-jan-2016'
- and x.WeatherTypeLu in (6436,6439)
- '''
- try:
- #establish connection with profit (oracle) db
- con = cx_Oracle.connect(user='uid', password='pass', dsn='dsn_name')
- df0 = pd.read_sql_query(q0, con)
- except Exception as e:
- #return error message
- print("Error: " + str(e))
Add Comment
Please, Sign In to add comment