add sqlite and a test command (lose WASI support, see note)
With this commit, we lose WASI. This is ok here, because it's not like we're going to be saving our data on sqlite inside a Cloudflare worker. The problem actually doesn't seem to be compilation, but runtime. wasmtime complains that too many locals are defined when sqlite is compiled into this
This commit is contained in:
parent
35d9e78623
commit
79eac7d4f0
|
@ -76,7 +76,16 @@ pub fn build(b: *std.Build) !void {
|
|||
.optimize = optimize,
|
||||
});
|
||||
const aws_signing_module = aws_dep.module("aws-signing");
|
||||
const sqlite_dep = b.dependency("sqlite", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.use_bundled = true,
|
||||
});
|
||||
const sqlite_module = sqlite_dep.module("sqlite");
|
||||
for (&[_]*std.Build.Step.Compile{ exe, unit_tests }) |cs| {
|
||||
cs.addModule("aws-signing", aws_signing_module);
|
||||
cs.addModule("sqlite", sqlite_module);
|
||||
cs.addIncludePath(.{ .path = "c" });
|
||||
cs.linkLibrary(sqlite_dep.artifact("sqlite"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
.url = "https://git.lerch.org/lobo/aws-sdk-for-zig/archive/825d93720a92bcaedb3d00cd04764469fdec0c86.tar.gz",
|
||||
.hash = "122038e86ca453cbb0b4d5534380470eeb0656fdbab9aca2b7d2dc77756ab659204a",
|
||||
},
|
||||
.sqlite = .{
|
||||
.url = "https://github.com/vrischmann/zig-sqlite/archive/19535aab5760eeaf2979a9dadfca3bb21d1594b9.tar.gz",
|
||||
.hash = "12208c654deea149cee27eaa45d0e6515c3d8f97d775a4156cbcce0ff424b5d26ea3",
|
||||
},
|
||||
.universal_lambda_build = .{
|
||||
.url = "https://git.lerch.org/lobo/universal-lambda-zig/archive/d8b536651531ee95ceb4fae65ca5f29c5ed6ef29.tar.gz",
|
||||
.hash = "1220de5b5f23fddb794e2e735ee8312b9cd0d1302d5b8e3902f785e904f515506ccf",
|
||||
|
|
|
@ -1,9 +1,19 @@
|
|||
const std = @import("std");
|
||||
const sqlite = @import("sqlite");
|
||||
|
||||
pub fn handler(allocator: std.mem.Allocator, event_data: []const u8) ![]const u8 {
|
||||
_ = event_data;
|
||||
var db = try sqlite.Db.init(.{
|
||||
.mode = sqlite.Db.Mode{ .File = "donotuse.db" },
|
||||
.open_flags = .{
|
||||
.write = true,
|
||||
.create = true,
|
||||
},
|
||||
.threading_mode = .MultiThread,
|
||||
});
|
||||
try db.exec("CREATE TABLE user(id integer primary key, age integer, name text)", .{}, .{});
|
||||
var al = std.ArrayList(u8).init(allocator);
|
||||
var writer = al.writer();
|
||||
try writer.print("hello\n", .{});
|
||||
try writer.print("table created\n", .{});
|
||||
return al.items;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user