"""subject model""" import streamlit as st from sqlalchemy.sql import text def create_table(conn): with conn.session as s: s.execute(text('CREATE TABLE IF NOT EXISTS subject (name TEXT, gender TEXT, birthday DATE, create_time DATETIME);')) s.commit() def get_subjects(conn): subjects = conn.query('select * from subject', ttl=0.05) return subjects def create_subject(conn, subject_form): with conn.session as s: s.execute( text('INSERT INTO subject (name, gender, birthday, create_time) VALUES (:name, :gender, :birthday, :create_time);'), params=dict(name=subject_form['name'], gender=subject_form['gender'], birthday=subject_form['birthday'], create_time=subject_form['create_time']) ) s.commit()