This is the implementation of the MariaDB data handler for MindsDB.

MariaDB is a community-developed, commercially supported fork of the MySQL relational database management system (RDBMS), intended to remain free and open-source software under the GNU General Public License. MariaDB is intended to maintain high compatibility with MySQL, library binary parity and exact matching with MySQL APIs and commands, allowing it in many cases to function as a replacement for MySQL.

Implementation

This handler is implemented using mysql-connector, a self-contained Python driver for communicating with MariaDB servers.

The required arguments to establish a connection are as follows:

  • user is the database user.
  • password is the database password.
  • host is the host IP address or URL.
  • port is the port used to make TCP/IP connection.
  • database is the database name.

There are several optional arguments that can be used as well.

  • ssl indicates whether SSL is enabled (True) or disabled (False).
  • ssl_ca is the SSL Certificate Authority.
  • ssl_cert stores the SSL certificates.
  • ssl_key stores the SSL keys.

If you installed MindsDB locally via pip, you need to install all handler dependencies manually. To do so, go to the handler’s folder (mindsdb/integrations/handlers/mariadb_handler) and run this command: pip install -r requirements.txt.

Usage

In order to make use of this handler and connect to the MariaDB database in MindsDB, the following syntax can be used:

CREATE DATABASE maria_datasource
WITH
  engine = 'mariadb',
  parameters = {
    "host": "127.0.0.1",
    "port": 3306,
    "database": "mariadb",
    "user": "root",
    "password": "password"
  };

You can use this established connection to query your table as follows.

SELECT *
FROM maria_datasource.example_table;