You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>Run your Streamlit app as a native object in Snowflake. Enjoy an in-browser editor and minimal work to configure your environment. Share your app with other users in your Snowflake account through role-based access control. This is a great way to deploy apps internally for your business. Check out Snowflake docs!</InlineCallout>
42
+
>Run your Streamlit app as a native object in Snowflake. Enjoy an in-browser editor and minimal work to configure your environment. Share your app with other users in your Snowflake account through role-based access control (RBAC). This is a great way to deploy apps internally for your business. Check out Snowflake docs!</InlineCallout>
>Package your app with data and share it with other Snowflake accounts. This is a great way to share apps and their underlying data with other organizations who use Snowflake so they can run it in their own account. Check out Snowflake docs!</InlineCallout>
48
+
>Package your app with data and share it with other Snowflake accounts. This is a great way to share apps and their underlying data with other organizations who use Snowflake. Check out Snowflake docs!</InlineCallout>
>Deploy your app in a container that's optimized to run in Snowflake. This is the most flexible option where you can use any library. Share your app publicly or privately. Check out Snowflake docs!</InlineCallout>
54
+
>Deploy your app in a container that's optimized to run in Snowflake. This is the most flexible option, where you can use any library and assign a public URL to your app. Manage your allowed viewers through your Snowflake account. Check out Snowflake docs!</InlineCallout>
This guide explains how to securely access a Snowflake database from Streamlit. It uses [st.connection](/develop/api-reference/connections/st.connection), the [Snowpark library](https://docs.snowflake.com/en/developer-guide/snowpark/python/index) and Streamlit's [Secrets management](/develop/concepts/connections/secrets-management).
10
+
This guide explains how to securely access a Snowflake database from Streamlit. It uses [st.connection](/develop/api-reference/connections/st.connection), the [Snowpark library](https://docs.snowflake.com/en/developer-guide/snowpark/python/index), and Streamlit's [Secrets management](/develop/concepts/connections/secrets-management).
11
11
12
12
### Prerequisites
13
13
@@ -20,7 +20,7 @@ This guide explains how to securely access a Snowflake database from Streamlit.
20
20
```
21
21
22
22
<Note>
23
-
Use the correct version of Python required by `snowflake-snowpark-python`. For example, if you use `snowflake-snowpark-python==1.23.0` you must use Python version \>=3.8, \<3.12.
23
+
Use the correct version of Python required by `snowflake-snowpark-python`. For example, if you use `snowflake-snowpark-python==1.23.0`, you must use Python version \>=3.8, \<3.12.
24
24
</Note>
25
25
26
26
- You must have a Snowflake account. To create a trial account, see the [tutorial](/get-started/installation/streamlit-in-snowflake) in _Get started_.
@@ -31,13 +31,13 @@ This guide explains how to securely access a Snowflake database from Streamlit.
31
31
If you already have a database that you want to use, you can [skip to the next step](#add-connection-parameters-to-your-local-app-secrets).
32
32
33
33
1. Sign in to your Snowflake account at [https://app.snowflake.com](https://app.snowflake.com).
34
-
1. In the left navigation, click "**Projects**," then click "**Worksheets**."
34
+
1. In the left navigation, select "**Projects**," and then select "**Worksheets**."
35
35
1. To create a new worksheet, in the upper-right corner, click the plus icon (<i style={{ verticalAlign: "-.25em" }} className={{ class: "material-icons-sharp" }}>add</i>).
36
36
37
37
You can use a worksheet to quickly and conveniently execute SQL statements. This is a great way to learn about and experiment with SQL in a trial account.
38
38
39
-
1. Optional: To rename your worksheet, in the upper-left corner, hover over the tab with your worksheet name, and click the overflow menu icon (<i style={{ verticalAlign: "-.25em" }} className={{ class: "material-icons-sharp" }}>more_vert</i>). Select "**Rename**", enter a new worksheet name (e.g. "Scratchwork"), and press "**Enter**".
40
-
1. To create a new database with a table, in your worksheet's SQL editor, type the following SQL statements, and execute them.
39
+
1. Optional: To rename your worksheet, in the upper-left corner, hover over the tab with your worksheet name, and then click the overflow menu icon (<i style={{ verticalAlign: "-.25em" }} className={{ class: "material-icons-sharp" }}>more_vert</i>). Select "**Rename**", enter a new worksheet name (e.g. "Scratchwork"), and then press "**Enter**".
40
+
1. To create a new database with a table, in your worksheet's SQL editor, type and execute the following SQL statements:
41
41
42
42
```sql
43
43
CREATEDATABASEPETS;
@@ -56,7 +56,7 @@ If you already have a database that you want to use, you can [skip to the next s
56
56
57
57
<Important>
58
58
59
-
If no lines are highlighted and you click the play button, only the line with your cursor will execute.
59
+
If no lines are highlighted and you click the play button, only the line with your cursor will be executed.
60
60
61
61
</Important>
62
62
@@ -75,11 +75,11 @@ If you already have a database that you want to use, you can [skip to the next s
75
75
76
76
Because the SQL statements did not specify a schema, they defaulted to the "PUBLIC" schema within the new "PETS" database. The role and warehouse are trial-account defaults. You can see the role and warehouse used by your worksheet in the upper-right corner, to the left of the "**Share**" and play (<i style={{ verticalAlign: "-.25em" }} className={{ class: "material-icons-sharp" }}>play_arrow</i>) buttons.
77
77
78
-
In Snowflake, databases provide storage and warehouses provide compute. When you configure your connection, you aren't explicitly required to declare role, warehouse, database, and schema; if these are not specified, the connection will use your account defaults. You can also change these settings within an active connection if you need to use multiple roles, warehouses, or databases. However, declaring these defaults avoids unintentional selections.
78
+
In Snowflake, databases provide storage, and warehouses provide compute. When you configure your connection, you aren't explicitly required to declare role, warehouse, database, and schema; if these are not specified, the connection will use your account defaults. If you want to use multiple roles, warehouses, or databases, you can also change these settings within an active connection. However, declaring these defaults avoids unintentional selections.
79
79
80
80
1. To conveniently copy your account identifier, in the lower-left corner, click your profile image, and hover over your account. A popover dialog expands to the right with your organization and account. In the popover, hover over your account, and click the copy icon (<i style={{ verticalAlign: "-.25em", transform: "rotateZ(90deg)" }} className={{ class: "material-icons-sharp" }}>content_copy</i>).
81
81
82
-
The account identifier in your clipboard is period-separated, which is the format used for SQL statements. Paste your account identifier into your notes, and change the period into a hyphen. The Snowflake Connector for Python requires the hyphen-separated format for your account identifier.
82
+
The account identifier in your clipboard is period-separated, which is the format used for SQL statements. However, the Snowflake Connector for Python requires a hyphen-separated format. Paste your account identifier into your notes, and change the period to a hyphen.
83
83
84
84
```toml
85
85
account = "xxxxxxx-xxxxxxx"
@@ -156,7 +156,7 @@ If you already have your connection configured using [Snowflake's connections fi
156
156
157
157
## Write your Streamlit app
158
158
159
-
1. Copy the code below to your Streamlit app and save it. If you are not using the example database and table from the first section of this tutorial, replace the SQL query and results handling as desired.
159
+
1. Copy the following code to your Streamlit app and save it. If you are not using the example database and table from the first section of this tutorial, replace the SQL query and results handling as appropriate.
160
160
161
161
```python
162
162
# streamlit_app.py
@@ -170,7 +170,7 @@ If you already have your connection configured using [Snowflake's connections fi
170
170
st.write(f"{row.NAME} has a :{row.PET}:")
171
171
```
172
172
173
-
The `st.connection` command creates a `SnowflakeConnection` object and handles secrets retrieval. The `.query()` method handles query caching and retries. By default, query results are cached without expiring. Setting `ttl="10m"` ensures the query result is cached for no longer than 10 minutes. To disable caching, you can set `ttl=0` instead. Learn more in [Caching](/develop/concepts/architecture/caching).
173
+
The `st.connection` command creates a `SnowflakeConnection` object and handles secrets retrieval. The `.query()` method handles query caching and retries. By default, query results are cached without expiring. Setting `ttl="10m"` ensures that the query result is cached for no longer than 10 minutes. To disable caching, you can set `ttl=0` instead. Learn more in [Caching](/develop/concepts/architecture/caching).
174
174
175
175
<Note>
176
176
@@ -192,7 +192,7 @@ If you already have your connection configured using [Snowflake's connections fi
The [SnowflakeConnection](/develop/api-reference/connections/st.connections.snowflakeconnection) used above also provides access to [Snowpark sessions](https://docs.snowflake.com/en/developer-guide/snowpark/reference/python/session.html) for dataframe-style operations that run natively inside Snowflake. Using this approach, you can rewrite the app above as follows:
Copy file name to clipboardExpand all lines: content/get-started/installation/sis.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,13 +31,13 @@ All you need is an email address! Everything else happens in your 30-day trial a
31
31
<Image alt="Choose your Snowflake edition, provider, and region" src="/images/get-started/SiS-region.png" />
32
32
</div>
33
33
34
-
1. Answer or skip a few questions to let us know more about yourself.
34
+
1. Answer a few questions to let us know more about yourself, or skip them.
35
35
36
36
1. A message will display: "You're now signed up!" Go to your email, and click on the activation link. (Within your link, note the subdomain. This is your Snowflake account identifier. `https://<account_identifier>.snowflakecomputing.com`)
37
37
38
38
1. Set your username and password. This will be an admin user account within your Snowflake account. Your Snowflake account can have multiple users within it.
39
39
40
-
1. If you are not signed in after setting your password, follow the instructions to enter your Snowflake account identifier, then enter your username and password. If you've accidentally closed your browser, you can log in at [app.snowflake.com](https://app.snowflake.com/).
40
+
1. If you are not signed in after setting your password, follow the instructions to enter your Snowflake account identifier, and then enter your username and password. If you've accidentally closed your browser, you can sign in at [app.snowflake.com](https://app.snowflake.com/).
41
41
42
42
Congratulations! You have a trial Snowflake account.
43
43
@@ -89,7 +89,7 @@ The databases in the above screenshot are as follows:
89
89
- App location: "STREAMLIT_DB" and "PUBLIC"
90
90
- App warehouse: "COMPUTE_WH" (default) or "STREAMLIT_WH" (if you created a new warehouse)
91
91
92
-
If you can't select your database, refresh the page to ensure the interface is displaying current information.
92
+
If you can't select your database, refresh the page to ensure that the interface is displaying current information.
93
93
94
94
1. Click "**Create**." (Note that the app will run with the rights of "ACCOUNTADMIN" for simplicity. You can curate your roles and permissions to choose who can create and access apps.)
95
95
@@ -107,7 +107,7 @@ The databases in the above screenshot are as follows:
107
107
st.write("Hello World")
108
108
```
109
109
110
-
If you want to get back to the sample code later, you can always make another app to edit the same example again.
110
+
If you want to return to the sample code later, you can always make another app to edit the same example again.
111
111
112
112
1. In the upper-right corner, click the blue "<i style={{ verticalAlign: "-.25em" }} className={{ class: "material-icons-sharp" }}>play_arrow</i> **Run**" button to make the running app reflect your changes.
113
113
@@ -135,17 +135,17 @@ The databases in the above screenshot are as follows:
135
135
136
136
1. Optional: Make more edits to your app. You must interact with your app or click the blue "<i style={{ verticalAlign: "-.25em" }} className={{ class: "material-icons-sharp" }}>play_arrow</i> **Run**" button to display the changes. This is different from a local environment where you can save your changes to trigger a rerun.
137
137
138
-
1. To go back to Snowsight, in the upper-left corner, click "<i style={{ verticalAlign: "-.25em" }} className={{ class: "material-icons-sharp" }}>chevron_left</i> **Streamlit Apps**."
138
+
1. To return to Snowsight, in the upper-left corner, click "<i style={{ verticalAlign: "-.25em" }} className={{ class: "material-icons-sharp" }}>chevron_left</i> **Streamlit Apps**."
139
139
140
140
## Return to your app
141
141
142
-
When you want to view or edit your app again, you can return to it through Snowsight. If you are returning to the site, you can log in at [app.snowflake.com](https://app.snowflake.com/).
142
+
When you want to view or edit your app again, you can return to it through Snowsight. If you are returning to the site, you can sign in at [app.snowflake.com](https://app.snowflake.com/).
143
143
144
144
1. In the left navigation, select "**Projects**" → "**Streamlit**."
145
145
146
146
1. In your list of apps, click "**Hello World**."
147
147
148
-
If you don't see your app, check that you have your role set to "ACCOUNTADMIN" as described in [Optional: Create a warehouse](/get-started/installation/streamlit-in-snowflake#optional-create-a-warehouse).
148
+
If you don't see your app, check that your role is set to "ACCOUNTADMIN" as described in [Optional: Create a warehouse](/get-started/installation/streamlit-in-snowflake#optional-create-a-warehouse).
149
149
150
150
1. Your app will open in viewing mode. To edit your app, in the upper-right corner, click "**Edit**."
0 commit comments