Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the develop branch, built from commit be80102e55.
PrevUpHomeNext

Examples

Welcome to Boost.MySQL examples. If you are intending to run the examples, please go through the setup first.

Here is a list of available examples:

  1. Async functions using callbacks
  2. Async functions using futures
  3. Async functions using stackful coroutines
  4. Async functions using C++20 coroutines
  5. Setting timeouts
  6. Using prepared statements with the dynamic interface (C++11)
  7. Using prepared statements with the static interface (C++14)
  8. Using stored procedures with the dynamic interface (C++11)
  9. Using stored procedures with the static interface (C++14)
  10. Metadata
  11. UNIX sockets
  12. Setting SSL options
  13. Using multi-queries to source a .sql file
  14. (Experimental) Using type-erased connections
  15. (Experimental) Batch inserts using client-side query formatting
  16. (Experimental) Generic batch inserts with Boost.Describe: extending format_sql
  17. (Experimental) Implements a query with several dynamic filters using client-side query formatting
  18. (Experimental) Implements a dynamic UPDATE query for PATCH-like update semantics using client-side query formatting
  19. (Experimental) Prepares, executes and closes statements in batch using the pipeline API
  20. (Experimental) A REST API server that uses connection pooling
  21. The BoostServerTech chat project uses Boost.MySQL and Boost.Redis to implement a chat server

Setup

To run the examples, you need a MySQL server you can connect to. Examples make use of a database named boost_mysql_examples. The server hostname and credentials (username and password) are passed to the examples via the command line.

You can spin up a server quickly by using Docker:

# Remove the "-v /var/run/mysqld:/var/run/mysqld" part if you don't need UNIX sockets
> docker run --name some-mysql -p 3306:3306 -v /var/run/mysqld:/var/run/mysqld -d -e MYSQL_ROOT_PASSWORD= -e MYSQL_ALLOW_EMPTY_PASSWORD=1 -d mysql

# All the required data can be loaded by running example/db_setup.sql.
# If you're using the above container, the root user has a blank password
> mysql -u root < example/db_setup.sql

Please note that this container is just for demonstrative purposes, and is not suitable for production.

The root MySQL user for these containers is root and it has an empty password.


PrevUpHomeNext