Description
MindsDB lets you connect to your favorite databases, data warehouses, data lakes, etc., via theCREATE DATABASE
command.
The MindsDB SQL API supports creating connections to integrations by passing the
connection parameters specific per integration. You can find more in the
Supported Integrations chapter.
Syntax
Let’s review the syntax for theCREATE DATABASE
command.
Name | Description |
---|---|
datasource_name | Identifier for the data source to be created. |
engine_name | Engine to be selected depending on the database connection. |
PARAMETERS | {"key": "value"} object with the connection parameters specific for each engine. |
SQL Commands Resulting in the Same Output Please note that the
keywords/statements enclosed within square brackets are optional. Also, by
default, the engine is
mindsdb
if not provided otherwise. That yields the
following SQL commands to result in the same output.What’s available on your installation
Here is how you can query for all the available data handlers used to create database connections.Or, alternatively:And here is how you can query for all the connected databases:Or, alternatively:
Example
Connecting a Data Source
Here is an example of how to connect to a MySQL database.Listing Linked Databases
You can list all the linked databases using the command below.Making your Local Database Available to MindsDB
When connecting your local database to MindsDB Cloud, you should expose the local database server to be publicly accessible. It is easy to accomplish using Ngrok Tunnel. The free tier offers all you need to get started. The installation instructions are easy to follow. Head over to the downloads page and choose your operating system. Follow the instructions for installation. Then create a free account at Ngrok to get an auth token that you can use to configure your Ngrok instance. Once installed and configured, run the following command to obtain the host and port for your localhost atport-number
.
localhost:5432
, use the following command:
4.tcp.ngrok.io:15093
instead of
localhost:5432
.
So to connect your local database to the MindsDB GUI, use the Forwarding
information. The host is 4.tcp.ngrok.io
, and the port is 15093
.
Proceed to create a database connection in the MindsDB GUI by executing the
CREATE DATABASE
statement with the host and port number obtained from
Ngrok.
DROP DATABASE
statement.
RETRAIN
your predictors, please ensure the database
connection has the same name you used when creating the predictor to avoid
failing to retrain.