{"id":16559357,"url":"https://github.com/anders94/asynqlite","last_synced_at":"2025-07-28T22:38:32.253Z","repository":{"id":145052374,"uuid":"616770829","full_name":"anders94/asynqlite","owner":"anders94","description":"Node.js async / await wrapper for sqlite3","archived":false,"fork":false,"pushed_at":"2023-08-23T12:38:08.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-15T12:12:03.862Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/anders94.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-21T03:27:12.000Z","updated_at":"2024-01-16T05:50:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"c1ad057d-de61-4a16-9d43-c37b0650b3ca","html_url":"https://github.com/anders94/asynqlite","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anders94%2Fasynqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anders94%2Fasynqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anders94%2Fasynqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anders94%2Fasynqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anders94","download_url":"https://codeload.github.com/anders94/asynqlite/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241950145,"owners_count":20047591,"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":[],"created_at":"2024-10-11T20:25:39.928Z","updated_at":"2025-03-05T02:16:49.714Z","avatar_url":"https://github.com/anders94.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# asynqlite\n\nSimple Node.js async/await wrapper for SQLite. Uses `sqlite3` behind the scenes and\ngreatly simplifies the the API.\n\n## Install\n\n```bash\nnpm install asynqlite\n```\n\n## Examples\n`SELECT` some data:\n\n```js\nconst db = require('asynqlite');\n\n(async () =\u003e {\n    await db.open(':memory:');\n\n    const res = await db.run('SELECT datetime() AS foo');\n    console.log(res[0].foo);    // outputs today's date\n\n    db.close();\n})();\n```\n\nPass parameters:\n\n```js\nconst db = require('asynqlite');\n\n(async () =\u003e {\n    await db.open(':memory:');\n\n    const res = await db.run('SELECT ? + ? as onePlusTwo', [1, 2]);\n    console.log(res[0].onePlusTwo);\n\n    // output:\n    // 3\n\n    db.close();\n})();\n```\n\nUse a prepared statement:\n\n```js\nconst db = require('asynqlite');\n\n(async () =\u003e {\n    db.open(':memory:');\n\n    await db.run('CREATE TABLE foo (bar TEXT)');\n\n    const stmt = await db.prepare('INSERT INTO foo VALUES (?)');\n    for (let i = 0; i \u003c 5; i++) {\n        stmt.run('test ' + i);\n    }\n    await db.finalize(stmt);\n\n    const res = await db.run('SELECT rowid AS id, bar FROM foo');\n    console.log(res);\n\n    // output:\n    // [\n    //   { id: 1, bar: 'test 0' },\n    //   { id: 2, bar: 'test 1' },\n    //   { id: 3, bar: 'test 2' },\n    //   { id: 4, bar: 'test 3' },\n    //   { id: 5, bar: 'test 4' }\n    // ]\n\n    await db.close();\n})();\n```\n\n## API\n- `db.open(path, options)`\n  - `path` is a local path and filename for persistant storage, `:memory:` for a memory\n    based non persistant database or `undefined` for a filesystem based non-persistant\n    storage.\n  - `options` are one or more pipe delineated `db.OPEN_READONLY`, `db.OPEN_READWRITE`,\n    `db.OPEN_CREATE`, `db.OPEN_FULLMUTEX`, `db.OPEN_URI`, `db.OPEN_SHAREDCACHE`,\n    `db.OPEN_PRIVATECACHE`. The default is `OPEN_READWRITE | OPEN_CREATE | OPEN_FULLMUTEX`.\n- `db.run(sql (, [param, ...]))` - returns an array of results (if any)\n  - `sql` is the SQL statement in text to be executed.\n  - Optional array of `param` values which will be substituted for `?` in the SQL.\n    Example: set `bar` equal to `a` where baz is `b` in the table `foo`\n    ```js\n    await db.run('UPDATE foo SET bar = ? WHERE baz = ?', [ 'a', 'b' ]);\n    ```\n  - Returns an array of results. (if any)\n    Example: `SELECT` all the rows from the table `foo`:\n    ```js\n    const res = await db.run('SELECT * FROM foo');\n    console.log(res);\n    ```\n- `db.prepare(sql)` - returns a statement object\n  - `sql` is the SQL statement in text to be executed. Parameter substitution (values of which\n    are to be supplied later by using the returned statement object) are designated with `?`\n    in the SQL statement.\n    Example: Prepare an `INSERT` statement and execute it with three different sets of values:\n    ```js\n    const stmt = await db.prepare('INSERT INTO foo (a, b) VALUES (?, ?)');\n    stmt.run('x', 1);\n    stmt.run('y', 2);\n    stmt.run('z', 3);\n    await db.finalize(stmt);\n    ```\n    \u003e Note: You don't have to `await` each `stmt.run()` because the `await finalize()` effectivly does this.\n- `db.finalize(stmt)` - finalizes the passed statement\n  - See `db.prepare(sql)` above for example usage.\n- `db.close()`\n  - Closes the database handle. (happens automatically if you don't do it explicitly)\n\n## More Info\n\nSee the [examples](examples/) directory for more.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanders94%2Fasynqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanders94%2Fasynqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanders94%2Fasynqlite/lists"}