{"id":13740794,"url":"https://github.com/lpil/sqlight","last_synced_at":"2025-04-05T17:05:18.737Z","repository":{"id":65147169,"uuid":"583126475","full_name":"lpil/sqlight","owner":"lpil","description":"💡 Use SQLite from Gleam!","archived":false,"fork":false,"pushed_at":"2025-02-22T21:52:14.000Z","size":40,"stargazers_count":104,"open_issues_count":6,"forks_count":16,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T16:04:37.287Z","etag":null,"topics":["database-client","gleam","sqlite"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/sqlight","language":"Gleam","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lpil.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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}},"created_at":"2022-12-28T21:06:40.000Z","updated_at":"2025-03-29T12:56:55.000Z","dependencies_parsed_at":"2023-11-06T23:21:39.496Z","dependency_job_id":"844646fc-bfa3-47f3-a034-39fe153dd5f2","html_url":"https://github.com/lpil/sqlight","commit_stats":{"total_commits":31,"total_committers":1,"mean_commits":31.0,"dds":0.0,"last_synced_commit":"c8b9d1e8afdf5fe326499c2aca421d55289ed9e7"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpil%2Fsqlight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpil%2Fsqlight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpil%2Fsqlight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpil%2Fsqlight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lpil","download_url":"https://codeload.github.com/lpil/sqlight/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247369953,"owners_count":20927928,"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":["database-client","gleam","sqlite"],"created_at":"2024-08-03T04:00:52.263Z","updated_at":"2025-04-05T17:05:18.704Z","avatar_url":"https://github.com/lpil.png","language":"Gleam","readme":"# sqlight\n\n[![Package Version](https://img.shields.io/hexpm/v/sqlight)](https://hex.pm/packages/sqlight)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/sqlight/)\n\nUse [SQLite](https://www.sqlite.org/index.html) from Gleam!\n\nWorks on Erlang or JavaScript running on Deno.\n\n```sh\ngleam add sqlight\n```\n\n```gleam\nimport gleam/dynamic/decode\nimport sqlight\n\npub fn main() {\n  use conn \u003c- sqlight.with_connection(\":memory:\")\n\n  let sql = \"\n  create table cats (name text, age int);\n\n  insert into cats (name, age) values \n  ('Nubi', 4),\n  ('Biffy', 10),\n  ('Ginny', 6);\n  \"\n  let assert Ok(Nil) = sqlight.exec(sql, conn)\n\n  let cat_decoder = {\n    use name \u003c- decode.field(0, decode.string)\n    use age \u003c- decode.field(1, decode.int)\n    decode.success(#(name, age))\n  }\n\n  let sql = \"\n  select name, age from cats\n  where age \u003c ?\n  \"\n  let assert Ok([#(\"Nubi\", 4), #(\"Ginny\", 6)]) =\n    sqlight.query(sql, on: conn, with: [sqlight.int(7)], expecting: cat_decoder)\n}\n```\n\nDocumentation can be found at \u003chttps://hexdocs.pm/sqlight\u003e.\n\n## Why SQLite?\n\nSQLite is a implementation of SQL as a library. This means that you don't run a\nseparate SQL server that your program communicates with, but you embed the SQL\nimplementation directly in your program. SQLite stores its data in a single\nfile. The file format is portable between different machine architectures. It\nsupports atomic transactions and it is possible to access the file by multiple\nprocesses and different programs.\n\nYou can also use in-memory databases with SQLite, which may be useful for testing.\n\n## Implementation\n\nWhen running on Erlang is library wrapper around the excellent Erlang library\n[esqlite](https://hex.pm/packages/esqlite), which in turn is a wrapper around\nthe SQLite C library. It is implemented as a NIF, which means that the SQLite\ndatabase engine is linked to the erlang virtual machine.\n\nWhen running on Deno it is a wrapper around the excellent\n[x/sqlite](https://deno.land/x/sqlite@v3.7.0) library, which in turn is a\nwrapper around the SQLite C library compiled to WASM.\n\n## On using Bool with SQLite\n\nSQLite does not have a native boolean type. Instead, it uses ints, where 0 is\nFalse and 1 is True. Because of this the Gleam stdlib decoder for bools will not\nwork, instead the `sqlight.decode_bool` function should be used as it supports\nboth ints and bools.\n","funding_links":[],"categories":["Packages","Gleam"],"sub_categories":["Databases"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flpil%2Fsqlight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flpil%2Fsqlight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flpil%2Fsqlight/lists"}