{"id":20021259,"url":"https://github.com/tiendq/sqlitecpp","last_synced_at":"2026-04-07T20:31:30.106Z","repository":{"id":88624067,"uuid":"158561126","full_name":"tiendq/SQLiteCpp","owner":"tiendq","description":"SQLiteCpp is a modern C++ wrapper for SQLite3 library.","archived":false,"fork":false,"pushed_at":"2019-07-14T12:41:56.000Z","size":12524,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-02T03:42:19.809Z","etag":null,"topics":["c-plus-plus","cpp","database","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/tiendq.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2018-11-21T14:33:29.000Z","updated_at":"2024-11-01T00:57:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"3bafd619-e270-4eb4-9b8e-3eb0df6fd6ab","html_url":"https://github.com/tiendq/SQLiteCpp","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/tiendq/SQLiteCpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiendq%2FSQLiteCpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiendq%2FSQLiteCpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiendq%2FSQLiteCpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiendq%2FSQLiteCpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tiendq","download_url":"https://codeload.github.com/tiendq/SQLiteCpp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiendq%2FSQLiteCpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31528274,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"ssl_error","status_checked_at":"2026-04-07T16:28:06.951Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["c-plus-plus","cpp","database","sqlite"],"created_at":"2024-11-13T08:36:03.300Z","updated_at":"2026-04-07T20:31:30.083Z","avatar_url":"https://github.com/tiendq.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"SQLiteC++\r\n---------\r\n\r\nSQLiteC++ (SQLiteCpp) is an easy to use modern C++ wrapper for SQLite3 library. It offers an encapsulation around the native C APIs of SQLite, with a few intuitive and well documented C++ classes.\r\n\r\n[SQLite](http://www.sqlite.org/about.html) is a C library that implements a serverless transactional SQL database engine. It is the most widely deployed SQL database engine in the world. All of the code and documentation in SQLite has been dedicated to the public domain by the authors.\r\n\r\n## The goals of SQLiteC++\r\n\r\n- to offer the best of the existing simple C++ SQLite wrappers\r\n- to be elegantly written with good C++ design, STL, exceptions and RAII idiom\r\n- to keep dependencies to a minimum (STL and SQLite3)\r\n- to be portable\r\n- to be light and fast\r\n- to be thread-safe only as much as SQLite [multi-thread mode](https://www.sqlite.org/threadsafe.html)\r\n- to have a good unit test coverage\r\n- to use API names sticking with those of the SQLite library\r\n- to be well documented with Doxygen tags, and with some good examples\r\n- to be well maintained\r\n- to use a permissive MIT license, similar to BSD or Boost, for proprietary/commercial usage\r\n\r\nIt is designed using the [RAII](http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization) idiom, and throwing exceptions in case of SQLite errors (exept in destructors, where `assert()` are used instead). Each SQLiteC++ object must be constructed with a valid SQLite database connection, and then is always valid until destroyed.\r\n\r\n## Dependencies\r\n\r\n- an STL implementation (even an old one, like the one provided with VC6 should work)\r\n- exception support (the class `Exception` inherits from `std::runtime_error`)\r\n- the SQLite library (3.7.15 minimum from 2012-12-12) either by linking to it dynamicaly or statically (install the `libsqlite3-dev` package under Debian/Ubuntu/Mint Linux), or by adding its source file in your project code base (source code provided in `sqlite3` for Windows), with the [`SQLITE_ENABLE_COLUMN_METADATA`](http://www.sqlite.org/compile.html#enable_column_metadata) macro defined.\r\n\r\n## Getting started\r\n\r\n### Installation\r\n\r\nTo use this wrapper, you need to add the SQLiteC++ source files from the `src` directory in your project code base, and compile/link against the `sqlite3` library.\r\n\r\nThe easiest way to do this is to add the wrapper as a library.\r\n\r\nThe `CMakeLists.txt` file defining the static library is provided in the root directory, so you simply have to `add_subdirectory(SQLiteCpp)` to you main `CMakeLists.txt` and link to the `SQLiteCpp` wrapper library.\r\n\r\nExample for Linux:\r\n\r\n```cmake\r\nadd_executable(main src/main.cpp)\r\nadd_subdirectory(${PROJECT_SOURCE_DIR}/libs/SQLiteCpp)\r\n\r\ntarget_include_directories(main PRIVATE ${PROJECT_SOURCE_DIR}/libs/SQLiteCpp/include)\r\ntarget_link_libraries(main SQLiteCpp sqlite3 dl)\r\n```\r\n\r\nThis SQLiteCpp repository can be directly used as a Git submoldule in your main repository, see [SQLiteCppExample](https://github.com/tiendq/SQLiteCppExample) for detail.\r\n\r\nUnder Debian/Ubuntu/Mint Linux, you can install the `libsqlite3-dev` package if you don't want to use the embedded `sqlite3` library.\r\n\r\n### Building example and unit tests\r\n\r\nClone the repository then init and update submodule `googletest`.\r\n\r\n```shell\r\ngit clone --recurse-submodules https://github.com/tiendq/SQLiteCpp.git\r\n```\r\n\r\n#### CMake and tests\r\nA CMake configuration file is also provided for multiplatform support and testing.\r\n\r\n```shell\r\nmkdir build\r\ncd bebug\r\n\r\ncmake -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON ..\r\ncmake --build .\r\n\r\n# Build and run unit-tests (ie 'make test')\r\nctest --output-on-failure\r\n```\r\n\r\n#### CMake options\r\n\r\n* For more options on customizing the build, see the [CMakeLists.txt](https://github.com/tiendq/SQLiteCpp/blob/master/CMakeLists.txt) file.\r\n\r\n#### Troubleshooting\r\n\r\nUnder Linux, if you get muliple linker errors like `undefined reference to sqlite3_xxx`,\r\nit's that you lack the `sqlite3` library: install the `libsqlite3-dev` package.\r\n\r\nIf you get a single linker error `Column.cpp: undefined reference to sqlite3_column_origin_name`,\r\nit's that your `sqlite3` library was not compiled with the `SQLITE_ENABLE_COLUMN_METADATA` macro defined.\r\nYou can either recompile it yourself (seek help online) or you can comment out the following line in `include/SQLiteCpp/Column.h`:\r\n\r\n```c++\r\n#define SQLITE_ENABLE_COLUMN_METADATA\r\n```\r\n\r\n### Thread-safety\r\n\r\nSQLite supports three modes of thread safety, as described in [Multi-threaded Programs and SQLite](https://www.sqlite.org/threadsafe.html).\r\n\r\nThis SQLiteC++ does not add any locks (no mutexes) nor any other thread-safety mechanism\r\nabove the SQLite library itself, by design, for lightness and speed.\r\n\r\nThus, SQLiteC++ naturally supports the multi-thread mode of SQLite:\r\n\r\n\u003e In this mode, SQLite can be safely used by multiple threads provided that no single database connection is used simultaneously in two or more threads.\r\n\r\nBut SQLiteC++ does not support the fully thread-safe \"Serialized\" mode of SQLite, because of the way it shares the underlying SQLite precompiled statement in a custom shared pointer (see class `Statement::Ptr`).\r\n\r\n### Examples\r\n\r\nThis example sample demonstrates how to query a database and get results.\r\n\r\n```c++\r\ntry\r\n{\r\n    // Open a database file\r\n    SQLite::Database    db(\"example.db3\");\r\n\r\n    // Compile a SQL query, containing one parameter (index 1)\r\n    SQLite::Statement   query(db, \"SELECT * FROM test WHERE size \u003e ?\");\r\n\r\n    // Bind the integer value 6 to the first parameter of the SQL query\r\n    query.bind(1, 6);\r\n\r\n    // Loop to execute the query step by step, to get rows of result\r\n    while (query.executeStep())\r\n    {\r\n        // Demonstrate how to get some typed column value\r\n        int         id      = query.getColumn(0);\r\n        const char* value   = query.getColumn(1);\r\n        int         size    = query.getColumn(2);\r\n\r\n        std::cout \u003c\u003c \"row: \" \u003c\u003c id \u003c\u003c \", \" \u003c\u003c value \u003c\u003c \", \" \u003c\u003c size \u003c\u003c std::endl;\r\n    }\r\n}\r\ncatch (std::exception\u0026 e)\r\n{\r\n    std::cout \u003c\u003c \"exception: \" \u003c\u003c e.what() \u003c\u003c std::endl;\r\n}\r\n```\r\n\r\n### How to handle assertion in SQLiteC++\r\n[Don't throw exceptions in destructors!](https://isocpp.org/wiki/faq/exceptions#dtors-shouldnt-throw), so SQLiteC++ uses `SQLITECPP_ASSERT()` to check for errors in destructors. If you don't want `assert()` to be called, you have to enable and define an assert handler as shown below, and by setting the flag `SQLITECPP_ENABLE_ASSERT_HANDLER` when compiling the library.\r\n\r\n```c++\r\n#ifdef SQLITECPP_ENABLE_ASSERT_HANDLER\r\nnamespace SQLite\r\n{\r\n/// Definition of the custom assertion handler, enabled when SQLITECPP_ENABLE_ASSERT_HANDLER is defined.\r\nvoid assertion_failed(const char* apFile, const long apLine, const char* apFunc, const char* apExpr, const char* apMsg)\r\n{\r\n    // Print a message to the standard error output stream, and abort the program.\r\n    std::cerr \u003c\u003c apFile \u003c\u003c \":\" \u003c\u003c apLine \u003c\u003c \":\" \u003c\u003c \" error: assertion failed (\" \u003c\u003c apExpr \u003c\u003c \") in \" \u003c\u003c apFunc \u003c\u003c \"() with message \\\"\" \u003c\u003c apMsg \u003c\u003c \"\\\"\\n\";\r\n    std::abort();\r\n}\r\n}\r\n#endif // SQLITECPP_ENABLE_ASSERT_HANDLER\r\n```\r\n\r\n### Coding guidelines\r\n\r\nThe source code use the `CamelCase` naming style variant where:\r\n\r\n- Type names (class, struct, typedef, enums...) begin with a capital letter e.g. `Database`\r\n- Files are named like the class they contain e.g. `Database.cpp`\r\n- Function and variable names begin with a lower case letter e.g. `bindNoCopy`\r\n- Member variables begin with 'm_' e.g. `m_fileName`\r\n- Each file, class, method and member variable is documented using Doxygen tags\r\n\r\n### History\r\n\r\nThis repo is originally forked from [SQLiteCpp](https://github.com/SRombauts/SQLiteCpp).\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiendq%2Fsqlitecpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftiendq%2Fsqlitecpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiendq%2Fsqlitecpp/lists"}