1234567891011121314151617181920212223242526272829 |
- """train 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 train (position TEXT, finger_model TEXT, trial_num INTEGER, start_time DATETIME, owner_name TEXT, virtual_feedback_rate FLOAT, model_path TEXT);'))
- s.commit()
- def get_trains(conn, sub_name):
- trains = conn.query('select * from train where owner_name = :owner', ttl=0.05, params={'owner': sub_name})
- return trains
- def create_train(conn, train_form):
- with conn.session as s:
- s.execute(
- text('INSERT INTO train (position, finger_model, trial_num, start_time, owner_name, virtual_feedback_rate, model_path) VALUES (:position, :finger_model, :trial_num, :start_time, :owner_name, :virtual_feedback_rate, :model_path);'),
- params=dict(position=train_form['position'],
- finger_model=train_form['finger_model'],
- trial_num=train_form['trial_num'],
- start_time=train_form['start_time'],
- owner_name=train_form['owner_name'],
- virtual_feedback_rate=train_form['virtual_feedback_rate'],
- model_path=train_form['model_path'])
- )
- s.commit()
|