Wrapper around Kebolla python client to list tables, buckets and upload files to stage
Project description
streamlit-keboola-api
Streamlit custom component wrapping Keboola python client to list tables, buckets 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
key="zero"
)
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
key="one"
)
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
action="UPLOAD FILE",
# Key is mandatory
key="two"
)
value
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
Close
Hashes for streamlit-keboola-api-0.1.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e05a1cd4e7c7945881d0b557af47536de9a12c45bb596cc6dc0d7190b130f49 |
|
MD5 | 6183cab7b5f6419f8f5c7adafb6b8c41 |
|
BLAKE2b-256 | 8a96c9a7276cd96c0cee5e747675fd461bf3d5f18aa5f61fa71ed8b107e8ee31 |
Close
Hashes for streamlit_keboola_api-0.1.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10c1f029dba7a7cf6dff9af2799ba26ce79dab0207613e6989b50cd07d17a13f |
|
MD5 | 0d2307d8e59562abcf9a232f9e33939a |
|
BLAKE2b-256 | 68d5bea0f5181a883de16e9cf840a980b39cab796bc42e612975c79b17f1d2b5 |