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

Couchbase is an open-source, distributed multi-model NoSQL document-oriented database software package optimized for interactive applications. These applications may serve many concurrent users by creating, storing, retrieving, aggregating, manipulating, and presenting data.

Prerequisites

Before proceeding, ensure the following prerequisites are met:

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

Implementation

This handler is implemented using the couchbase library, the Python driver for Couchbase.

The required arguments to establish a connection are as follows:

  • host: the host name or IP address of the Couchbase server
  • bucket: the bucket name to use when connecting with the Couchbase server
  • user: the user to authenticate with the Couchbase server
  • password: the password to authenticate the user with the Couchbase server
  • scope: scopes are a level of data organization within a bucket. If omitted, will default to _default

If you are using Couchbase Capella, the host should be the connection string for the cluster. When you navigate to your cluster, the connection string can be found under the Connect tab. It will also be required to whitelist the machine(s) that will be running MindsDB and database credentials will need to be created for the user. These steps can also be taken under the Connect tab.

In order to make use of this handler and connect to a Couchbase server in MindsDB, the following syntax can be used. Note, that the example uses the default travel-sample bucket which can be enabled from the couchbase UI with pre-defined scope and documents.

CREATE DATABASE couchbase_datasource
WITH
engine='couchbase',
parameters={
    "host": "127.0.0.1",
    "bucket": "travel-sample",
    "user": "admin",
    "password": "password",
    "scope": "inventory"
};

Usage

Now, you can use this established connection to query your database as follows:

SELECT * FROM couchbase_datasource.airport