From bb9f0ee38809ab0b41d66ced950c034101862a59 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 19 Mar 2022 16:19:26 +0100 Subject: main: If `primary_key` option is given, select by given column name --- src/lib.rs | 2 +- src/main.rs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 3f6151e..4f1b44d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ pub mod sqlite; pub mod yaml; -pub use select::select; +pub use select::*; #[derive(thiserror::Error, Debug)] diff --git a/src/main.rs b/src/main.rs index d3c286b..6c87a0b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,7 +79,20 @@ fn main() { } => { let dbconn = rusqlite::Connection::open(database).unwrap(); - yaqlite::select(&dbconn, &table_name, &record_id).unwrap(); + match primary_key { + Some(pk) => yaqlite::select_by_column( + &dbconn, + &table_name, + &pk, + &record_id, + ).unwrap(), + + None => yaqlite::select( + &dbconn, + &table_name, + &record_id, + ).unwrap(), + }; dbconn.close().unwrap(); }, -- cgit v1.2.3