{"id":20711392,"url":"https://github.com/codehz/easy_sqlite3","last_synced_at":"2025-04-23T06:25:14.229Z","repository":{"id":41549524,"uuid":"416690967","full_name":"codehz/easy_sqlite3","owner":"codehz","description":"Yet another SQLite wrapper for Nim","archived":false,"fork":false,"pushed_at":"2023-09-21T03:17:49.000Z","size":2141,"stargazers_count":17,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2025-03-29T22:31:34.017Z","etag":null,"topics":["nim","sqlite3"],"latest_commit_sha":null,"homepage":"","language":"C","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/codehz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-13T10:23:44.000Z","updated_at":"2024-09-12T13:20:25.000Z","dependencies_parsed_at":"2023-02-15T16:45:11.767Z","dependency_job_id":null,"html_url":"https://github.com/codehz/easy_sqlite3","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codehz%2Feasy_sqlite3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codehz%2Feasy_sqlite3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codehz%2Feasy_sqlite3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codehz%2Feasy_sqlite3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codehz","download_url":"https://codeload.github.com/codehz/easy_sqlite3/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250381650,"owners_count":21421183,"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":["nim","sqlite3"],"created_at":"2024-11-17T02:15:16.181Z","updated_at":"2025-04-23T06:25:14.212Z","avatar_url":"https://github.com/codehz.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yet another SQLite wrapper for Nim\n\nFeatures:\n\n1. Design for ARC/ORC, you don’t need to close the connection manually\n2. Use `importdb` macro to create helper function (see examples)\n3. Including a memfs implemention， may better than `:memory:` database since it support WAL mode (Experimental, see tests/test_thread)\n\n## Example\n\nBasic usage:\n\n```nim\nimport std/tables\nimport easy_sqlite3\n\n# Bind function argument to sql statment\n# The tuple return value indicate the query will got exactly 1 result\nproc select_1(arg: int): tuple[value: int] {.importdb: \"SELECT $arg\".}\n\nvar db = initDatabase(\":memory:\")\n# Use as a method (the statment will be cached, thats why `var` is required)\necho db.select_1(1).value\n# Got 1\n\n# You can bind create statment as well\nproc create_table() {.importdb: \"\"\"\n  CREATE TABLE mydata(name TEXT PRIMARY KEY NOT NULL, value INT NOT NULL);\n\"\"\".}\n\n# Or insert\nproc insert_data(name: string, value: int) {.importdb: \"\"\"\n  INSERT INTO mydata(name, value) VALUES ($name, $value);\n\"\"\".}\n\n# And you can create iterator by the same way (the `= discard` is required, since iterator must have body in nim)\niterator iterate_data(): tuple[name: string, value: int] {.importdb: \"\"\"\n  SELECT name, value FROM mydata;\n\"\"\".} = discard\n\nconst dataset = {\n  \"A\": 0,\n  \"B\": 1,\n  \"C\": 2,\n  \"D\": 3,\n}.toTable\ndb.create_table()\n# Use transaction (commit by default)\ndb.transaction:\n  for name, value in dataset:\n    db.insert_data name, value\n  commit() # optional\n  # Never goes here\n\nfor name, value in db.iterate_data():\n  assert name in dataset\n  assert dataset[name] == value\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodehz%2Feasy_sqlite3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodehz%2Feasy_sqlite3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodehz%2Feasy_sqlite3/lists"}