12345678910111213141516171819202122 |
- """subject model"""
- import streamlit as st
- def create_table(conn):
- with conn.session as s:
- s.execute('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(
- '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()
|