{"id":20834657,"url":"https://github.com/cachyos/db-wrap","last_synced_at":"2025-10-14T14:45:59.950Z","repository":{"id":259304830,"uuid":"876810688","full_name":"CachyOS/db-wrap","owner":"CachyOS","description":"A Modern C++ Database Wrapper Library","archived":false,"fork":false,"pushed_at":"2025-09-15T22:43:59.000Z","size":88,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-29T06:26:52.089Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/CachyOS.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-10-22T15:37:19.000Z","updated_at":"2025-09-15T22:44:03.000Z","dependencies_parsed_at":"2025-04-12T20:28:44.803Z","dependency_job_id":"df22a2b7-0388-4749-b20f-0667a46e2e64","html_url":"https://github.com/CachyOS/db-wrap","commit_stats":null,"previous_names":["cachyos/db-wrap"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CachyOS/db-wrap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CachyOS%2Fdb-wrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CachyOS%2Fdb-wrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CachyOS%2Fdb-wrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CachyOS%2Fdb-wrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CachyOS","download_url":"https://codeload.github.com/CachyOS/db-wrap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CachyOS%2Fdb-wrap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279019161,"owners_count":26086685,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-18T00:20:04.568Z","updated_at":"2025-10-14T14:45:59.935Z","avatar_url":"https://github.com/CachyOS.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# db-wrap: A Modern C++ Database Wrapper Library\n\n`db-wrap` is a lightweight, header-only C++20 library that simplifies database\ninteractions using modern C++ features and concepts. It provides a generic\ninterface for database operations, currently supports only (PostgreSQL) via\nthe libpqxx library.\n\nmotivating example: https://www.boost.org/doc/libs/1_86_0/doc/html/boost_pfr.html#boost_pfr.intro\n\n## Features\n\n- **Type-Safe SQL Queries:** Use C++ types directly in queries for better\n  type safety and reduced errors.\n- **Automatic Parameter Binding:**  Bind parameters to queries without manual\n  placeholder management.\n- **Row-to-Object Mapping:**  Easily convert database rows to user-defined\n  objects using Boost.PFR.\n- **Compile-Time Query Generation:**  Optionally generate SQL queries at\n  compile time for performance optimization and validation.\n\n## Requirements\n\n- C++20 compatible compiler\n- libpqxx library (for PostgreSQL support)\n- Boost.PFR library\n\n## Installation\n\n`db-wrap` is a header-only library, so no installation is required. Simply\ninclude the header files in your project and link against libpqxx and\nBoost.PFR.\n\n## Usage\n\nHere's a basic example demonstrating how to use `db-wrap` with libpqxx:\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cstring_view\u003e\n#include \u003cdb_wrap/db_api.hpp\u003e\n\n#include \u003cpqxx/pqxx\u003e\n\nstruct User {\n    /// `kName` is name table in DB\n    static constexpr std::string_view kName = \"users\";\n\n    int id;\n    std::string name;\n    std::string email;\n};\n\nint main() {\n    // Create a connection object\n    pqxx::connection conn(\"postgresql://user:password@host:port/database\");\n\n    // Find a user by ID\n    auto user = db::find_by_id\u003cUser\u003e(conn, 1);\n    if (user) {\n        std::cout \u003c\u003c \"User found: \" \u003c\u003c user-\u003ename \u003c\u003c std::endl;\n    } else {\n        std::cout \u003c\u003c \"User not found!\" \u003c\u003c std::endl;\n    }\n\n    // Retrieve all users\n    auto users = db::get_all_records\u003cUser\u003e(conn);\n    if (users) {\n        for (auto\u0026\u0026 user : *users) {\n            std::cout \u003c\u003c \"User: \" \u003c\u003c user.name \u003c\u003c \" (\" \u003c\u003c user.email \u003c\u003c \")\" \u003c\u003c std::endl;\n        }\n    } else {\n        std::cout \u003c\u003c \"No users found!\" \u003c\u003c std::endl;\n    }\n}\n```\n\n## Examples\n\nMore examples can be found in the `examples` directory.\n\n## Testing\n\nUnit tests are provided in the `tests` directory. You can run the tests using\nCMake's CTest framework.\n\n## Contributing\n\nContributions are welcome!\n\n## License\n\nThis library is licensed under the [MIT License](LICENSE).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcachyos%2Fdb-wrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcachyos%2Fdb-wrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcachyos%2Fdb-wrap/lists"}