Step 1: Load the ‘pyodbc’ and ‘pandas’ Python Libraries

import pyodbc
import pandas as pd


Step 2: Establish a Connection with the Server Named ‘FBMSCBIDB-DEV02’ and Incidcate the Database (i.e., folder from inside the database)

cnxn = pyodbc.connect('Driver={ODBC Driver 17 for SQL Server};'
                      'Server=FBMSCBIDB-DEV02;' 
                      'Database=DW_WCSI_DEV;'
                      'Trusted_Connection=yes;')


To pull datasets from WCSI use ‘DW_WCSI_DEV’ as the Database for connection


Step 3: Pull a Dataset or Run SQL Queries from the Microsoft SQL Database

dt = pd.read_sql_query('select * from VW_RATE_AUTOLINE', cnxn)

Step 4: Begin Data Analysis/Exploration/Manipulation

# get the shape of the data
dt.shape
# get column names
dt.columns
# preview dt
dt.head(5)