| ... | @@ -9,6 +9,19 @@ const Self = @This(); | ... | @@ -9,6 +9,19 @@ const Self = @This(); |
| 9 | db: *c.sqlite3, | 9 | db: *c.sqlite3, |
| 10 | | 10 | |
| 11 | pub fn connect(allocator: std.mem.Allocator, path: [:0]const u8) !Self { | 11 | pub fn connect(allocator: std.mem.Allocator, path: [:0]const u8) !Self { |
| | 12 | var driver: Self = try .connect_only(allocator, path); |
| | 13 | errdefer driver.close(); |
| | 14 | _ = try driver.first(allocator, void, "PRAGMA journal_mode = WAL", .{}); |
| | 15 | _ = try driver.first(allocator, void, "PRAGMA busy_timeout = 5000", .{}); |
| | 16 | _ = try driver.first(allocator, void, "PRAGMA synchronous = NORMAL", .{}); |
| | 17 | _ = try driver.first(allocator, void, "PRAGMA cache_size = 1000000000", .{}); |
| | 18 | _ = try driver.first(allocator, void, "PRAGMA foreign_keys = true", .{}); |
| | 19 | _ = try driver.first(allocator, void, "PRAGMA temp_store = memory", .{}); |
| | 20 | _ = try driver.first(allocator, void, "PRAGMA mmap_size = 1073741824", .{}); |
| | 21 | _ = try driver.first(allocator, void, "PRAGMA auto_vacuum = INCREMENTAL", .{}); |
| | 22 | return driver; |
| | 23 | } |
| | 24 | pub fn connect_only(allocator: std.mem.Allocator, path: [:0]const u8) !Self { |
| 12 | std.log.scoped(.zorm).info("connecting to {s} @ {s}", .{ "sqlite3", path }); | 25 | std.log.scoped(.zorm).info("connecting to {s} @ {s}", .{ "sqlite3", path }); |
| 13 | _ = allocator; | 26 | _ = allocator; |
| 14 | var db: ?*c.sqlite3 = null; | 27 | var db: ?*c.sqlite3 = null; |