# How to create a static table in dash?

**URL:** https://community.plotly.com/t/how-to-create-a-static-table-in-dash/14372
**Category:** Dash Python
**Created:** [October 9, 2018, 10:48am UTC](https://community.plotly.com/t/how-to-create-a-static-table-in-dash/14372 "2018-10-09T10:48:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![kristada619](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/kristada619/32/4363_2.png) [@kristada619](https://community.plotly.com/u/kristada619)
#### Post date: [October 9, 2018, 10:48am UTC](https://community.plotly.com/t/how-to-create-a-static-table-in-dash/14372/1 "2018-10-09T10:48:13Z")

</div>

I have a dash app where a table should be displayed depending on the user input in a textbox. But when I run my code, the table is not displayed. Here is the relevant part of my code:

```
import dash
from dash.dependencies import Output, Event, Input
import dash_core_components as dcc
import dash_html_components as html
import plotly
import plotly.graph_objs as go
import pandas as pd
import sqlite3
import requests

app = dash.Dash()

app.layout = html.Div(children=[

	html.Div([
        dcc.Input(id='input', placeholder='Enter the input...', type='text')
    ]),

	html.Div([
        html.Div(id='my-table'),
        dcc.Interval(
            id='table-update',
            interval=2*1000
        ),
    ])
])

@app.callback(Output('my-table', 'children'),
              [Input(component_id='input', component_property='value')],
              events=[Event('table-update', 'interval')])        
def update_recent_tweets(input_data):
    conn = sqlite3.connect('database.db')
    c = conn.cursor()
    df = pd.read_sql("SELECT * FROM Col1 WHERE Col2 LIKE ? ORDER BY Col3 DESC LIMIT 10", conn, params=('%' + input_data + '%',))

    trace = go.Table(
        header=dict(values=list(df.columns),
                    fill = dict(color='#C2D4FF'),
                    align = ['left'] * 5),
        cells=dict(values=[df.Col1, df.Col2, df.Col3],
                   fill = dict(color='#F5F8FF'),
                   align = ['left'] * 5))

    return {'data':[trace]}

if __name__ == ' __main__':
    app.run_server(debug=True)

```

The error it gives says the input cannot be found in the database. But its there in it, I know because my app has some more plots, and the other plots dependent on the same input work fine. What’s wrong with the table code?

---

<div class="post-metadata">

### Author: ![caiyij](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/caiyij/32/4462_2.png) [@caiyij](https://community.plotly.com/u/caiyij)
#### Post date: [October 17, 2018, 8:43pm UTC](https://community.plotly.com/t/how-to-create-a-static-table-in-dash/14372/2 "2018-10-17T20:43:09Z")

</div>

The code below would work. So I think instead of `return {'data':[trace]}`, you should write `dcc.Graph(figure = go.Figure(data = trace))`

```auto
app = dash.Dash( __name__ )
server=app.server

trace=[go.Table(
    ...
    )]

app.layout = html.Div([
    dcc.Graph(figure = go.Figure(data = trace))
])

if __name__ == ' __main__':
    app.run_server(debug=True)

```
