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.6.tar.gz
.
File metadata
- Download URL: keboola_streamlit-0.0.6.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7366db85b3810bd05c784d56f01861d7854294ef891115901d46e40c7b2b2559 |
|
MD5 | fdcf52aaa2db4871da7205fd8f3e9927 |
|
BLAKE2b-256 | 195a3df45fa3facb7188eb2be8860f2cb678df93eded4cf57b37c31ebadf3f54 |
File details
Details for the file keboola_streamlit-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: keboola_streamlit-0.0.6-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 | c075ea08fc042da4255ea7234e077ceb4affbc99eb2985a1a218aa01894bd17b |
|
MD5 | f274b1ddad4ee4e0a2d26678adbb750b |
|
BLAKE2b-256 | 9ed733876a398bf880d0833a01b387056fc502bd0a0a5b25fc5a385871305f12 |