Learn how to build Python web applications using Streamlit, connect SQLite database and develop real-time mini projects using Python backend logic.
Start Learning
Python UI Development Framework
Streamlit is a Python library used to build web applications easily using Python code.
It helps developers create attractive UI applications without HTML or JavaScript.
pip install streamlit
streamlit run app.py
Create Your First UI Application
Streamlit provides simple functions to create headings, messages and UI components.
import streamlit as st
st.title("My First App")
st.write("Welcome Students")
Read User Data
Streamlit provides input components to read data from users.
name = st.text_input("Enter Name")
st.write(name)
marks = st.number_input("Enter Marks")
st.write(marks)
Database Connectivity Using Python
SQLite is a lightweight database available directly in Python.
It helps store and retrieve data from applications.
import sqlite3
con = sqlite3.connect("student.db")
cursor = con.cursor()
cursor.execute( "CREATE TABLE IF NOT EXISTS student( id INTEGER PRIMARY KEY, name TEXT )" ) con.commit()
cursor.execute(
"insert into student(name) values(?)",
("Ravi",)
)
con.commit()
cursor.execute("select * from student")
data = cursor.fetchall()
print(data)
Student Marks Management System
This application accepts student marks, calculates total marks and stores data into SQLite database.
import streamlit as st
import sqlite3
con = sqlite3.connect("student.db")
cursor = con.cursor()
cursor.execute(
"CREATE TABLE IF NOT EXISTS student_marks(
id integer primary key autoincrement,
name TEXT,
marks INTEGER
)"
)
con.commit()
st.title("Student Marks Management System")
name = st.text_input("Enter Student Name")
s1 = st.number_input("Enter Subject 1 Marks")
s2 = st.number_input("Enter Subject 2 Marks")
s3 = st.number_input("Enter Subject 3 Marks")
total_marks = s1 + s2 + s3
if st.button("Save Data"):
cursor.execute(
"insert into student_marks(name, marks) values(?,?)",
(name, total_marks)
)
con.commit()
st.success("Data Stored Successfully")
if st.button("View Data"):
cursor.execute("select * from student_marks")
data = cursor.fetchall()
st.dataframe(data)
con.close()