Posts

Showing posts with the label dash

Unable To Plot Graph From PostgreSQL Query Results In Dash App

Unable To Plot Graph From PostgreSQL Query Results In Dash App I am attempting to write a simple code to simply plot a bar graph of some fruit names in the x-axis vs corresponding sales units. The aim of this code is just to understand how to query postgres results from heroku hosted database through a dash app. Below is the code, from dash import dash import dash_core_components as dcc import dash_html_components as html import plotly.graph_objs as go import psycopg2 import os DATABASE_URL = os.environ['DATABASE_URL'] conn = psycopg2.connect(DATABASE_URL, sslmode='require') cur = conn.cursor() cur.execute("SELECT fruits FROM pgrt_table") fruits1=cur.fetchall() #print(fruits1) cur.execute("SELECT sales FROM pgrt_table") sales1=cur.fetchall() app = dash.Dash() app.layout = html.Div(children=[ html.H1( children='Hello Dash' ), html.Div( children='''Dash: A web application framework for Python.''...