diff options
| author | 2020-12-31 21:00:16 +0100 | |
|---|---|---|
| committer | 2021-02-27 12:46:59 +0100 | |
| commit | 2ae96654f769bee10636fa81699e1708295f9ae6 (patch) | |
| tree | 0e09f87e0e529aa587dbfd58651c4401a0370724 | |
| parent | add Diagnostics (diff) | |
| download | zig-sqlite-2ae96654f769bee10636fa81699e1708295f9ae6.tar.gz zig-sqlite-2ae96654f769bee10636fa81699e1708295f9ae6.tar.xz zig-sqlite-2ae96654f769bee10636fa81699e1708295f9ae6.zip | |
readme: document prepareWithDiags
Diffstat (limited to '')
| -rw-r--r-- | README.md | 13 |
1 files changed, 13 insertions, 0 deletions
| @@ -104,6 +104,19 @@ defer stmt.deinit(); | |||
| 104 | 104 | ||
| 105 | The `Db.prepare` method takes a `comptime` query string. | 105 | The `Db.prepare` method takes a `comptime` query string. |
| 106 | 106 | ||
| 107 | ### Diagnostics | ||
| 108 | |||
| 109 | If you want failure diagnostics you can use `prepareWithDiags` like this: | ||
| 110 | |||
| 111 | ```zig | ||
| 112 | var diags = sqlite.Diagnostics{}; | ||
| 113 | var stmt = db.prepareWithDiags(query, .{ .diags = &diags }) catch |err| { | ||
| 114 | std.log.err("unable to prepare statement, got error {s}. diagnostics: {s}", .{ err, diags }); | ||
| 115 | return err; | ||
| 116 | }; | ||
| 117 | defer stmt.deinit(); | ||
| 118 | ``` | ||
| 119 | |||
| 107 | ## Executing a statement | 120 | ## Executing a statement |
| 108 | 121 | ||
| 109 | For queries which do not return data (`INSERT`, `UPDATE`) you can use the `exec` method: | 122 | For queries which do not return data (`INSERT`, `UPDATE`) you can use the `exec` method: |