streamlit / streamlit

Streamlit — A faster way to build and share data apps.
https://streamlit.io
Apache License 2.0
35.22k stars 3.05k forks source link

st.experimental_connection. Missing SQL DB connection configuration #6599

Closed bnxvs closed 1 year ago

bnxvs commented 1 year ago

Checklist

Summary

StreamlitAPIException: Missing SQL DB connection configuration. Did you forget to set this in secrets.toml or as kwargs to st.experimental_connection?

Traceback: File "/Users/bnx/Desktop/R work/streamlit_tests/main.py", line 41, in conn = st.experimental_connection("sql")

Reproducible Code Example

import streamlit as st

conn = st.experimental_connection("sql")
df = conn.query('select * from user_reports')
st.table(df)

''' in /.streamlit/secrets.toml

[connection.sql]
dialect = "mysql"
username = "user"
password = "password"
host = "127.0.0.1"
database = "mydb"
'''

Steps To Reproduce

No response

Expected Behavior

No response

Current Behavior

No response

Is this a regression?

Debug info

Additional Information

No response

Are you willing to submit a PR?

sfc-gh-kjavadyan commented 1 year ago

Hey, @bnxvs ! Thanks for opening this issue

Looks like there is just a typo in secrets.toml

https://docs.streamlit.io/library/api-reference/connections/st.connections.sqlconnection

# .streamlit/secrets.toml
[connections.sql]
dialect = "mysql"
username = "user"
password = "password"
host = "127.0.0.1"
database = "mydb"

should work correctly

Please note that the section name is connectionS.sql

bnxvs commented 1 year ago

Oops... I'm sorry. It's my mistake. Thank you!