This is the implementation of the IBM Db2 data handler for MindsDB.

Db2 is a database product from IBM. It is a Relational Database Management System (RDBMS). Db2 is designed to store, analyze, and retrieve the data efficiently. Db2 product is extended with the support of Object-Oriented features and non-relational structures with XML.


Before proceeding, ensure the following prerequisites are met:

  1. Install MindsDB locally via Docker or Docker Desktop.
  2. To connect IBM Db2 to MindsDB, install the required dependencies following this instruction.
  3. Install or ensure access to IBM Db2.


This handler is implemented using ibm_db/ibm_db_dbi, a Python library that allows you to use Python code to run SQL commands on the Db2 database.

The required arguments to establish a connection are as follows:

  • user is the username associated with the database.
  • password is the password required to authenticate your access to the database.
  • host is the hostname or IP address of the server.
  • port is the port through which TCP/IP connection is to be made.
  • database is the database name to be connected.
  • schema is required to get the tables.


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

    engine = 'DB2',
    parameters = {
        "user": "db2admin",
        "password": "1234",
        "host": "",
        "port": 25000,
        "schema_name": "db2admin",
        "database": "BOOKS"

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

FROM DB2_datasource.AUTHORS;