CREATE STREAMLIT¶
Creates a new Streamlit application object in Snowflake or replaces an existing Streamlit application object in the same schema.
Syntax¶
CREATE [ OR REPLACE ] STREAMLIT [ IF NOT EXISTS ] <name>
FROM <source_location>
MAIN_FILE = '<path_to_main_file_in_root_directory>'
QUERY_WAREHOUSE = <warehouse_name>
[ COMMENT = '<string_literal>' ]
[ TITLE = '<app_title>' ]
[ IMPORTS = ( '<stage_path_and_file_name_to_read>' [ , ... ] ) ]
[ EXTERNAL_ACCESS_INTEGRATIONS = ( <integration_name> [ , ... ] ) ]
[ ROOT_LOCATION = '<stage_path_and_root_directory>' ]
Required parameters¶
name
Specifies the identifier (i.e. name) for the Streamlit object. This identifier must be unique for the schema in which the table is created.
In addition, the identifier must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (e.g.
"My object"
). Identifiers enclosed in double quotes are also case-sensitive.For more details, see Identifier requirements.
FROM source_location
Copies the source files from the specified location to initialize the app. This happens once. For example,
FROM @streamlit_db.streamlit_schema.streamlit_stage
.MAIN_FILE = 'path_to_main_file_in_root_directory'
Specifies the filename of the Streamlit Python application. This filename is relative to the value of
ROOT_LOCATION
.QUERY_WAREHOUSE = warehouse_name
Specifies the warehouse to run SQL queries issued by the Streamlit application.
Note
If you’re creating or replacing a Streamlit application object within the Snowflake Native App Framework, the
QUERY_WAREHOUSE
parameter is optional.
Optional parameters¶
COMMENT = 'string_literal'
Specifies a comment for the Streamlit object.
DEFAULT: No value
TITLE = 'app_title'
Specifies a title for the Streamlit app to display in Snowsight.
IMPORTS = ( 'stage_path_and_file_name_to_read' [ , ... ] )
The location (stage), path, and name of the file(s) to import.
EXTERNAL_ACCESS_INTEGRATIONS = ( integration_name [ , ... ] )
The names of external access integrations needed in order for the Streamlit app code to access external networks.
ROOT_LOCATION = 'stage_path_and_root_directory'
Important
ROOT_LOCATION
is a legacy parameter. Snowflake recommends usingFROM source_location
.For Streamlit apps created using ROOT_LOCATION, multi-file editing and Git integration are not supported.
Specifies the full path to the named stage containing the Streamlit Python files, media files, and the
environment.yml
file, for example:ROOT_LOCATION = '@streamlit_db.streamlit_schema.streamlit_stage'
In this example, the Streamlit files are located on a named stage named
streamlit_stage
within a database namedstreamlit_db
and schema namedstreamlit_schema
.Note
This parameter must point to a single directory inside a named internal stage.
External stages are not supported for Streamlit in Snowflake.
If you’re creating or replacing a Streamlit application object within the Snowflake Native App Framework, use
FROM 'relative_path_from_stage_root_directory'
and notROOT_LOCATION = 'stage_path_and_root_directory'
.
Usage notes¶
When you clone a schema or database containing a Streamlit object, the Streamlit object is not cloned.
To specify the packages used by the Streamlit application, use an
environment.yml
file.Regarding metadata:
Attention
Customers should ensure that no personal data (other than for a User object), sensitive data, export-controlled data, or other regulated data is entered as metadata when using the Snowflake service. For more information, see Metadata fields in Snowflake.
The
OR REPLACE
andIF NOT EXISTS
clauses are mutually exclusive. They can’t both be used in the same statement.CREATE OR REPLACE <object> statements are atomic. That is, when an object is replaced, the old object is deleted and the new object is created in a single transaction.
Examples¶
To create a Streamlit app from a stage, run the CREATE STREAMLIT command, as shown in the following example:
CREATE STREAMLIT hello_streamlit
FROM @streamlit_db.streamlit_schema.streamlit_stage
MAIN_FILE = 'streamlit_main.py'
QUERY_WAREHOUSE = my_warehouse;
To create a Streamlit app from a Git repository, run the CREATE STREAMLIT command, as shown in the following example:
CREATE STREAMLIT hello_streamlit
FROM @streamlit_db.streamlit_schema.streamlit_repo/branches/streamlit_branch/
MAIN_FILE = 'streamlit_main.py'
QUERY_WAREHOUSE = my_warehouse;