diff options
author | jvech <jmvalenciae@unal.edu.co> | 2024-04-26 08:48:06 -0500 |
---|---|---|
committer | jvech <jmvalenciae@unal.edu.co> | 2024-04-26 08:48:06 -0500 |
commit | ac7bcafae3b9cdb75a9df35a9ab8e37adb1eb192 (patch) | |
tree | 08d8db0b1a78ddb5c108fa7429fa2977a62af9f2 /src | |
parent | a5dfd2627853bd67e9d17ef870fc84be312b1397 (diff) |
add: insertion of data checked
Diffstat (limited to 'src')
-rw-r--r-- | src/database.rs | 5 |
1 files changed, 3 insertions, 2 deletions
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, |