feat: zig-sqlite.

This commit is contained in:
2026-04-24 17:26:20 -04:00
parent 8d1b0ffa2d
commit 41944af80c
36 changed files with 22057 additions and 1 deletions

26
src/db.zig Normal file
View File

@@ -0,0 +1,26 @@
const std = @import("std");
const sqlite = @import("sqlite");
test "simple database can be opened" {
var db = try sqlite.Db.init(.{
.mode = sqlite.Db.Mode{ .File = "./fixtures/example.db" },
.open_flags = .{
.write = false,
.create = false,
},
.threading_mode = .MultiThread,
});
var stmt = try db.prepare("SELECT * FROM hello");
defer stmt.deinit();
const alloc = std.testing.allocator;
if (try stmt.oneAlloc(struct { text: []const u8 }, alloc, .{}, .{})) |got| {
defer alloc.free(got.text);
try std.testing.expectEqualSlices(u8, "world!", got.text);
} else {
return error.TestUnexpectedResult;
}
}

View File

@@ -56,6 +56,10 @@ pub const root: Command = .new(.{
},
});
test {
std.testing.refAllDecls(@import("db.zig"));
}
test "enum type" {
const got: root.Type = @enumFromInt(2);