test.py 1.0 KB

123456789101112131415161718192021222324252627
  1. """train model"""
  2. import streamlit as st
  3. from sqlalchemy.sql import text
  4. def create_table(conn):
  5. with conn.session as s:
  6. s.execute(text('CREATE TABLE IF NOT EXISTS test (position TEXT, finger_model TEXT, start_time DATETIME, owner_name TEXT, model_path TEXT);'))
  7. s.commit()
  8. def get_tests(conn, sub_name):
  9. tests = conn.query('select * from test where owner_name = :owner', ttl=0.05, params={'owner': sub_name})
  10. return tests
  11. def create_test(conn, test_form):
  12. with conn.session as s:
  13. s.execute(
  14. text('INSERT INTO test (position, finger_model, start_time, owner_name, model_path) VALUES (:position, :finger_model, :start_time, :owner_name, :model_path);'),
  15. params=dict(position=test_form['position'],
  16. finger_model=test_form['finger_model'],
  17. start_time=test_form['start_time'],
  18. owner_name=test_form['owner_name'],
  19. model_path=test_form['model_path'])
  20. )
  21. s.commit()