From 77fc26cd5eddd6bb71ad4543034dee95fad17a6f Mon Sep 17 00:00:00 2001 From: chris Mitchell Date: Wed, 21 Aug 2024 09:25:29 -0400 Subject: [PATCH] Add in simple transactions --- src/main.rs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index bea2e9d..88cc7fe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -242,7 +242,12 @@ fn main() { name, db, shallow, - }) => import_fasta(fasta, name, *shallow, &mut get_connection(db)), + }) => { + let mut conn = get_connection(db); + conn.execute("BEGIN TRANSACTION", []).unwrap(); + import_fasta(fasta, name, *shallow, &mut conn); + conn.execute("END TRANSACTION", []).unwrap(); + } Some(Commands::Update { name, db, @@ -250,13 +255,18 @@ fn main() { vcf, genotype, sample, - }) => update_with_vcf( - vcf, - name, - genotype.clone().unwrap_or("".to_string()), - sample.clone().unwrap_or("".to_string()), - &mut get_connection(db), - ), + }) => { + let mut conn = get_connection(db); + conn.execute("BEGIN TRANSACTION", []).unwrap(); + update_with_vcf( + vcf, + name, + genotype.clone().unwrap_or("".to_string()), + sample.clone().unwrap_or("".to_string()), + &mut conn, + ); + conn.execute("END TRANSACTION", []).unwrap(); + } None => {} } }