From ac7bcafae3b9cdb75a9df35a9ab8e37adb1eb192 Mon Sep 17 00:00:00 2001 From: jvech Date: Fri, 26 Apr 2024 08:48:06 -0500 Subject: add: insertion of data checked --- src/database.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/database.rs b/src/database.rs index 6a7bde0..8321723 100644 --- a/src/database.rs +++ b/src/database.rs @@ -1,5 +1,6 @@ use rusqlite::Connection; use rusqlite::Result; +use rusqlite::config::DbConfig::{*}; use chrono::Utc; use std::path::PathBuf; @@ -22,7 +23,7 @@ impl Database { pub fn add_register(&self, filepath: &PathBuf) -> Result<()> { let conn = Connection::open(filepath)?; - conn.execute("PRAGMA foreign_key=1", ())?; + conn.set_db_config(SQLITE_DBCONFIG_ENABLE_FKEY, true)?; conn.execute(" INSERT INTO Registers (agent_id, register_date, amount, note) VALUES ( @@ -56,7 +57,7 @@ impl Database { conn.execute(" CREATE TABLE Registers ( id INTEGER PRIMARY KEY, - agent_id INTEGER, + agent_id INTEGER NOT NULL, register_date INTEGER NOT NULL, amount INTEGER NOT NULL, note TEXT, -- cgit v1.2.3-70-g09d2