Fixes for passing in sqlite file name
This commit is contained in:
+4
-2
@@ -11,9 +11,11 @@ pub const Db = struct {
|
||||
_mode: ?sqlite.Db.Mode,
|
||||
_sql_db: sqlite.Db,
|
||||
|
||||
pub fn init(allocator: Allocator, mode: ?sqlite.Db.Mode) !Db {
|
||||
pub fn init(allocator: Allocator, db_path: ?[]const u8, mode: ?sqlite.Db.Mode) !Db {
|
||||
const path: [:0]const u8 = if (db_path != null) try std.mem.Allocator.dupeZ(allocator, u8, db_path.?) else "./data.db";
|
||||
defer allocator.free(path);
|
||||
var sqlDb = try sqlite.Db.init(.{
|
||||
.mode = if (mode != null) mode.? else sqlite.Db.Mode{ .File = "./data.db" },
|
||||
.mode = if (mode != null) mode.? else sqlite.Db.Mode{ .File = path },
|
||||
.open_flags = .{
|
||||
.write = true,
|
||||
.create = true,
|
||||
|
||||
Reference in New Issue
Block a user