mariadb_connect

Connect to a database server using a connection string

Syntax

#include <mysql.h>

MYSQL *mariadb_connect(MYSQL * mysql, const char *conn_str);

Parameter

  • mysql - mysql handle, which was previously allocated by mysql_init() and connected by mysql_real_connect().

  • conn_str- Connection string, containig connection parameters. A connection string contains key/value pairs, separated by a semicolon as used in ODBC. Supported keys are all configuration options which can be used in MariaDB configuration files. For a complete list check the chapter configuration files.

Return Value

Returns a MYSQL * handle or NULL on error.

Note

  • The connection string must contain at least one semicolon, otherwise it wil be interpreted as hostname.

  • Unknown or invalid keys will be ignored

  • mariadb_connect is not a function, but a macro which maps to mysql_real_connect: #define mariadb_connect(mysql, conn_str) mysql_real_connect((mysql),(conn_str), NULL, NULL, NULL, 0, NULL, 0)

Example

History

mariadb_connect() was added in Connector/C 3.3.0.

Last updated

Was this helpful?