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

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) A REST API server that uses connection pooling
  20. 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.

If you're using docker, you can use the ghcr.io/anarthal-containers/mysql8 container to simplify the process:

# If you're on a system supporting UNIX sockets. Note that /var/run/mysqld
# should be empty for this to work; you can specify a different directory, if it's not
> docker run -p 3306:3306 -v /var/run/mysqld:/var/run/mysqld -d ghcr.io/anarthal-containers/mysql8

# If you're on a system that does not support UNIX sockets
> docker run -p 3306:3306 -d ghcr.io/anarthal-containers/mysql8

# 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