From 2c5cf2d65bbf91cdba00f52dfe7624a7a3a97d6c Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Fri, 2 Aug 2024 20:47:27 +0200 Subject: Move queries to conn --- src/duckdb/db.zig | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/duckdb/db.zig') diff --git a/src/duckdb/db.zig b/src/duckdb/db.zig index 41cfe67..4b5ebe3 100644 --- a/src/duckdb/db.zig +++ b/src/duckdb/db.zig @@ -24,12 +24,17 @@ const Connection = struct { /// Query returning a result. Caller needs to call result.deinit() pub fn query(self: *Connection, q: [:0]const u8, comptime res_type: type) !Result(res_type) { - return try Result(res_type).init(self._conn, q); + var result: c.duckdb_result = undefined; + const state = c.duckdb_query(self._conn, q, &result); + if ( state == c.DuckDBError ){ + return error.DuckDBError; + } + return try Result(res_type).init(result); } /// Query with no results and autoclean pub fn run(self: *Connection, q: [:0]const u8) !void{ - var x = try Result(void).init(self._conn, q); + var x = try self.query(q, void); defer x.deinit(); } }; -- cgit v1.2.3