| ... | ... | @@ -54,3 +54,12 @@ pub fn first(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptime |
| 54 | 54 | defer stmt.deinit(); |
| 55 | 55 | return try stmt.oneAlloc(T, alloc, .{}, args); |
| 56 | 56 | } |
| 57 | |
| 58 | pub fn doesTableExist(self: *Self, alloc: *std.mem.Allocator, name: string) !bool { |
| 59 | for (try self.collect(alloc, string, "select name from sqlite_master where type=? AND name=?", .{ .type = "table", .name = name })) |item| { |
| 60 | if (std.mem.eql(u8, item, name)) { |
| 61 | return true; |
| 62 | } |
| 63 | } |
| 64 | return false; |
| 65 | } |