From 2ae96654f769bee10636fa81699e1708295f9ae6 Mon Sep 17 00:00:00 2001 From: Vincent Rischmann Date: Thu, 31 Dec 2020 21:00:16 +0100 Subject: readme: document prepareWithDiags --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index f1f2e09..1551cc0 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,19 @@ defer stmt.deinit(); The `Db.prepare` method takes a `comptime` query string. +### Diagnostics + +If you want failure diagnostics you can use `prepareWithDiags` like this: + +```zig +var diags = sqlite.Diagnostics{}; +var stmt = db.prepareWithDiags(query, .{ .diags = &diags }) catch |err| { + std.log.err("unable to prepare statement, got error {s}. diagnostics: {s}", .{ err, diags }); + return err; +}; +defer stmt.deinit(); +``` + ## Executing a statement For queries which do not return data (`INSERT`, `UPDATE`) you can use the `exec` method: -- cgit v1.2.3