streamlit-keboola-api
Streamlit custom component wrapping Keboola python client to list tables, buckets, delete table, delete bucket and upload files to stage.
Installation instructions
pip install streamlit-keboola-api
Usage instructions
from io import StringIO
import os
import streamlit as st
from pathlib import Path
import keboola_api as kb
def saveFile(uploaded):
with open(os.path.join(os.getcwd(),uploaded.name),"w") as f:
strIo= StringIO(uploaded.getvalue().decode("utf-8"))
f.write(strIo.read())
return os.path.join(os.getcwd(),uploaded.name)
def main():
st.write("# Keboola upload button")
st.write("## A Streamlit Custom component")
with st.expander("Keboola Tables"):
tables=kb.keboola_table_list(
keboola_URL="https://connection.north-europe.azure.keboola.com",
keboola_key='<key>',
# Button Label
label="GET TABLES",
# Key is mandatory and has to be unique
key="zero"
# if api_only= True than the button is not shown and the api call is fired directly
api_only=False
)
st.selectbox("Tables",options= list(map(lambda v: v['id'], tables)))
with st.expander("Keboola Buckets"):
buckets=kb.keboola_bucket_list(
keboola_URL="https://connection.north-europe.azure.keboola.com",
keboola_key='<key>',
# Button Label
label="GET BUCKETS",
# Key is mandatory and has to be unique
key="one"
# if api_only= True than the button is not shown and the api call is fired directly
api_only=False
)
st.selectbox("Buckets",options= list(map(lambda v: v['id'], buckets)))
url = "http://www.dickimaw-books.com/latex/admin/html/examples/booklist.csv"
st.write("Get a sample CSV here [link](%s)" % url)
fl=st.file_uploader("Drop a csv...",type="csv")
if hasattr(fl,'name'):
# Streamlit uploader doesn't save the file to disk, only in mem.
# We need to save the file to disk to send it to Keboola python client
fpath=saveFile(fl)
with st.expander("Keboola Upload files"):
value = kb.keboola_upload(
keboola_URL="https://connection.north-europe.azure.keboola.com",
keboola_key='<key>',
keboola_table_name="test-anthony",
keboola_bucket_id='in.c-streamlit_output',
keboola_file_path=fpath,
keboola_primary_key=['id'],
# Button Label
label="UPLOAD FILE",
# Key is mandatory and has to be unique
key="two"
# if api_only= True than the button is not shown and the api call is fired directly
api_only=False
)
value
Metadata
Release files for streamlit-keboola-api 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 | |
|---|---|---|---|
| streamlit-keboola-api-0.2.0.tar.gz | 73.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| streamlit_keboola_api-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 145.7 kB
Release files / streamlit-keboola-api-0.2.0.tar.gz
| Download URL | streamlit-keboola-api-0.2.0.tar.gz |
|---|---|
| Size | 73.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
62497e7e87bd9c83001c3257ea074bbf8366f9c31cf7e4692f7df4baea43d01f
|
|
BLAKE2b-256 checksum How to use checksums |
3f61f45064a4829d03c80d3b5a798cefe735ad395b11f1318922994b4edcb42a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.0
|
Release files / streamlit_keboola_api-0.2.0-py3-none-any.whl
| Download URL | streamlit_keboola_api-0.2.0-py3-none-any.whl |
|---|---|
| Size | 72.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
59ecd6b0061ff0fd2064b3baff1c1c8f61fa3d934a35a3ab2b1984da3b277328
|
|
BLAKE2b-256 checksum How to use checksums |
8c74844a8ea358e3fd933009854c7488535eeab49b4ae26a5707275fc681aca0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.0
|