Implementing MySQL

Written By Chetan Iterate ()

Updated at April 19th, 2022

Whenever we need to collect data by forms, saving Tabular data, or simple account handling tasks, we always have the need for a database, and with interplay, it is simple as a walk in the park! You don't even have to do anything new, simple SQL Queries are enough to manipulate data.

Prerequisites:

1) As we are implementing MySQL, a deployed MySQL Server with valid credentials.

Steps:

1) Search for 'inject' which look like this:

and drag-and-drop in the editor.

Search and drop the 'function' node which looks like this:

Search and drop the 'MySQL' Node which looks like this:

Finally, search 'Console' and drop:

2) Connect them as shown

     So we explain what the flow and their node actually do:

  1.      Inject triggers the SQL query to the database server.
  2.      Node.js function used to set MySQL Query to msg. topic.
  3.      MySQL node simply takes the query and returns its output as standard JSON.


3 ) Double Click on 'Inject' Node, To reveal window as:

Here we are injecting a query

SELECT * from USER;

Where in Node.js function it is converted as a string input and parsed as a parameter.

4) Edit 'MySQL' Node By simply Double-clicking 'MySQL' Node:

As we are creating a new Database profile click on 

Then Credentials: 6) After Connection with Database, the 'MySQL' node should be tagged with 'OK' as Shown Below. Else if the 'Connection Refused' Tag is displayed, please check the database permissions and database settings.

(For this example This database consists of one table named 'USER' and defined as)

7) By double-clicking 'Console' Node, modify its settings as given below:

8) The console Node is required for the viewing output of a given payload output. By default, it shows 

 msg.payload

 output.

8) Now simply deploy and trigger the inject node, by clicking the square left of 'Inject Node'.

7) You may think about the result, simply click on the info icon on the left hand menu

and then click on the "bug" icon in the pop up window

You could see the output similar to this


Here Object

 msg.payload

 

 parses output which the query response returns in JSON, depending on the query.

As this example we can use our SQL Queries, Generate queries by functions, even running scripts.

Was this article helpful?