In [3]:
# import the library - if you are getting an error install pyodbc from terminal using the line below
# pip install pyodbc --proxy="httpproxy.munich.munichre.com:3128"

import pyodbc
import pandas as pd

# create a connection with SQL server you may need to change the driver if you are getting an erro ,
conn = pyodbc.connect('DRIVER={SQL Server};SERVER=wtk-crouch;DATABASE=Ladder Data;')

#sql query to run in sql 
query = 'SELECT * FROM vw_Output_Data'

#reading the sql query and placing the output in df cariable
df= pd.read_sql(query, conn)

# closing the connection -- !important
conn.close()
In [4]:
# view the top 5 rows of your data 
df.head()
Out[4]:
Lookup LookupClass LookupRG LookupSCC Class Reserving Group Ladders SCC Service Company YOA Development Quarter CTDP Signed Premium CTDP Paid Claims CTDP OS Claims CTDP Signed Premium Conv CTDP Paid Claims Conv CTDP OS Claims Conv
0 Accident & HealthCADLON20088 A&H20088 Accident & Health20088 Accident & HealthCAD20088 A&H Accident & Health CAD LON 2008 8 1039411.25 767578.69 113554.84 637062.00 470453.95 69598.54
1 Accident & HealthCADLON200811 A&H200811 Accident & Health200811 Accident & HealthCAD200811 A&H Accident & Health CAD LON 2008 11 983975.68 757398.71 2503.38 603085.16 464214.56 1534.39
2 Accident & HealthCADLON200814 A&H200814 Accident & Health200814 Accident & HealthCAD200814 A&H Accident & Health CAD LON 2008 14 983975.68 751838.07 179.52 603085.16 460806.39 110.09
3 Accident & HealthCADLON200837 A&H200837 Accident & Health200837 Accident & HealthCAD200837 A&H Accident & Health CAD LON 2008 37 983916.29 751838.12 0.00 603048.76 460806.42 0.05
4 Accident & HealthCADLON200840 A&H200840 Accident & Health200840 Accident & HealthCAD200840 A&H Accident & Health CAD LON 2008 40 983916.29 751838.12 0.00 603048.76 460806.42 0.05