Hi,
I’m new to Streamlit and I’m trying to build a web application similar to ETL tools. Below is my Python script which is working, but I have some questions:
- How can I achieve S3 export and Google Drive export using buttons instead of a radio button widget? I know a little bit about
session_state
, but I’m not able to achieve functionality for both S3 export and Google Drive export together. - How do I clear the
col
andcol2
text input fields after the submit button is clicked? Currently, I still see the values after the submit button is clicked. - If the user clicks ‘view jobs’, I’m showing the list of jobs created by the user using
st.data_editor
. How can I add edit and delete buttons for each row in the result so that the user can edit or delete the existing jobs?
Please assist me with these questions. Below is my python script
import streamlit as st
from S3ExportConfig import S3Export
from GdriveExportConfig import GdriveExport
opt = st.radio('Export Type:',['S3_Export','GDrive_Export','HothJobMonitor'])
st.write('<style>div.row-widget.stRadio > div{flex-direction:row;}</style>', unsafe_allow_html=True)
# Functoin from S3Export
def create_new_s3_export():
col, col2 = st.columns(2)
JOB_NAME = col.text_input("JOB_NAME:", key='job_name', placeholder="Name of your Job")
FILE_NAME_PATTERN = col.text_input("FILE_NAME_PATTERN:", key='file_pattern', placeholder="FileName With Extention ex: abc.csv")
BUCKET = col.text_input("BUCKET:", key='bucket', placeholder="S3 Bucket ex: eait-wwce-dw-etl-preprod")
TARGET_PATH = col.text_input("TARGET_PATH:", key='target_path', placeholder="Please Enter Target File Path...")
JOB_DESC = col2.text_input("JOB_DESCRIPTION:", key='job_desc', placeholder="Job Description")
CLIENT_KEY = col2.text_input("CLIENT_KEY:", key='client_key', placeholder="Please Enter S3 client key...", type="password")
SECRET_TOKEN = col2.text_input("SECRET_TOKEN:", key='secret_token', placeholder="Please Enter S3 Secret Token...", type="password")
BUCKET_REGION = col2.text_input("BUCKET_REGION:", key='bucket_region', placeholder="AWS Region ex: us-east-1")
data = [JOB_NAME, FILE_NAME_PATTERN, BUCKET, TARGET_PATH, JOB_DESC, CLIENT_KEY, SECRET_TOKEN, BUCKET_REGION]
if st.button("Submit"):
ret_val = insert_data_into_database()
if ret_val:
<clear all my text_input>
else:
<dont clear>
if opt == 'S3_Export':
s3exp = S3Export()
opt_val = st.radio('Options:', ['Create new s3_export', 'View Jobs'])
if opt_val == 'Create new s3_export':
s3exp.create_new_s3_export()
elif opt_val == 'View Jobs':
s3exp.view_jobs('username')
elif opt == 'GDrive_Export':
gdr_exp = GdriveExport()
opt_val = st.radio('Options:', ['Create new Gdrive_export', 'View Jobs'])
if opt_val == 'Create new gdrive_export':
gdr_exp.create_new_gdrive_export()
elif opt_val == 'View Jobs':
gdr_exp.view_jobs('username')