diff options
author | Teddy Wing | 2022-03-12 22:12:45 +0100 |
---|---|---|
committer | Teddy Wing | 2022-03-12 22:12:45 +0100 |
commit | 8dd59ee6fee0f023a75d4657ad07f6f09b14fc9c (patch) | |
tree | b2334bfef45beaa3d2b5a0570b52f943354edd3c /src/lib.rs | |
parent | 2388395752fbd56b8e1213ff60ccb2a40d23c806 (diff) | |
download | yaqlite-8dd59ee6fee0f023a75d4657ad07f6f09b14fc9c.tar.bz2 |
Add an `insert()` function for inserting YAML in database
Make an interface that more cleanly says "insert this YAML into this
database".
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -1,2 +1,19 @@ pub mod sqlite; pub mod yaml; + + +pub fn insert( + dbconn: &mut rusqlite::Connection, + table_name: &str, + data: &mut [yaml_rust::Yaml], +) { + let table_columns = crate::sqlite::get_column_names(&dbconn, table_name); + + for mut doc in data { + let tx = dbconn.transaction().unwrap(); + + crate::yaml::extract(&mut doc, &tx, &table_columns); + + tx.commit().unwrap(); + } +} |