n8n-nodes-database-connector
v0.1.0
Published
The **Database Connector** node for n8n allows you to easily connect to MySQL and MongoDB databases, retrieve table names (for MySQL), or collection names (for MongoDB). It supports both traditional MySQL databases and MongoDB Atlas, providing a simple wa
Downloads
92
Maintainers
Readme
Database Connector Node for n8n
The Database Connector node for n8n allows you to connect to MySQL and MongoDB databases and retrieve the list of tables (for MySQL) or collections (for MongoDB). This node supports both MySQL and MongoDB, providing flexibility for database automation workflows.
Features:
- MySQL Support: Connect to MySQL databases and retrieve the list of tables.
- MongoDB Support: Connect to MongoDB (including MongoDB Atlas) and retrieve the list of collections.
- Error Handling: Provides detailed error messages in case of connection or query failures.
- Simple Configuration: Easily configure database connection parameters like host, port, username, password, and database name.
Installation
To install this custom node, follow these steps:
- Clone or download this repository.
- Follow the official n8n custom node installation guide.
- Install the necessary dependencies:
- For MySQL: Install mysql2.
- For MongoDB: Install mongodb.
Configuration
Node Settings
Once you add the Database Connector node to your workflow, you can configure the following parameters:
Database Type (options):
- Choose between
MySQL
orMongoDB
for the database type. - Default:
mysql
- Description: Select the type of database you want to connect to.
- Choose between
Host (string):
- Provide the host for the database (e.g.,
localhost
for MySQL or MongoDB Atlas connection string). - Default:
localhost
- Description: The host of the database server.
- Provide the host for the database (e.g.,
Port (number):
- Provide the port for the database connection.
- Default:
3306
for MySQL. Leave empty for MongoDB Atlas. - Description: The port to connect to the database (leave empty for MongoDB Atlas).
Username (string):
- The username for the database connection.
- Default:
''
- Description: The username to authenticate the database connection.
Password (string):
- The password for the database connection.
- Default:
''
- Description: The password to authenticate the database connection.
Database Name (string):
- The name of the database to connect to.
- Default:
''
- Description: The specific database to use on the selected database server.
Example Workflow
Input Data:
{
"dbType": "mysql",
"host": "localhost",
"port": 3306,
"username": "root",
"password": "password",
"database": "test_db"
}
Node Configuration:
- Database Type: mysql
- Host: localhost
- Port: 3306
- Username: root
- Password: password
- Database Name: test_db
Output Data (Example):
If the database is MySQL, the output might look like this:
{
"tableName": "users"
}
If the database is MongoDB, the output might look like this:
{
"collectionName": "customers"
}
In this example:
- tableName (for MySQL): The name of the table in the database.
- collectionName (for MongoDB): The name of the collection in the database.