node-red-mysql_node-red-contrib-sqldbs

Node-RED node to access different database engines

node-red-contrib-sqldbs

Node-RED nodes to work with a database

that can be either MSSQL, MySQL, SQLite, or PostgreSQL server.

Install

Install from npm

npm install node-red-contrib-sqldbs

Usage

This package contains one node to select, update, insert, or delete records from a specified database engine. It can

work with Microsoft SQL Server, MySql, SQLite, and ProgreSQL by selecting proper database dialect

Query node usage:

You will need to fill in the following fields:

-- Database host name.

-- User name to access the database.

-- Password for the user name above.

-- Database name

-- Dialect for different database engines, currently, it supports MSSQL, MYSQL, SQLite, and PostgreSQL.

-- Query Type that the query is for. It can be either select, insert, update, and delete

Node usage:

The returned data will be stored in msg.payload and it will contains two array.

You should just need to access the first object of the array to retrieve data

returned from the database query.

So for example, you might create a function node that flows into your sqldbs node

with code like this to find if the user exists in the table (please make a special

note to "as count". It will serve as the key of the return to retrieve the data.

However, if you use "select * from user", the column name will serve as the key

name):

msg.topic = "select count(*) as count from user where username = '" + msg.payload.username + "'";

return msg;

Then, you can use a switch function after sqldbs node to check if the user exist:

if msg.payload[0][0].count > 0

if msg.payload[0][0].count <= 0

Currently, only MSSQL server database have been tested but not others. Please let

me know if you have any issue.

Authors

Repository

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值