| Home | Libraries | People | FAQ | More

#### any_connection

(EXPERIMENTAL) A type-erased connection to a MySQL server.

##### Synopsis

Defined in header `<boost/mysql/any_connection.hpp>`

    class any_connection

##### Types

Name | Description
--- | ---
executor_type | The executor type associated to this object.

##### Member Functions

Name | Description
--- | ---
any_connection [constructor] | Constructs a connection object from an executor and an optional set of parameters. — Constructs a connection object from an execution context and an optional set of parameters. — Move constructor.
async_close | Cleanly closes the connection to the server. — Cleanly closes the connection to the server.
async_close_statement | Closes a statement, deallocating it from the server. — Closes a statement, deallocating it from the server.
async_connect | Establishes a connection to a MySQL server. — Establishes a connection to a MySQL server.
async_execute | Executes a text query or prepared statement. — Executes a text query or prepared statement.
async_ping | Checks whether the server is alive. — Checks whether the server is alive.
async_prepare_statement | Prepares a statement server-side. — Prepares a statement server-side.
async_read_resultset_head | Reads metadata for subsequent resultsets in a multi-resultset operation. — Reads metadata for subsequent resultsets in a multi-resultset operation.
async_read_some_rows | Reads a batch of rows. — Reads a batch of rows. — Reads a batch of rows.
async_reset_connection | Resets server-side session state, like variables and prepared statements. — Resets server-side session state, like variables and prepared statements.
async_run_pipeline | Runs a set of pipelined requests. — Runs a set of pipelined requests.
async_set_character_set | Sets the connection's character set, as per SET NAMES. — Sets the connection's character set, as per SET NAMES.
async_start_execution | Starts a SQL execution as a multi-function operation. — Starts a SQL execution as a multi-function operation.
backslash_escapes | Returns whether backslashes are being treated as escape sequences.
close | Cleanly closes the connection to the server. — Cleanly closes the connection to the server.
close_statement | Closes a statement, deallocating it from the server. — Closes a statement, deallocating it from the server.
connect | Establishes a connection to a MySQL server. — Establishes a connection to a MySQL server.
current_character_set | Returns the character set used by this connection.
execute | Executes a text query or prepared statement. — Executes a text query or prepared statement.
format_opts | Returns format options suitable to format SQL according to the current connection configuation.
get_executor | Retrieves the executor associated to this object.
meta_mode | Returns the current metadata mode that this connection is using.
operator= | Move assignment.
ping | Checks whether the server is alive. — Checks whether the server is alive.
prepare_statement | Prepares a statement server-side. — Prepares a statement server-side.
read_resultset_head | Reads metadata for subsequent resultsets in a multi-resultset operation. — Reads metadata for subsequent resultsets in a multi-resultset operation.
read_some_rows | Reads a batch of rows. — Reads a batch of rows. — Reads a batch of rows.
reset_connection | Resets server-side session state, like variables and prepared statements. — Resets server-side session state, like variables and prepared statements.
run_pipeline | Runs a set of pipelined requests. — Runs a set of pipelined requests.
set_character_set | Sets the connection's character set, as per SET NAMES. — Sets the connection's character set, as per SET NAMES.
set_meta_mode | Sets the metadata mode.
start_execution | Starts a SQL execution as a multi-function operation. — Starts a SQL execution as a multi-function operation.
uses_ssl | Returns whether the connection negotiated the use of SSL or not.
~any_connection [destructor] | Destructor.

##### Description

Represents a connection to a MySQL server. Compared to `connection`, this class:

- Is type-erased. The type of the connection doesn't depend on the transport being used. Supported transports include plaintext TCP, SSL over TCP and UNIX domain sockets.
- Is easier to connect, as `connect` and `async_connect` handle hostname resolution.
- Can always be re-connected after being used or encountering an error.
- Doesn't support default completion tokens.

Provides a level of performance similar to `connection`.

This is a move-only type.

##### Thread safety

Distinct objects: safe.

Shared objects: unsafe.

This class is not thread-safe: for a single object, if you call its member functions concurrently from separate threads, you will get a race condition.

##### Experimental

This part of the API is experimental, and may change in successive releases without previous notice.