Prerequisites
Before proceeding, ensure the following prerequisites are met:- Install MindsDB locally via Docker or Docker Desktop.
Connection
Establish a connection to MongoDB from MindsDB by executing the following SQL command:host: The connection string of the MongoDB server that includes user (admin), password (admin_pass), host and port (demo.mongodb.net), and database (public).database: If the connection string does not include the/databasepath, provide it in this parameter.
username: The username associated with the database.password: The password to authenticate your access.host: The host of the MongoDB server.port: The port through which TCP/IP connection is to be made.database: The database name to be connected.
Usage
Retrieve data from a specified collection by providing the integration name and collection name:The above examples utilize
mongodb_datasource as the datasource name, which is defined in the CREATE DATABASE command.At the moment, this integration only supports
SELECT and UPDATE queries.Troubleshooting Guide
Database Connection Error- Symptoms: Failure to connect MindsDB with the MongoDB server.
- Checklist:
- Make sure the MongoDB server is active.
- Confirm that host and credentials provided are correct. Try a direct MongoDB connection using a client like MongoDB Compass.
- Ensure a stable network between MindsDB and MongoDB. For example, if you are using MongoDB Atlas, ensure that the IP address of the machine running MindsDB is whitelisted.
Unknown statement- Symptoms: Errors related to the issuing of unsupported queries to MongoDB via the integration.
- Checklist:
- Ensure the query is a
SELECTorUPDATEquery.
- Ensure the query is a
SQL statement cannot be parsed by mindsdb_sql- Symptoms: SQL queries failing or not recognizing collection names containing special characters.
- Checklist:
- Ensure table names with special characters are enclosed in backticks.
- Examples:
- Incorrect: SELECT * FROM integration.travel-data
- Incorrect: SELECT * FROM integration.‘travel-data’
- Correct: SELECT * FROM integration.`travel-data`