Skip to content

Commit

Permalink
Add ability to directly run sql on the database
Browse files Browse the repository at this point in the history
This is a hack intended to allow for the manual addition of indexes
by users of holmes, since holmes does not know which indices to make.
  • Loading branch information
maurer committed Oct 18, 2017
1 parent 837c8ea commit 5eeebd9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@ impl Engine {
}
}

pub fn run_sql(&self, path: &str) {
use std::io::Read;
let mut fd = ::std::fs::File::open(path).unwrap();
let mut sql = String::new();
fd.read_to_string(&mut sql);
let conn = self.fact_db.conn().unwrap();
conn.batch_execute(&sql).unwrap();
}

/// Dump profiling information for how much time was spent in each rule
pub fn dump_profile(&self) -> Vec<RuleProfile> {
self.rule_profiles.iter().map(|x| x.borrow().clone()).collect()
Expand Down

0 comments on commit 5eeebd9

Please sign in to comment.