aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.zig2
-rw-r--r--build.zig.zon1
-rw-r--r--src/main.zig7
3 files changed, 6 insertions, 4 deletions
diff --git a/build.zig b/build.zig
index 37ceb1d..bf8170b 100644
--- a/build.zig
+++ b/build.zig
@@ -15,7 +15,7 @@ pub fn build(b: *std.Build) void {
lib.addIncludePath(.{ .path = "/usr/include" });
// for zig package manager
- _ = b.addModule("pq", .{ .source_file = .{ .path = "src/main.zig" } });
+ _ = b.addModule("pq", .{ .root_source_file = .{ .path = "src/main.zig" } });
b.installArtifact(lib);
diff --git a/build.zig.zon b/build.zig.zon
index c1e91ab..275ae8d 100644
--- a/build.zig.zon
+++ b/build.zig.zon
@@ -1,4 +1,5 @@
.{
.name = "pq",
.version = "0.0.1",
+ .paths = .{""},
} \ No newline at end of file
diff --git a/src/main.zig b/src/main.zig
index a4fc382..df6b2c9 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -14,7 +14,7 @@ pub const Db = struct {
std.log.err("PQisthreadsafe returned 0, can't use libpq in this program", .{});
return PqError.PqError;
}
- var maybe_conn: ?*pq.PGconn = pq.PQconnectdb(connect_url);
+ const maybe_conn: ?*pq.PGconn = pq.PQconnectdb(connect_url);
if (maybe_conn == null) {
std.log.err("PQconnectdb returned null", .{});
return PqError.PqError;
@@ -37,9 +37,9 @@ pub const Db = struct {
}
pub fn exec(self: Db, query: [:0]const u8) !void {
- var res: ?*pq.PGresult = pq.PQexec(self.c_conn, query);
+ const res: ?*pq.PGresult = pq.PQexec(self.c_conn, query);
defer pq.PQclear(res);
- var est: pq.ExecStatusType = pq.PQresultStatus(res);
+ const est: pq.ExecStatusType = pq.PQresultStatus(res);
if (est != pq.PGRES_COMMAND_OK) {
std.log.err("PQexec error code {} message {s}", .{ est, pq.PQerrorMessage(self.c_conn) });
return PqError.PqError;
@@ -149,3 +149,4 @@ pub fn addZ(comptime length: usize, value: [length]u8) [length:0]u8 {
@memcpy(&terminated_value, &value);
return terminated_value;
}
+