{"id":19891260,"url":"https://github.com/jkoop/zigqlite","last_synced_at":"2025-06-19T14:39:49.416Z","repository":{"id":250039500,"uuid":"833248361","full_name":"jkoop/zigqlite","owner":"jkoop","description":"An SQLite binding for Zig.","archived":false,"fork":false,"pushed_at":"2025-02-13T14:38:50.000Z","size":5761,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-02T18:53:13.176Z","etag":null,"topics":["sqlite","zig","zig-package"],"latest_commit_sha":null,"homepage":"http://joekoop.com/zigqlite/","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jkoop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-24T16:41:33.000Z","updated_at":"2025-02-22T21:27:25.000Z","dependencies_parsed_at":"2025-05-02T18:45:35.276Z","dependency_job_id":null,"html_url":"https://github.com/jkoop/zigqlite","commit_stats":null,"previous_names":["jkoop/zigqlite"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jkoop/zigqlite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkoop%2Fzigqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkoop%2Fzigqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkoop%2Fzigqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkoop%2Fzigqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jkoop","download_url":"https://codeload.github.com/jkoop/zigqlite/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkoop%2Fzigqlite/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260769861,"owners_count":23060192,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sqlite","zig","zig-package"],"created_at":"2024-11-12T18:17:35.651Z","updated_at":"2025-06-19T14:39:44.404Z","avatar_url":"https://github.com/jkoop.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zigqlite\n\n\u003e [!NOTE]  \n\u003e Forked from https://chiselapp.com/user/javier/repository/zigqlite\n\nAn [SQLite](https://sqlite.org) binding for [Zig](https://ziglang.org).\n\n## Install\n\n```sh\nzig fetch --save https://github.com/jkoop/zigqlite/archive/COMMIT.zip\n```\n\n```zig\n// build.zig before b.installArtifact(exe);\n\nconst zigqlite = b.dependency(\"zigqlite\", .{\n    .target = target,\n    .optimize = optimize,\n}).module(\"zigqlite\");\n\nexe.linkSystemLibrary(\"c\");\nexe.linkSystemLibrary(\"sqlite3\"); // apt install libsqlite3-dev\nexe.root_module.addImport(\"zigqlite\", zigqlite);\n```\n\n## Usage\n\nSee also, the [API documentation](https://joekoop.com/zigqlite).\n\nTo open a database file at the given path, creating it if needed:\n\n```zig\nvar db = try sqlite.DB.open(allocator, \"database.db\");\ndefer db.close() catch unreachable; // @todo figure out if I can handle this error or not\n```\n\nCreate a statment:\n\n```zig\nvar stmt = try db.prep(\"SELECT * FROM iguanas WHERE name = ?\");\n```\n\nThe SQL can include positional arguments like `?` or named arguments like `:argname`.\n\nOnce prepared, the statement is executed with the `.exec()` function:\n\n```zig\n// var cursor = try stmt.exec(args, rowtype);\nvar cursor = try stmt.exec(.{\"Zero\"}, struct { name: []u8, photo_url: []u8 });\n```\n\nWhere `args` is a tuple or structure holding arguments to fill in the SQL command. If field names match named arguments, they are used regardless of order; otherwise the position in the tuple or struct determines the field it fills.\n\nThe `rowtype` parameter is a struct type. Each returned row will be a value of this type. Each field will hold a column from the row, in order. If there are more fields than columns, the extra fields would be filled with their respective default value, if declared in the struct.\n\nThe value returned by the `stmt.exec()` function is used to retrieve results row by row with the `.fetch()` function:\n\n```zig\nwhile (try cursor.fetch()) |iguana| {\n    std.debug.print(\"{s}'s picture is at {s}\\n\", .{ iguana.name, iguana.photo_url });\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjkoop%2Fzigqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjkoop%2Fzigqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjkoop%2Fzigqlite/lists"}