Skip to content

Instantly share code, notes, and snippets.

View phillipsj's full-sized avatar

Jamie Phillips phillipsj

View GitHub Profile
@phillipsj
phillipsj / Dockerfile
Last active October 17, 2020 01:19
Dockerfile for restoring an AdventureWorks2017 database.
# Adventure Works Database on SQL Server 2019
FROM mcr.microsoft.com/mssql/server:2019-CU5-ubuntu-18.04
# Note: This isn't a secure password, and please don't use this for production.
ENV SA_PASSWORD=ThisIsAReallyCoolPassword123
ENV ACCEPT_EULA=Y
# Setting the user
USER mssql
@phillipsj
phillipsj / execute-dash.sh
Last active October 13, 2020 16:21
Executing the dash python app
$ python app.py
Dash is running on http://127.0.0.1:8050/
* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
@phillipsj
phillipsj / app.py
Created October 13, 2020 15:57
Complete Dash Tutorial file.
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
import pandas as pd
from sqlalchemy import create_engine
app = dash.Dash(__name__)
engine = create_engine(
@phillipsj
phillipsj / app.py
Created October 13, 2020 15:56
Main method for Dash tutorial
if __name__ == '__main__':
app.run_server(debug=True)
@phillipsj
phillipsj / app.py
Created October 13, 2020 15:56
Creating layout for Dash tutorial
app.layout = html.Div(children=[
html.H1(children='Adventure Works Sales Report'),
html.Div(children='''
YTD Sales by Individual.
'''),
dcc.Graph(
id='sales-graph',
figure=salesFigure
@phillipsj
phillipsj / app.py
Created October 13, 2020 15:55
Create figures for Dash tutorial
salesFigure = px.bar(df, x="Name", y="SalesYTD", color="Name", barmode="group")
quotaFigure = px.bar(df, x="Name", y="SalesQuota", color="Name", barmode="group")
@phillipsj
phillipsj / app.py
Created October 13, 2020 15:55
Create Pandas Dataframe for Dash tutorial
df = pd.read_sql(query, engine)
@phillipsj
phillipsj / app.py
Last active October 13, 2020 15:54
Dash tutorial query
query = '''
SELECT CONCAT([FirstName],' ', [LastName]) as FullName,
[SalesQuota],
[SalesYTD]
FROM [Sales].[vSalesPerson]
'''
@phillipsj
phillipsj / app.py
Created October 13, 2020 15:53
Create SQL Alchemy Engine
engine = create_engine(
"mssql+pyodbc://sa:ThisIsAReallyCoolPassword123@localhost:1633/AdventureWorks2019?driver=ODBC+Driver+17+for+SQL+Server")
@phillipsj
phillipsj / app.py
Created October 13, 2020 15:53
Creating dash application.
app = dash.Dash(__name__)