This is the implementation of the Microsoft SQL Server data handler for MindsDB.

Microsoft SQL Server is a relational database management system developed by Microsoft. As a database server, it stores and retrieves data as requested by other software applications, which may run either on the same computer or on another computer across a network.

Prerequisites

Before proceeding, ensure the following prerequisites are met:

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

Implementation

This handler is implemented using pymssql, the Python language extension module that provides access to Microsoft SQL Server from Python scripts.

The required arguments to establish a connection are as follows:

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

Usage

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

CREATE DATABASE mssql_datasource
WITH
    engine = 'mssql',
    parameters = {
      "host": "127.0.0.1",
      "port": 1433,
      "database": "master",
      "user": "sa",
      "password": "password"
    };

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

SELECT *
FROM mssql_datasource.example_tbl;