Don't lock database operations to a single thread

This commit is contained in:
Ethan O'Brien
2025-11-30 10:48:16 -06:00
parent b9b344b50c
commit fd47262f52
5 changed files with 80 additions and 98 deletions

View File

@@ -25,8 +25,8 @@ pub struct Live {
pub master_pass: i64,
}
fn setup_tables(conn: &SQLite) {
conn.lock_and_exec("CREATE TABLE IF NOT EXISTS lives (
fn setup_tables(conn: &rusqlite::Connection) {
conn.execute_batch("CREATE TABLE IF NOT EXISTS lives (
live_id INT NOT NULL PRIMARY KEY,
normal_failed BIGINT NOT NULL,
normal_pass BIGINT NOT NULL,
@@ -36,11 +36,11 @@ fn setup_tables(conn: &SQLite) {
expert_pass BIGINT NOT NULL,
master_failed BIGINT NOT NULL,
master_pass BIGINT NOT NULL
)", params!());
conn.lock_and_exec("CREATE TABLE IF NOT EXISTS scores (
);
CREATE TABLE IF NOT EXISTS scores (
live_id INT NOT NULL PRIMARY KEY,
score_data TEXT NOT NULL
)", params!());
);").unwrap();
}
fn update_live_score(id: i64, uid: i64, score: i64) {