A Python library that simplifies Keboola SAPI integration in Streamlit apps.
Project description
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 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)
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)
License
This project is licensed under the MIT License. See the LICENSE
file for more details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file keboola_streamlit-0.0.7.tar.gz
.
File metadata
- Download URL: keboola_streamlit-0.0.7.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c73c21d2e927dbf7c99c38967fb247b77bc92c710351dddacc667fe662a512c7 |
|
MD5 | 87e8bccdbc6ead123d9dce037bc78f31 |
|
BLAKE2b-256 | a7715c040b7993321687b7ac7c76d4e270ba4b332011a2a5e0a50e8b1507b332 |
File details
Details for the file keboola_streamlit-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: keboola_streamlit-0.0.7-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 810f916bcc9a3ea35577cc812bf23d4b46b38da7527d82097f9bdb561c87a26c |
|
MD5 | f4cd8704352a4c9eef80f2f97f2ee3ab |
|
BLAKE2b-256 | 5eabd3307bdbf861c837200602165703c1c2bbbd89dbf34f4abf6f53ed3244af |