train.py 822 B

12345678910111213141516171819202122
  1. """train model"""
  2. import streamlit as st
  3. def create_table(conn):
  4. with conn.session as s:
  5. s.execute('CREATE TABLE IF NOT EXISTS train (position TEXT, trial_num INTEGER, start_time DATETIME, owner_name TEXT);')
  6. s.commit()
  7. def get_trains(conn, sub_name):
  8. trains = conn.query('select * from train where owner_name = :owner', ttl=0.05, params={'owner': sub_name})
  9. return trains
  10. def create_train(conn, train_form):
  11. with conn.session as s:
  12. s.execute(
  13. 'INSERT INTO train (position, trial_num, start_time, owner_name) VALUES (:position, :trial_num, :start_time, :owner_name);',
  14. params=dict(position=train_form['position'], trial_num=train_form['trial_num'], start_time=train_form['start_time'], owner_name=train_form['owner_name'])
  15. )
  16. s.commit()