In [2]:
import pandas
import pyodbc
In [3]:
def query(sql):
    con = pyodbc.connect('DRIVER=ODBC Driver 17 for SQL Server;SERVER=.\SQLEXPRESS;DATABASE=AdventureWorks;UID=mike;PWD=password')
    return pandas.read_sql(sql, con)
In [8]:
df = query ("SELECT * FROM FactProductInventory")
df.head()
Out[8]:
ProductKey DateKey MovementDate UnitCost UnitsIn UnitsOut UnitsBalance
0 1 20101228 2010-12-28 0.32 0 0 875
1 1 20101229 2010-12-29 0.32 0 0 875
2 1 20101230 2010-12-30 0.32 0 0 875
3 1 20101231 2010-12-31 0.32 0 0 875
4 1 20110101 2011-01-01 0.32 0 0 875
In [18]:
import matplotlib
%matplotlib inline

df['UnitCost'].hist();
In [ ]: