{"id":13421230,"url":"https://github.com/yhirose/cpp-sqlitelib","last_synced_at":"2025-10-18T02:12:49.056Z","repository":{"id":9057635,"uuid":"10825202","full_name":"yhirose/cpp-sqlitelib","owner":"yhirose","description":"C++ SQLite wrapper library","archived":false,"fork":false,"pushed_at":"2022-07-12T19:39:30.000Z","size":3938,"stargazers_count":51,"open_issues_count":1,"forks_count":19,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-24T02:08:47.229Z","etag":null,"topics":["cpp","head-only","sqlite"],"latest_commit_sha":null,"homepage":"","language":"C","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/yhirose.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}},"created_at":"2013-06-20T17:16:25.000Z","updated_at":"2025-04-22T20:43:34.000Z","dependencies_parsed_at":"2022-08-28T05:03:06.657Z","dependency_job_id":null,"html_url":"https://github.com/yhirose/cpp-sqlitelib","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/yhirose%2Fcpp-sqlitelib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhirose%2Fcpp-sqlitelib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhirose%2Fcpp-sqlitelib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhirose%2Fcpp-sqlitelib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yhirose","download_url":"https://codeload.github.com/yhirose/cpp-sqlitelib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250546081,"owners_count":21448260,"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":["cpp","head-only","sqlite"],"created_at":"2024-07-30T22:01:52.295Z","updated_at":"2025-10-18T02:12:48.977Z","avatar_url":"https://github.com/yhirose.png","language":"C","readme":"cpp-sqlitelib\n=============\n\nA single file C++ header-only SQLite wrapper library\n\n## Open database\n\n    #include \u003csqlitelib.h\u003e\n    using namespace sqlitelib;\n    auto db = Sqlite(\"./test.db\");\n\n## Create table\n\n    db.execute(R\"(\n      CREATE TABLE IF NOT EXISTS people (\n        id INTEGER PRIMARY KEY AUTOINCREMENT,\n        name TEXT,\n        age INTEGER,\n        data BLOB\n      )\n    )\");\n\n## Drop table\n\n    db.execute(\"DROP TABLE IF EXISTS people\");\n\n## Insert records\n\n    auto stmt = db.prepare(\"INSERT INTO people (name, age, data) VALUES (?, ?, ?)\");\n    stmt.execute(\"john\", 10, vector\u003cchar\u003e({ 'A', 'B', 'C', 'D' }));\n    stmt.execute(\"paul\", 20, vector\u003cchar\u003e({ 'E', 'B', 'G', 'H' }));\n    stmt.execute(\"mark\", 15, vector\u003cchar\u003e({ 'I', 'J', 'K', 'L' }));\n    stmt.execute(\"luke\", 25, vector\u003cchar\u003e({ 'M', 'N', 'O', 'P' }));\n\n## Select a record (single colum)\n\n    auto val = db.execute_value\u003cint\u003e(\"SELECT age FROM people WHERE name='john'\");\n    val; // 10\n\n## Select records (multiple columns)\n\n    auto rows = db.execute\u003cint, std::string\u003e(\"SELECT age, name FROM people\");\n    rows.size(); // 4\n\n    auto [age, name] = rows[3]; // age: 25, name: luke\n\n## Bind #1\n\n    auto stmt = db.prepare\u003cstd::string\u003e(\"SELECT name FROM people WHERE age \u003e ?\");\n\n    auto rows = stmt.execute(10);\n    rows.size(); // 3\n    rows[0];     // paul\n\n    auto rows = stmt.bind(10).execute();\n    rows.size(); // 3\n    rows[0];     // paul\n\n## Bind #2\n\n    auto val = db.execute_value\u003cint\u003e(\"SELECT id FROM people WHERE name=? AND age=?\", \"john\", 10);\n    val; // 1\n\n## Cursor (multiple columns)\n\n    auto stmt = db.prepare\u003cstd::string, int\u003e(\"SELECT name, age FROM people\");\n\n    auto cursor = stmt.execute_cursor();\n    for (auto it = cursor.begin(); it != cursor.end(); ++it) {\n      get\u003c0\u003e(*it);\n      get\u003c1\u003e(*it);\n      ++it;\n    }\n\n    // With C++17 structured binding\n    for (const auto\u0026 [name, age] : stmt.execute_cursor()) {\n      ;\n    }\n\n## Cursor (single column)\n\n    auto stmt = db.prepare\u003cstd::string\u003e(\"SELECT name FROM people\");\n\n    for (const auto\u0026 x: stmt.execute_cursor()) {\n      ;\n    }\n\n## Count\n\n    auto val = db.execute_value\u003cint\u003e(\"SELECT COUNT(*) FROM people\");\n    val; // 4\n\n## Flat API\n\n    for (const auto\u0026 [name, age] :\n         db.execute_cursor\u003cstring, int\u003e(\"SELECT name, age FROM people\")) {\n      ;\n    }\n\n    for (const auto\u0026 x: db.execute_cursor\u003cstd::string\u003e(\"SELECT name FROM people\")) {\n      ;\n    }\n\nLicense\n-------\n\nMIT license (© 2021 Yuji Hirose)\n","funding_links":[],"categories":["TODO scan for Android support in followings","Database"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyhirose%2Fcpp-sqlitelib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyhirose%2Fcpp-sqlitelib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyhirose%2Fcpp-sqlitelib/lists"}