From 17ecc483cf725f370d0bceda414fec4aed8dc331 Mon Sep 17 00:00:00 2001 From: Kenta Iwasaki Date: Fri, 27 Aug 2021 03:43:30 +0900 Subject: sqlite: interpret database path in init flags as uri To avoid the need for introducing multiple sqlite.Mode's for addressing all the different possible ways one may initialize a SQLite database, enable the flag SQLITE_OPEN_URI by default. This allows for initialization options which are not addressed by InitFlags as of yet, such as the option to initialize a shared in-memory SQLite database instance that may be shared across connections in the same address space, to be set via. URI query parameters. e.g. sqlite.Db.init({ .mode = .{ .File = "file:hello.db?mode=memory&cache=shared" }, .open_flags = .{ .create = true, .write = true }, .threading_mode = .MultiThread, }); --- sqlite.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sqlite.zig') diff --git a/sqlite.zig b/sqlite.zig index e88fb64..0a19fea 100644 --- a/sqlite.zig +++ b/sqlite.zig @@ -328,7 +328,7 @@ pub const Db = struct { } // Compute the flags - var flags: c_int = 0; + var flags: c_int = c.SQLITE_OPEN_URI; flags |= @as(c_int, if (options.open_flags.write) c.SQLITE_OPEN_READWRITE else c.SQLITE_OPEN_READONLY); if (options.open_flags.create) { flags |= c.SQLITE_OPEN_CREATE; -- cgit v1.2.3