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

TimescaleDB is an open-source relational database that is optimized for time-series data. It is designed to handle large volumes of data. It enables you to query and analyze data in real-time. TimescaleDB can be used for a wide range of applications, including IoT, finance, and monitoring.

Prerequisites

Before proceeding, ensure the following prerequisites are met:

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

Implementation

This handler is implemented using the psycopg2 library, which is a PostgreSQL adapter for the Python programming language. TimescaleDB is built on top of PostgreSQL and therefore can be accessed using the same client libraries and APIs.

The required arguments to establish a connection are as follows:

*host is the the host name or IP address of the TimescaleDB server. *port is the port to use when connecting with the TimescaleDB server. *database is the database name to use when connecting with the TimescaleDB server. *user is the user to authenticate the user with the TimescaleDB server. *password is the password to authenticate the user with the TimescaleDB server.

Usage

Before attempting to connect to a TimescaleDB server using MindsDB, ensure that it accepts incoming connections using this guide.

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

CREATE DATABASE timescaledb_datasource
WITH
    engine = 'timescaledb',
    parameters = {
        "host": "examplehost.timescaledb.com",
        "port": 5432,
        "user": "example_user",
        "password": "my_password",
        "database": "tsdb"
    };

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

SELECT *
FROM timescaledb_datasource.sensor;