Create website with form and backend data

Hi All,

I am trying to develop a website where:
1 the visitor can answer a series of questions hosted on a form
2 the data generated, can be stored in a SQL or some database
3 i can extract the data, run some analytics automatically in python

Does Streamlit offer the functionality to do all of the above?

Yes , You can create the form and connect it to the backend data.

Check the attached link for the reference :- Tutorial

Here am using csv file but you can use any database and export data as csv file to analyze in future

import streamlit as st
import pandas as pd
import os
st.title("Form Data to CSV")
with st.form("user_input_form"):
    st.write("Enter your answers:")
    name = st.text_input("Name")
    age = st.number_input("Age", min_value=0, max_value=150)
    email = st.text_input("Email")
    submit_button = st.form_submit_button("Submit")
csv_file_path = "user_answers.csv"
data = pd.DataFrame(columns=["Name", "Age", "Email"])
if os.path.exists(csv_file_path):
    data = pd.read_csv(csv_file_path)
if submit_button:
    new_row = {"Name": name, "Age": age, "Email": email}
    data = pd.concat([data, pd.DataFrame([new_row])], ignore_index=True)
    data.to_csv(csv_file_path, index=False)
    st.success("Answers submitted successfully!")
st.write("Current data:")
st.write(data)
st.download_button(
        label="Download CSV File",
        data=data.to_csv(index=False).encode("utf-8"),
        file_name="user_answers.csv",
        mime="text/csv",
    )