Created
October 9, 2021 02:24
Revisions
-
dunithd created this gist
Oct 9, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ import psycopg2 import pandas.io.sql as sqlio import pandas as pd import dash from dash import dcc from dash import html import plotly.express as px app = dash.Dash(__name__) # Connect to an existing database conn = psycopg2.connect("dbname=materialize user=materialize port=6875 host=localhost") sql = "select * from sales_by_customer;" df = pd.read_sql_query(sql, conn) fig = px.bar(df, x="customer_id", y="total_order_value") # Main UI scaffolding app.layout = html.Div(children=[ html.H1(children='Sales by customer'), html.Div(children=''' Dash: A web application framework for your data. '''), dcc.Graph( id='bar-chart', figure=fig ) ]) if __name__ == '__main__': app.run_server(debug=True) conn = None