✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

I am trying to connect my sqlite database table to dash

Hello everyone, I am trying to connect my sqlite database table to dash as well as displaying the table in my dash. However, there is an error “sqlite3.OperationalError: no such table: information” but I have already created the table information.

Heres my code:

import pandas as pd
import dash
import dash_table
import dash_html_components as html
import sqlite3

conn = sqlite3.connect('databasename.db')
cursor =conn.cursor()
cursor.execute('SELECT A,B,C,D,E FROM informtion')

df = pd.read_sql("SELECT A,B,C,D,E FROM information",conn)

app = dash.Dash(__name__)

app.layout = html.Div([

    html.H1("This is a random table", style={'text-align': 'center'}),

    dash_table.DataTable(
    id='table',
    columns=[{"name": i, "id": i} for i in df.columns],
    data=df.to_dict('records'),
)])

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

What happend if you print the df before the app = dash.Dash?

Hi there, it still shows me the same error.

I found my typo “informtion” but when I correct it to information. It’s still showing me that “sqlite3.OperationalError: no such table: information”

it seems that it is not a Dash issue but sqlite3.
Be sure that you have the table or that you are working in the same folder where the database is.

ok, thank you for the help :slight_smile: