sqlitegraph/config/
sqlite.rs1use std::collections::HashMap;
4
5#[derive(Clone, Debug, Default)]
7pub struct SqliteConfig {
8 pub without_migrations: bool,
10 pub cache_size: Option<usize>,
12 pub pragma_settings: HashMap<String, String>,
14}
15
16impl SqliteConfig {
17 pub fn new() -> Self {
19 Self::default()
20 }
21
22 pub fn with_migrations_disabled(mut self, without_migrations: bool) -> Self {
24 self.without_migrations = without_migrations;
25 self
26 }
27
28 pub fn with_cache_size(mut self, cache_size: usize) -> Self {
30 self.cache_size = Some(cache_size);
31 self
32 }
33
34 pub fn with_pragma(mut self, key: &str, value: &str) -> Self {
36 self.pragma_settings
37 .insert(key.to_string(), value.to_string());
38 self
39 }
40
41 pub fn with_wal_mode(mut self) -> Self {
43 self.pragma_settings
44 .insert("journal_mode".to_string(), "WAL".to_string());
45 self
46 }
47
48 pub fn with_performance_mode(mut self) -> Self {
50 self.pragma_settings
51 .insert("journal_mode".to_string(), "WAL".to_string());
52 self.pragma_settings
53 .insert("synchronous".to_string(), "NORMAL".to_string());
54 self
55 }
56}