Getting started with Streamlit in Snowflake

This topic walks you through deploying your first Streamlit in Snowflake app in under five minutes using a container runtime. After that, two hands-on examples show you how to build real apps that query data, personalize the experience for each viewer, and write back to Snowflake.

先决条件

Before you can create a Streamlit app, ensure that your administrator has completed the essential security setup for Streamlit apps.

您的角色必须拥有以下权限:

PrivilegeObjectNotes
USAGEDatabase where you create the Streamlit app
CREATE STREAMLIT, USAGESchema where you create the Streamlit app
USAGECompute pool that runs the Streamlit appFor all accounts, Snowflake configures a general-purpose compute pool that typical users will have access to. For more information, see Configuring your own preferred compute pools for Streamlit apps.
USAGEWarehouse that runs queries in the Streamlit app

For more information, see Privileges required to create and use a Streamlit app.

Deploy your first Streamlit in Snowflake app

最快速的入门方式是使用默认的入门代码创建一个 Streamlit 应用。当您在不指定源文件的情况下创建应用程序时,Snowflake 会自动提供示例代码。

  1. Sign in to Snowsight.
  2. In the navigation menu, select Projects » Streamlit.
  3. Select + Streamlit App.
  4. 输入应用程序的名称。
  5. 选择要在其中创建应用程序的数据库和架构。
  6. Select Run on container.
  7. 选择计算池和查询仓库。
  8. Select Create.

Snowsight redirects you to the app editor. Your app will be ready within a few minutes. Then, you can view and edit it immediately.

编辑应用程序

部署后,您可以编辑应用程序代码以对其进行自定义。快速测试方法如下:

  1. Sign in to Snowsight.
  2. In the navigation menu, select Projects » Streamlit, and then select your app.
  3. Select Edit.
  4. Modify the code in streamlit_app.py.
  5. Select Run to see your changes.

For more information, see Edit your Streamlit app.

下一步是什么?

现在您已经有了一个正在运行的应用程序,请尝试以下实践示例之一:

要了解有关特定主题的更多信息,请执行以下操作: