Skip to content

Commit a0b298b

Browse files
committed
Create Connect to data sources.md
1 parent ff52877 commit a0b298b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Connect to data sources.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
These Streamlit snippets illustrate how to establish experimental connections and create a custom connection class:
2+
3+
**Establishing connections:**
4+
5+
st.experimental_connection('pets_db', type='sql')
6+
sets up an experimental connection named 'pets_db' of type SQL.
7+
8+
conn = st.experimental_connection('sql')
9+
retrieves the experimental SQL connection.
10+
11+
conn = st.experimental_connection('snowpark')
12+
retrieves the experimental Snowpark connection.
13+
14+
**Creating a custom connection class:**
15+
16+
The code defines a custom connection class `MyConnection` inheriting from `ExperimentalBaseConnection[myconn.MyConnection]`.
17+
18+
_connect()
19+
method establishes a connection using custom parameters and returns an instance of `MyConnection`.
20+
21+
query()
22+
method executes a query using the connection instance.
23+
24+
This code demonstrates Streamlit's experimental features for establishing and customizing connections to databases and other data sources.

0 commit comments

Comments
 (0)