Re: [sqlite] Formal review of Boost.SQLite begins

# Introduction Below is my review of the boost_sqlite library. First off, I believe that this approach of providing a safer and much more expressive C++ interface on top of the SQLite C library, is a step toward the simplification and hardening of database development. ## Author's Background I'm a professional C++ Developer. I've been using the Boost library in both hobby projects and professional ones. I have experience in interacting with similar connectors such as: ADO, ODBC, MySQL, JDBC. ## Initial Thoughts and Use Case The library wraps the standard C API of SQLite into wrapped containers. Such as the connection, field, resultset containers. String helpers and the connection object seems to fulfill their duty correctly. Reflecting industry standard practice of such interfaces. The library is a perfect solution for applications written in C++ with persistence needs without the need of a SQL server. Moreover the boost style codebase makes it even easier to integrate into such applications. ## Thoughts on Design The design is simple, easy to understand, and what I'd expect for such an interface. I believe it would meet my needs. ## Improvements Needed The `handle_type` alias shall be set to a void* in order to hide the implementation details of the library. ```cpp using handle_type = void*; ``` The `connection` constructor with the `int flags` parameter should be abstracted away in a `enum class` as in the following: ```cpp enum class open_flags : int { bad = 0, rw = SQLITE_OPEN_READWRITE, ... } ``` ## Notes on Documentation The readme explains the concepts and gives concrete usage examples of the interface. ```cpp conn.execute(R"( create table if not exists author ( id integer primary key autoincrement, first_name text, last_name text ); create table if not exists library( id integer primary key autoincrement, name text unique, author integer references author(id) ); )" ); ``` ## Comparison to other libraries I notice that other libraries are using the `operator<<` that would be beneficial to Boost.SQLite as well, as it would mean seamless integration into many codebases. As well as future extension capabilities, if there is a need to extend the library in the future. ## Personal Usage Although I did not use Boost.SQLite directly in any production projects, I did study its design, and run its examples with the previous experience I have with other similar libraries in mind. ## Final Thoughts The need of a modern interface for such databases is becoming stronger by the day, the C API of SQLite makes the functionality of persistence and error handling very hard in modern C++ codebases. I would like to see the library with optional dependencies as well I am favorable in the merging of this library in Boost, however improvements in additional operators might be needed for completeness. (such as operator<<, operator>>) Amlal El Mahrouss.

On Tue, Aug 26, 2025 at 6:16 PM Amlal El Mahrouss via Boost < boost@lists.boost.org> wrote:
# Introduction Below is my review of the boost_sqlite library.
First off, I believe that this approach of providing a safer and much more expressive C++ interface on top of the SQLite C library, is a step toward the simplification and hardening of database development.
## Author's Background
I'm a professional C++ Developer. I've been using the Boost library in both hobby projects and professional ones. I have experience in interacting with similar connectors such as: ADO, ODBC, MySQL, JDBC.
## Initial Thoughts and Use Case
The library wraps the standard C API of SQLite into wrapped containers. Such as the connection, field, resultset containers. String helpers and the connection object seems to fulfill their duty correctly. Reflecting industry standard practice of such interfaces. The library is a perfect solution for applications written in C++ with persistence needs without the need of a SQL server. Moreover the boost style codebase makes it even easier to integrate into such applications.
## Thoughts on Design
The design is simple, easy to understand, and what I'd expect for such an interface. I believe it would meet my needs. ## Improvements Needed
The `handle_type` alias shall be set to a void* in order to hide the implementation details of the library. ```cpp using handle_type = void*; ```
May I ask why? I am not hiding the implementation (i.e. sqlite3) on purpose, so that users can just use the sqlite3 API or another library if they need. Not being able to do that has caused me much frustration in other libraries before.
The `connection` constructor with the `int flags` parameter should be abstracted away in a `enum class` as in the following: ```cpp enum class open_flags : int { bad = 0, rw = SQLITE_OPEN_READWRITE, ... } ```
## Notes on Documentation
The readme explains the concepts and gives concrete usage examples of the interface.
```cpp conn.execute(R"( create table if not exists author ( id integer primary key autoincrement, first_name text, last_name text ); create table if not exists library( id integer primary key autoincrement, name text unique, author integer references author(id) ); )" ); ```
## Comparison to other libraries
I notice that other libraries are using the `operator<<` that would be beneficial to Boost.SQLite as well, as it would mean seamless integration into many codebases. As well as future extension capabilities, if there is a need to extend the library in the future.
Which usage do you have in mind? As a query builder?
## Personal Usage
Although I did not use Boost.SQLite directly in any production projects, I did study its design, and run its examples with the previous experience I have with other similar libraries in mind.
## Final Thoughts
The need of a modern interface for such databases is becoming stronger by the day, the C API of SQLite makes the functionality of persistence and error handling very hard in modern C++ codebases.
I would like to see the library with optional dependencies as well
I am favorable in the merging of this library in Boost, however improvements in additional operators might be needed for completeness. (such as operator<<, operator>>)
Amlal El Mahrouss.
Thank you for your review!
_______________________________________________ Boost mailing list -- boost@lists.boost.org To unsubscribe send an email to boost-leave@lists.boost.org https://lists.boost.org/mailman3/lists/boost.lists.boost.org/ Archived at: https://lists.boost.org/archives/list/boost@lists.boost.org/message/BUL75BOX...
participants (3)
-
amlalelmahrouss@icloud.com
-
Klemens Morgenstern
-
Mohammad Nejati [ashtum]