This plugin connects to a MariaDB database using the MariaDB Connector/C library. It supports connection pooling and reconnects. Settings are made using a MariaDB client .cnf file (a sample is provided in this folder).
Follow the instructions in our manual to add our package repository and then run the below command.
apt-get install halon-extras-mariadb
yum install halon-extras-mariadb
For the configuration schema, see mariadb.schema.json. Below is a sample configuration.
plugins:
- id: mariadb
config:
profiles:
- id: myprofile
cnf: /path/to/halon.cnf
pool_size: 32
These functions needs to be imported from the extras://mariadb
module path.
Returns the a MySQL class instance.
import { MySQL } from "extras://mariadb";
$mysql = MySQL("myprofile");
Execute the SQL statement on the server. A successful query result will return an associative array with an "result" array and the "affected" rows. On error an associative array with "errno", "error" and "sqlstate" will be provided.
import { MySQL } from "extras://mariadb";
$result = MySQL()->query("SELECT * FROM table where column = '".MySQL::escape_string($value)."';");
Returns the argument parameter escaped. Safe to be used within a SQL statement.
import { MySQL } from "extras://mariadb";
$parameter = MySQL::escape_string("my string");