0.1.3 • Published 1 year ago

node-red-contrib-mysql-storage-plugin v0.1.3

Weekly downloads
3
License
MIT
Repository
github
Last release
1 year ago

Node Red MySQL Storage Plugin

This plugin allows you to store your flows and library entries in MySQL. Thanks to adibenmati whose MongoDb storage plugin served as a template to create this one.

Getting Started

For this one, you'll need a separate script to start your Node Red, as per the guide for running a custom Node-Red inside your process:

http://nodered.org/docs/embedding.html

Firstly, require the module:

npm install --save node-red-contrib-mysql-storage-plugin

Then, in your settings, add:

const storageModule = require('node-red-contrib-mysql-storage-plugin');
const sqlConfig = {
  user: 'sa',
  password: 'myPassword',
  host: 'SQL01',
  database: 'NodeRed',
  port: 3306
};

// Node-RED settings
const settings = {
  ...
  storageModule,
  storageModuleOptions: {
    sqlConfig,
    //optional
    //set the collection name that the module would be using
    tableNames:{
      flows: 'NodeRedFlows',
      sessions: 'NodeRedSessions',
      credentials: 'NodeRedCredentials',
      settings: 'NodeRedSettings',
      library: 'NodeRedLibrary'
    }
  },
  ...
};

Note that for sqlConfig I recommend storing all of the values in your .env file instead of hardcoding them like above. Then your sqlConfig could just look like this:

const sqlConfig = {
  user: process.env.MYSQL_USER,
  password: process.env.MYSQL_PASSWORD,
  host: process.env.MYSQL_SERVER,
  database: process.env.MYSQL_DATABASE,
  port: process.env.MYSQL_PORT
};

Lastly, you will need to create the tables by running the CreateTables.sql file against your database.

TODO

  1. I do not have the library functions working completely yet - you can save library entires but I haven't figured out what I am missing to recall them. PRs welcome!
0.1.3

1 year ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago