✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Issue with Dropdown from SQL

Hey All,

I am having some issues with dropdowns and sql, i want to fill the dropdown with options from sql.

I’m not getting any errors, but all I am getting in the dropdown is just the name of the column in the database which is sale category.

This is the SQL elsewhere to pull my data:

def get_saletype_data():
    con = sqlite3.connect(str(DBFILE))
    saletypes = pd.read_sql_query("SELECT SaleCategory FROM SaleType", con)
    return saletypes

And this is what it produces if i print the output:

  SaleCategory
0          Cut
1   Highlights
2    Gel Nails
3         Perm
4   Extensions
5       Fringe

Here is the code in the app dealing with the sql:

salelist = get_saletype_data()
saletypedic = salelist.to_dict()

This is the code for the dropdown:

dcc.Dropdown(
                    id="sales-type-dropdown",
                    options=[{'label':saletype, 'value':saletype} for saletype in saletypedic],
                ),

Really appreciate any help on this, not sure why I am just getting the first option in the dropdown