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

MySQL is a fast, reliable, and scalable open-source database. It has been in development for more than 25 years and has been used in many production environments since.

Prerequisites

Before proceeding, ensure the following prerequisites are met:

  1. Install MindsDB locally via Docker or use MindsDB Cloud.
  2. To connect MySQL to MindsDB, install the required dependencies following this instruction.
  3. Install or ensure access to MySQL.

Implementation

This handler is implemented using the mysql-connector-python library. It’s a Python client for MySQL that doesn’t depend on any MySQL C libraries.

Connect MySQL to MindsDB by providing the URL parameter. Learn more here.

Usage

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

CREATE DATABASE mysql_datasource
WITH
  ENGINE = 'mysql',
  PARAMETERS = {
    "url": "mysql://user@127.0.0.1:3306"
  };

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

SELECT *
FROM mysql_datasource.example_table;