MySQL and MariaDB are widespread SQL database servers. MySQL clients connect to the server in order to issue SQL queries. For this purpose, MySQL employs a dedicated protocol. Boost.MySQL is an implementation of the client side of this protocol.
This library is a full implementation of the MySQL client/server protocol. It aims to expose the protocol primitives in an efficient but easy-to-use way. It is similar in scope to the official libmysqlclient, but interoperable with Asio, safer and more expressive. Note that Boost.MySQL does not use libmysqlclient: it's a full implementation of the MySQL protocol, which makes it natively compatible with Asio.
This library is relatively low level. It gives you access to text SQL queries and prepared statements. Don't expect an ORM. This section presents a quick tour over the main library capabilities.
The design goals of this library are:
table("orders").select(["id", "quantity"]).where("id", 42).
If any of the following statements is true, you may consider using Boost.MySQL:
Use cases may include web servers, ETL processes and IoT systems.
It may not be a good fit for you if:
Boost.MySQL is a header-only library. The following additional libraries are needed at link time:
If you are using CMake with a Boost distribution (e.g. one you downloaded
and built with
b2), you can
use the following code to get the required setup:
project(boost_mysql_example LANGUAGES CXX) find_package(Boost REQUIRED COMPONENTS headers) find_package(Threads REQUIRED) find_package(OpenSSL REQUIRED) add_executable(main main.cpp) target_link_libraries(main PRIVATE Boost::headers Threads::Threads OpenSSL::Crypto OpenSSL::SSL)
Boost.MySQL has been tested with the following RDBMS systems:
I would like to specially acknowledge Richard Hodges (email@example.com) for his invaluable technical guidance during development. Thanks also to Christian Mazakas for his ideas in early stages, and to Klemens Morgenstern and and Vinnie Falco for his techincal advice. Without you, this library would not exist.