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.


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.

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/db2_handler) and run this command: pip install -r requirements.txt.


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;