A Python library that simplifies Keboola SAPI integration in Streamlit apps.
Project description
KeboolaStreamlit
Keboola Streamlit 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 KeboolaStreamlit, you can use pip
:
pip install keboola-streamlit
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"]
ROLE_ID = st.secrets["REQUIRED_ROLE_ID"]
keboola = KeboolaStreamlit(root_url=URL, token=TOKEN)
Authentication and Authorization
Ensure that the user is authenticated and authorized to access the Streamlit app:
keboola.auth_check(required_role_id=ROLE_ID)
Add a logout button to your Streamlit 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')
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="Custom Event Message", event_type="custom_event")
Table Selection
Add a table selection interface in your Streamlit app:
df = keboola.add_table_selection(sidebar=True)
Logout Button
Add a logout button to your app:
keboola.logout_button()
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.5.tar.gz
.
File metadata
- Download URL: keboola_streamlit-0.0.5.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66d448d67f81537a098bc41a539be685a6a197f6958cb21df987da73455b5e9c |
|
MD5 | 34573359dc636e72b2abf2ee703375cf |
|
BLAKE2b-256 | 3002db5905ca9c6d1015a4d8f4b8e9ad565e975c208506d7e634e353f75f360a |
File details
Details for the file keboola_streamlit-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: keboola_streamlit-0.0.5-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f9cf8ac5411ee89c34fcc33ba9fafb02dec896ec77024431f16376cd28dbb04 |
|
MD5 | af4eba4ad0922c167eefeea58f9cfb79 |
|
BLAKE2b-256 | 0e8006eeed491e7bbb447367e94917313742084c7d5f5f5c8727536c506579d8 |