KeboolaStreamlit
KeboolaStreamlit simplifies the use of Keboola Storage API within Streamlit apps, providing easy-to-use functions for authentication, data retrieval, event logging, and data loading.
Installation
To install:
pip install keboola-streamlit
If you also need the Snowflake Integration functions, install the
snowflake extra:
pip install keboola-streamlit[snowflake]
If you are using streamlit<=1.36.0, please use version 0.0.5 of the keboola-streamlit package.
Usage
Import and Initialization
Create an instance of the KeboolaStreamlit class, and initialize it with the required parameters from Streamlit secrets:
import streamlit as st
from keboola_streamlit import KeboolaStreamlit
URL = st.secrets["KEBOOLA_URL"]
TOKEN = st.secrets["STORAGE_API_TOKEN"]
keboola = KeboolaStreamlit(root_url=URL, token=TOKEN)
Authentication and Authorization
If only selected roles can access the app, make sure the user is authorized by:
ROLE_ID = st.secrets["REQUIRED_ROLE_ID"]
keboola.auth_check(required_role_id=ROLE_ID)
Add a logout button to your app:
keboola.logout_button(sidebar=True, use_container_width=True)
💡 You can find more about authorization settings in Keboola here.
Reading Data from Keboola Storage
Read data from a Keboola Storage table and return it as a Pandas DataFrame:
df = keboola.read_table(table_id='YOUR_TABLE_ID')
💡 Wrap the function and use the st.cache_data decorator to prevent your data from being read every time you interact with the app. Learn more about caching here.
Writing Data to Keboola Storage
Write data from a Pandas DataFrame to a Keboola Storage table:
keboola.write_table(table_id='YOUR_TABLE_ID', df=your_dataframe, is_incremental=False)
Creating Events
Create an event in Keboola Storage to log activities:
keboola.create_event(message='Streamlit App Create Event', event_type='keboola_data_app_create_event')
Table Selection
Add a table selection interface in your app:
df = keboola.add_table_selection(sidebar=True)
Snowflake Integration
Requires the
snowflakeextra:pip install keboola-streamlit[snowflake]
Creating a Snowflake Session
To interact with Snowflake, first create a session using your Streamlit secrets. Ensure that the following secrets are set in your Streamlit configuration:
SNOWFLAKE_USERSNOWFLAKE_ACCOUNTSNOWFLAKE_ROLESNOWFLAKE_WAREHOUSESNOWFLAKE_DATABASESNOWFLAKE_SCHEMA
For authentication you can use password:
SNOWFLAKE_PASSWORD
Or key-pair:
SNOWFLAKE_PRIVATE_KEYSNOWFLAKE_PRIVATE_KEY_PASSPHRASE(Optional)
Streamlit will automatically use type of authorization based on what you fill in secrets.
NOTE: If both password and key-pair are filled in secrets, Streamlit by default will use the key-pair authorization.
Then, create the session as follows:
st.session_state['snowflake_session'] = keboola.snowflake_create_session_object()
Reading Data from Snowflake
Load a table from Snowflake into a Pandas DataFrame:
df_snowflake = keboola.snowflake_read_table(session=st.session_state['snowflake_session'], table_id='YOUR_SNOWFLAKE_TABLE_ID')
Executing a Snowflake Query
Execute a SQL query on Snowflake and optionally return the results as a DataFrame:
query = "SELECT * FROM YOUR_SNOWFLAKE_TABLE"
df_query_result = keboola.snowflake_execute_query(session=st.session_state['snowflake_session'], query=query, return_df=True)
Writing Data to Snowflake
Write a Pandas DataFrame to a Snowflake table:
keboola.snowflake_write_table(session=st.session_state['snowflake_session'], df=your_dataframe, table_id='YOUR_SNOWFLAKE_TABLE_ID')
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Metadata
Release files for keboola_streamlit 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| keboola_streamlit-0.2.0.tar.gz | 8.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| keboola_streamlit-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.1 kB
Release files / keboola_streamlit-0.2.0.tar.gz
| Download URL | keboola_streamlit-0.2.0.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
083bc47c03a1d033f03efb943eaf350fdf769a2b35cd928a4ecb78eacf2353b3
|
|
BLAKE2b-256 checksum How to use checksums |
f170e6a00b69287f1684510cdb4232885af60cde85d996399eb1902b37c113d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / keboola_streamlit-0.2.0-py3-none-any.whl
| Download URL | keboola_streamlit-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
674790325ab4fbe5dcb081de145ffbb2f361a5f7d9fda087491f2df625e63f5d
|
|
BLAKE2b-256 checksum How to use checksums |
57f02fb93a13177b0f9d803bd4bd92b7bfc6fb34a82a12095149f4e265c5b308
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for keboola_streamlit 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.