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, 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
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.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62497e7e87bd9c83001c3257ea074bbf8366f9c31cf7e4692f7df4baea43d01f |
|
MD5 | 109855d6b1fca2dabf2adf273e601bc8 |
|
BLAKE2b-256 | 3f61f45064a4829d03c80d3b5a798cefe735ad395b11f1318922994b4edcb42a |
Close
Hashes for streamlit_keboola_api-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59ecd6b0061ff0fd2064b3baff1c1c8f61fa3d934a35a3ab2b1984da3b277328 |
|
MD5 | 114be14e1834652789fe5feb4656ad74 |
|
BLAKE2b-256 | 8c74844a8ea358e3fd933009854c7488535eeab49b4ae26a5707275fc681aca0 |