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

SurrealDB is an innovative NewSQL cloud database, suitable for serverless applications, jamstack applications, single-page applications, and traditional applications.

Prerequisites

Before proceeding, ensure the following prerequisites are met:

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

Implementation

This handler was implemented by using the python library pysurrealdb.

The required arguments to establish a connection are:

  • host: the host name of the Surrealdb connection
  • port: the port to use when connecting
  • user: the user to authenticate
  • password: the password to authenticate the user
  • database: database name to be connected
  • namespace: namespace name to be connected

Usage

To establish a connection with our SurrealDB server which is running locally with the public cloud instance. We are going to use ngrok tunneling to connect cloud instance to the local SurrealDB server. You can follow this guide for that.

Let’s make the connection with the MindsDB public cloud

CREATE DATABASE exampledb
WITH ENGINE = 'surrealdb',
PARAMETERS = {
  "host": "6.tcp.ngrok.io",
  "port": "17141",
  "user": "root",
  "password": "root",
  "database": "testdb",
  "namespace": "testns"
};

Please change the host and port properties in the PARAMETERS clause based on the values which you got.

We can also query the dev table which we created with

SELECT * FROM exampledb.dev;