aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2022-03-19 16:19:26 +0100
committerTeddy Wing2022-03-19 16:19:26 +0100
commitbb9f0ee38809ab0b41d66ced950c034101862a59 (patch)
tree87e5330f2e6fd78dd970aa754169e6047025a7dd
parent38f70de064fd9ed1e66a5da4007e7364a4a7d363 (diff)
downloadyaqlite-bb9f0ee38809ab0b41d66ced950c034101862a59.tar.bz2
main: If `primary_key` option is given, select by given column name
-rw-r--r--src/lib.rs2
-rw-r--r--src/main.rs15
2 files changed, 15 insertions, 2 deletions
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();
},