Method and system for converting database data in Internet of Things by utilizing development tool
Connecting the database and converting data into JSON format through Node-RED development tools has solved the technical gap in data transmission between database and IoT platform, and realized efficient data operation and format conversion, which is suitable for industrial Internet of Things and big data projects.
Patent Information
- Application Number
- CN202411165010.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-12-17
AI Technical Summary
In the prior art, the data transmission effect between the database and the Internet of Things platform is poor, resulting in the low docking function of local data and the Internet of Things platform, which cannot facilitate subsequent data statistics and analysis.
Use Node-RED development tools to build an environment, connect to the target database, write query statements, realize data addition, deletion, and modification operations, and convert data into JSON format to meet the requirements of Internet data transmission.
It realizes efficient operation of historical data in the target database and JSON data format conversion, breaks down local data information islands, simplifies data transmission, and is suitable for smart information projects such as industrial Internet of Things, big data and cloud platforms.
Smart Images

Figure CN119149005A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of communication technology, and in particular relates to a method and system for converting database data in an Internet of Things using a development tool. Background Art
[0002] Node-RED is a powerful tool for building IoT applications with high promotion value. Node-RED uses a visual programming method to perform tasks by connecting predefined code blocks (nodes), which simplifies the process of code writing. It is widely used in the field of IoT and can be used to draw processes, connect nodes, and easily integrate IoT devices with applications. Node-RED is a process-based programming tool that improves the programming efficiency of IoT terminal devices and can be used to trigger automation events. In addition to its wide application in the field of IoT, Node-RED has also been used in other fields such as social development and browser process editing.
[0003] At present, the Internet of Things technology and big data analysis technology have become the main projects actively developed and promoted by major Internet companies. However, most cloud computing, cloud storage, and cloud analysis data require uploading local data. Local data storage is generally stored in various databases, such as Microsoft SQL Server database, MySQL database, InfluxDB database, MongoDB database, etc. This leads to inconsistent data storage formats, data query codes or methods. Therefore, in general, local databases cannot directly connect to cloud platforms for data. The commonly used data transmission format on the Internet is JSON format, so this requires that local data and cloud platform connection meet the following two conditions:
[0004] ①First, use the query statement of a specific database to filter out the required data from the local database;
[0005] ②Convert the filtered data into JSON data format to meet the requirements of Internet data transmission format.
[0006] Through the above analysis, the problems and defects of the existing technology are: the data transmission effect between the existing technology database and the Internet of Things platform is poor, and the data docking function between local data and the Internet of Things platforms of various manufacturers is low, which cannot bring convenience to subsequent data statistics and data analysis. Summary of the invention
[0007] In order to overcome the problems existing in the related art, the disclosed embodiments of the present invention provide a method and system for converting database data in the Internet of Things using a development tool, and more particularly, relate to an application of a database in the Internet of Things using the Node-RED development tool.
[0008] The technical solution is as follows: A method for converting database data in the Internet of Things using a development tool includes:
[0009] S1, build the Node-RED development environment and run it;
[0010] S2, use the Node-RED development environment to connect to the target database;
[0011] S3, use the Node-RED development environment to write database query statement code and perform data screening;
[0012] S4, use the Node-RED development environment to implement the operations of adding, deleting, and modifying data in the database;
[0013] S5, use the Node-RED development environment to convert the filtered data into JSON format.
[0014] In step S1, build the Node-RED development environment and run it, including:
[0015] (1) Install the Node-RED platform operating environment;
[0016] (2) Use the CMD command prompt to run the Node-RED platform to collect and transmit on-site equipment data.
[0017] In step (1), install the Node-RED platform operating environment, including:
[0018] (1.1) Search and download the Node.msi software installation package;
[0019] (1.2) Install the Node.msi software on the Node.msi software installation package;
[0020] (1.3) Start the Windows command prompt;
[0021] (1.4) Copy the code npm config set registry http: / / registry.npmmirror.com into the input box and run the code;
[0022] (1.5) Copy the code npminstall-g --unsafe-perm node-red pm2pm2-windows-startup pm2-windows-service into the input box and run the code;
[0023] In step (2), use the CMD command prompt to run the Node-RED platform, including:
[0024] (2.1) Open the command prompt of Windows system;
[0025] (2.2) Copy the code C:\Users\Administrator\AppData\Roaming\npm\node-red.cmd into the input box and run the code.
[0026] In step S2, the Node-RED development environment is used to connect to the target database, including:
[0027] S201, establishing a connection character block with a target database;
[0028] S202, setting connection parameters.
[0029] In step S201, a connection character block with a target database is established, including:
[0030] After the Node-RED development environment is installed and successfully run, enter the graphical editor interface of the Node-RED development environment in the browser;
[0031] In the storage function area of the sidebar of the graphic editor interface, respectively obtain the inject function block, the MSSQL function block, and the debug function block, drag them into the working area of the graphic editor, and connect them in sequence.
[0032] In step S202, connection parameters are set, including:
[0033] (1) Connection parameters, which are used to establish a data channel between the Node-RED development environment and the target database. The Connection parameters include the Name parameter for naming the data link, the Server parameter for filling in the IP address of the target database, the Username parameter for the user name used to log in to the target database, the Password parameter for the user name and password corresponding to the Username, and the Database parameter for providing the target database name.
[0034] (2) Name parameters, including: INSERT for inserting a piece of data into the target database, DELETE for deleting a piece of data in the target database, UPDATE for changing the value of a piece of data in the target database, and SELECT for querying the value of a piece of data in the target database;
[0035] (3) Query mode parameter: used to select the default value Query;
[0036] (4) Query parameter: used to select the default value Editor and edit the SQL Server database statement in the input box;
[0037] (5)Parameters parameter: used to select the default value msg.queryParams;
[0038] (6) Output property parameter: used to fill in msg.payload;
[0039] (7) Output type parameter: used to select Driver Output;
[0040] (8)Error Handing parameter: used to select Send in msg.error.
[0041] In step S3, use the Node-RED development environment to write database query statement code and perform data screening, including:
[0042] On the basis of step S2, a connection with the target database is established, and the Select statement in the database is used to query the historical data of the table structure in the database, and the query result is returned after the query is completed.
[0043] In step S4, the Node-RED development environment is used to implement the operations of adding, deleting, and modifying data in the database, including:
[0044] On the basis of step S2, a connection with the target database is established, and Insert statements, Delete statements, and Update statements in the database are used to implement operations of adding, deleting, and modifying the table structure in the database, and the execution result is returned.
[0045] In step S5, the filtered data is converted into JSON format using the Node-RED development environment, including: based on the operations of steps S1, S2, S3, and S4, a new JSON function block is added to convert the data format into JSON format data; the parameter function settings of the new JSON function block are as follows:
[0046] Operation parameters: used to select the conversion between JSON string and object;
[0047] Attribute parameter: used to fill in msg.payload;
[0048] Object to JSON parameter: used to check the formatting JSON string.
[0049] Another object of the present invention is to provide a system for converting database data in the Internet of Things using a development tool, the system implementing the method for converting database data in the Internet of Things using a development tool, the system comprising:
[0050] Node-RED building module, used to build and run the Node-RED development environment;
[0051] The target database connection module is used to connect to the target database using the Node-RED development environment;
[0052] The database query statement code writing module is used to write database query statement codes and perform data screening using the Node-RED development environment;
[0053] The operation module is used to use the Node-RED development environment to add, delete, and modify data in the database;
[0054] The JSON format conversion module is used to convert the filtered data into JSON format using the Node-RED development environment.
[0055] In combination with all the above technical solutions, the beneficial effects of the present invention are as follows: the present invention uses the Node-RED development tool to implement operations such as adding, deleting, modifying, and checking the historical data in the target database; the queried historical data is converted into JSON data format using the Node-RED development tool. The present invention uses the computer Node-RED development environment to realize data transmission between the database and the Internet of Things platform, and is suitable for smart information projects such as industrial Internet of Things, big data, and cloud platforms.
[0056] The present invention can simply and reliably connect products of different database manufacturers to an IT network, and realize functions such as data connection between local data and the Internet of Things platforms of various manufacturers, so as to facilitate subsequent data statistics and data analysis.
[0057] The present invention fills the technical gap in the data transmission channel between the Internet of Things platform and the local database in the field of IT technology, and the present invention solves the technical problem of converting the data format of the local database into the JSON data format. The present invention uses the computer Node-RED development environment to realize the data transmission problem between the database and the Internet of Things platform, and is suitable for smart information projects such as industrial Internet of Things, big data, and cloud platforms. The present invention fills the technical gap in the data transmission channel between the Internet of Things platform and the local database in the field of IT technology, and the present invention solves the technical problem of converting the data format of the local database into the JSON data format. The present invention can simply and reliably connect the products of different database manufacturers to the IT network, realize the functions such as data docking between local data and the Internet of Things platforms of various manufacturers, so as to facilitate subsequent data statistics and data analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] The accompanying drawings herein are incorporated in and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description, serve to explain the principles of the present disclosure;
[0059] Figure 1 It is a flow chart of a method for converting database data in the Internet of Things using a development tool provided by an embodiment of the present invention;
[0060] Figure 2 The inject function block, MSSQL function block and debug function block provided in the embodiment of the present invention are dragged into the working area of the graphic editor and connected to the effect diagram in sequence;
[0061] Figure 3 This is an interface diagram for setting parameters of a function block provided by an embodiment of the present invention;
[0062] Figure 4 It is a diagram of the five sub-parameter interfaces of the Connection parameter provided in an embodiment of the present invention;
[0063] Figure 5 It is a schematic diagram of four functional blocks of Name parameters provided in an embodiment of the present invention;
[0064] Figure 6 A new JSON function block is added to convert the data format into a data principle diagram in JSON format provided by an embodiment of the present invention;
[0065] Figure 7 It is a parameter function setting interface diagram of the JSON function block provided by an embodiment of the present invention;
[0066] Figure 8 This is a diagram of an operation result display interface provided by an embodiment of the present invention;
[0067] Fig. 9This is a diagram of a historical data analysis and statistics interface on an IoT smart screen provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0068] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention, so the present invention is not limited by the specific implementation disclosed below.
[0069] The innovation of the present invention lies in: the present invention utilizes the low-code development environment Node-RED to realize basic operations such as adding, deleting, modifying and checking data in the local database, and converts the local data into the JSON data format using the Node-RED development environment, so that the data conforms to the data format of the Internet communication protocol, and can interact with data on other Internet platforms, breaking the information island problem of local data.
[0070] Embodiment 1, as Figure 1 As shown, the method for converting database data in the Internet of Things using a development tool provided by an embodiment of the present invention includes:
[0071] S1, build the Node-RED development environment and run it;
[0072] S2, use the Node-RED development environment to connect to the target database;
[0073] S3, use the Node-RED development environment to write database query statement code and perform data screening;
[0074] S4, use the Node-RED development environment to implement the operations of adding, deleting, and modifying data in the database;
[0075] S5, use the Node-RED development environment to convert the filtered data into JSON format.
[0076] In step S1 of the embodiment of the present invention, a Node-RED platform operating environment for field equipment data collection and transmission is established, including:
[0077] (1) Install the Node-RED development environment.
[0078] Run in cmd in administrator mode:
[0079] npm config set registry http: / / registry.npmmirror.com
[0080] npminstall–g--unsafe-perm node-red pm2 pm2-windows-startup pm2-windows-service;
[0081] (2) Operation:
[0082] C:\Users\Administrator\AppData\Roaming\npm\node-red.cmd
[0083] or
[0084] pm2
[0085] start C:\Users\Administrator\AppData\Roaming\npm\node_modules\node-red\red.js.
[0086] Exemplarily, the method specifically includes the following steps:
[0087] (1) Install the Node-RED platform operating environment:
[0088] (1.1) First search and download the Node.msi (Windows platform application name) software installation package. There is no infringement issue with open source software.
[0089] (1.2) Right-click the Node.msi software installation package and run it with administrator privileges to install the software;
[0090] (1.3) Open the Windows command prompt with administrator privileges;
[0091] (1.4) Copy the code npm config set registry http: / / registry.npmmirror.com (standard code for Windows platform) into the input box and press Enter to run the code;
[0092] (1.5) Copy the code npminstall-g --unsafe-perm node-red pm2pm2-windows-startup pm2-windows-service (standard code for Windows platform) into the input box and press Enter to run the copied code;
[0093] (2) Use the CMD (Command Prompt) command prompt to run the Node-RED platform, including:
[0094] (2.1) Open the Windows command prompt with administrator privileges;
[0095] (2.2) Copy the code C:\Users\Administrator\AppData\Roaming\npm\node-red.cmd (Windows platform standard code) into the input box and press Enter to run the code.
[0096] In step S2, connecting to the target database using the Node-RED development environment includes the following steps:
[0097] S201, establishing a connection character block with a target database;
[0098] S202, setting connection parameters.
[0099] In step S3, the database query statement code is written using the Node-RED development environment to filter out the required data, including the following steps:
[0100] On the basis of step S2, a connection with the target database is established, and then the Select statement in the database is used to query the historical data of the table structure in the database, and the query result is returned after the query is completed.
[0101] In step S4, other operations on the data in the database are implemented using the Node-RED development environment, such as adding, deleting, and modifying data, including the following steps:
[0102] On the basis of step S2, a connection with the target database is established, and then the Insert statement, Delete statement, and Update statement in the database are used to implement the operations of adding, deleting, and modifying the table structure in the database, and the execution result is returned.
[0103] Example 2, illustratively, uses the Node-RED development tool to implement the application of Microsoft SQL Server database in the Internet of Things. The operations of other brands of databases are similar. Preferably, step S2- can also adopt the following steps:
[0104] Step 1. After the Node-RED development environment is installed and successfully run based on the operation in S1, open the browser and enter the URL: http: / / 127.0.0.1:1880 to enter the graphical editor interface of the Node-RED development environment.
[0105] Step 2: Find the inject function block, MSSQL function block, and debug function block in the storage function area of the sidebar of the graphical editor interface, drag them into the work area of the graphical editor, and connect them in sequence. Figure 2 shown.
[0106] Step 3, double-click the MSSQL function block and set the parameters of the function block, such as Figure 3 ;The parameters of the function block include:
[0107] (1) Connection parameter: This parameter is used to establish a data channel between the Node-RED development environment and the target database. This parameter requires setting five sub-parameters, namely:
[0108] Name parameter: name the data link;
[0109] Server parameter: fill in the IP address of the target database;
[0110] Username parameter: the user name used to log in to the target database;
[0111] Password parameter: the password of the user name corresponding to Username;
[0112] Database parameter: the name of the target database;
[0113] After the above five parameters are set, the data connection between the Node-RED development environment and the target database has been successfully established. The five sub-parameter interfaces of the Connection parameter are shown in the figure below. Figure 4 As shown;
[0114] (2) Name parameter: Name the function, for example Figure 5 The functions of the four function blocks in the example are:
[0115] INSERT: insert a piece of data into the target database;
[0116] DELETE: Delete a piece of data in the target database;
[0117] UPDATE: Change the value of a certain data in the target database;
[0118] SELECT: Query the value of a certain data in the target database.
[0119] (3)Query mode parameter: Select the default value Query.
[0120] (4) Query parameter: Select the default value Editor and edit the SQL Server database statement in the input box below.
[0121] Insert statement example:
[0122] INSERT INTO FLOW(DATE_STR,TIME_STR,QS_FLS)
[0123] VALUES('2019-09-11','2019-09-11 15:03:00',10)
[0124] PRINT 'complete'
[0125] Code comments: Insert data into the table structure named FLOW, and insert the data '2019-09-11', '2019-09-11 15:03:00', 10 into the columns named DAT E_S TR, TIM E_S TR, Q S_F LS respectively.
[0126] Delete statement example:
[0127] DELETE FROM FLOW where TIME_STR='2019-09-11 15:03:00'
[0128] PRINT 'complete'
[0129] Code comment: Delete the row of data whose column name TIME_STR is 2019-09-1115:03:00 in the table structure named FLOW.
[0130] Example of change statement:
[0131] UPDATE FLOW
[0132] SET QS_FLS=0
[0133] WHERE TIME_STR='2019-09-11 15:03:00'
[0134] PRINT 'complete'
[0135] Code comment: Change the value of the QS_FLS column in the row of data whose column name TIME_STR is 2019-09-1115:03:00 in the table structure named FLOW to 0.
[0136] Query statement example:
[0137] SELECT *
[0138] FROM FLOW
[0139] WHERE TIME_STR='2019-09-11 15:03:00'
[0140] PRINT 'complete'
[0141] Code Notes: From the table structure named FLOW, select the values of all data columns with a date of September 11, 2019 and a time of 15:03:00, and output them.
[0142] (5)Parameters: Select the default value msg.queryParams.
[0143] (6)Output property parameter: fill in msg.payload.
[0144] (7)Output type parameter: Select Driver Output.
[0145] (8)Error Handing parameter: Select Send in msg.error.
[0146] In the embodiment of the present invention, the specific implementation steps of S5 are as follows:
[0147] S501, based on the operations of S1, S2, S3, and S4, the data can be accurately filtered out according to the database syntax. At this time, a new JSON function block needs to be added to convert the data format into JSON format. Figure 6 As shown;
[0148] S502, parameter function setting of JSON function block, such as Figure 7 As shown, the details are as follows:
[0149] ① Operation parameters: used to select the conversion between JSON string and object;
[0150] ② Attribute parameters: used to fill in msg.payload.
[0151] ③Object to JSON parameter: used to check the formatted JSON string.
[0152] The detailed process of data parsing of the JSON function block is that first, its input pin receives the data processed in the previous process, which can be a JavaScript object, or it can contain an array or other objects. Then the JSON function block calls the JSON.stringify() method in JavaScript to convert the JavaScript object into a string in JSON format. The following is a simple example:
[0153] var person = {
[0154] name:"John",
[0155] age:30,
[0156] city:"New York"
[0157] };
[0158] var jsonString=JSON.stringify(person);
[0159] console.log(jsonString);
[0160] Code Notes: Define a JavaScript object named person, convert it into a JSON string, and output it. The output result is {"name":"John","age":30,"city":"New York"}.
[0161] S503, the operation result is displayed, such as Figure 8 shown.
[0162] Embodiment 3, the embodiment of the present invention provides a system for converting database data in the Internet of Things using a development tool, comprising:
[0163] Node-RED building module, used to build and run the Node-RED development environment;
[0164] The target database connection module is used to connect to the target database using the Node-RED development environment;
[0165] The database query statement code writing module is used to write database query statement codes and perform data screening using the Node-RED development environment;
[0166] The operation module is used to use the Node-RED development environment to add, delete, and modify data in the database;
[0167] The JSON format conversion module is used to convert the filtered data into JSON format using the Node-RED development environment.
[0168] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0169] Since the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present invention, their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0170] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated in one processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment.
[0171] An embodiment of the present invention further provides a computer device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor implements the steps in any of the above-mentioned method embodiments when executing the computer program.
[0172] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0173] An embodiment of the present invention further provides an information data processing terminal, which, when executed on an electronic device, provides a user input interface to implement the steps in the above method embodiments. The information data processing terminal is not limited to mobile phones, computers, and switches.
[0174] An embodiment of the present invention further provides a server, which is used to provide a user input interface to implement the steps in the above method embodiments when executed on an electronic device.
[0175] An embodiment of the present invention provides a computer program product. When the computer program product runs on an electronic device, the electronic device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0176] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / terminal device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a disk or an optical disk.
[0177] To further illustrate the effects of the embodiments of the present invention, the following experiment is conducted: Using the Node-RED development tool to implement the application of the database in the Internet of Things can be applied to the historical data analysis and statistics of the IoT smart screen. Historical data analysis requires querying historical data as the data basis, and then comparing the differences in monthly data and the connections between various data, and finally analyzing the problems in the data. Analyzing the factors of the problem can optimize the operation mode of the device. Fig. 9 shown.
[0178] The Node-RED development tool can be used to query the production data of historical months, and different data can be displayed in a historical curve chart using web front-end technology for easy observation. At the same time, it can be intuitively found that certain data is directly related to the change trend of total production data. In future production operations, it is necessary to pay attention to such key data to optimize operations, save costs, and improve efficiency. At the same time, it can also be found in which months the production data is at its peak and which months the production data is at its lowest. After data analysis, the production plan can be reasonably arranged to prevent overproduction of products and waste of materials.
[0179] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by any technician familiar with the technical field within the technical scope disclosed by the present invention and within the spirit and principles of the present invention should be covered within the protection scope of the present invention.
Claims
1. A method for converting database data in the Internet of Things using a development tool, characterized in that: The method includes: S1, build the Node-RED development environment and run it; S2, use the Node-RED development environment to connect to the target database; S3, use the Node-RED development environment to write database query statement code and perform data screening; S4, using the Node-RED development environment to implement operations of adding, deleting, and modifying data in the database; S5, use the Node-RED development environment to convert the filtered data into JSON format.
2. The method for converting database data in the Internet of Things using a development tool according to claim 1, characterized in that: In step S1, build the Node-RED development environment and run it, including: (1) Install the Node-RED platform operating environment; (2) Use the CMD command prompt to run the Node-RED platform to collect and transmit on-site equipment data.
3. The method for converting database data in the Internet of Things using development tools according to claim 2, characterized in that: In step (1), install the Node-RED platform operating environment, including: (1.1) Search and download the Node.msi software installation package; (1.2) Install the Node.msi software on the Node.msi software installation package; (1.3) Start the Windows command prompt; (1.4) Copy the code npm config set registry http: / / registry.npmmirror.com into the input box and run the code; (1.5) Copy the code npminstall-g --unsafe-perm node-red pm2pm2-windows-startuppm2-windows-service into the input box and run the code; In step (2), use the CMD command prompt to run the Node-RED platform, including: (2.1) Open the command prompt of Windows system; (2.2) Copy the code C:\Users\Administrator\AppData\Roaming\npm\node-red.cmd into the input box and run the code.
4. The method for converting database data in the Internet of Things using development tools according to claim 1, characterized in that: In step S2, the Node-RED development environment is used to connect to the target database, including: S201, establishing a connection character block with a target database; S202, setting connection parameters.
5. The method for converting database data in the Internet of Things using development tools according to claim 4, characterized in that: In step S201, a connection character block with a target database is established, including: After the Node-RED development environment is installed and successfully run, enter the graphical editor interface of the Node-RED development environment in the browser; In the storage function area of the sidebar of the graphic editor interface, respectively obtain the inject function block, the MSSQL function block, and the debug function block, drag them into the working area of the graphic editor, and connect them in sequence.
6. The method for converting database data in the Internet of Things using development tools according to claim 4, characterized in that: In step S202, connection parameters are set, including: (1) Connection parameters, which are used to establish a data channel between the Node-RED development environment and the target database. The Connection parameters include the Name parameter for naming the data link, the Server parameter for filling in the IP address of the target database, the Username parameter for the user name used to log in to the target database, the Password parameter for the user name and password corresponding to the Username, and the Database parameter for providing the target database name. (2) Name parameters, including: INSERT for inserting a piece of data into the target database, DELETE for deleting a piece of data in the target database, UPDATE for changing the value of a piece of data in the target database, and SELECT for querying the value of a piece of data in the target database; (3) Query mode parameter: used to select the default value Query; (4) Query parameter: used to select the default value Editor and edit the SQL Server database statement in the input box; (5)Parameters: used to select the default value of msg.queryParams; (6) Output property parameter: used to fill in msg.payload; (7) Output type parameter: used to select Driver Output; (8)Error Handing parameter: used to select Send in msg.error.
7. The method for converting database data in the Internet of Things using development tools according to claim 1, characterized in that: In step S3, use the Node-RED development environment to write database query statement code and perform data screening, including: On the basis of step S2, a connection with the target database is established, and the Select statement in the database is used to query the historical data of the table structure in the database, and the query result is returned after the query is completed.
8. The method for converting database data in the Internet of Things using development tools according to claim 1, characterized in that: In step S4, the Node-RED development environment is used to implement the operations of adding, deleting, and modifying data in the database, including: On the basis of step S2, a connection with the target database is established, and Insert statements, Delete statements, and Update statements in the database are used to implement operations of adding, deleting, and modifying the table structure in the database, and the execution result is returned.
9. The method for converting database data in the Internet of Things using development tools according to claim 1, characterized in that: In step S5, the filtered data is converted into JSON format using the Node-RED development environment, including: based on the operations of steps S1, S2, S3, and S4, a new JSON function block is added to convert the data format into JSON format data; the parameter function settings of the new JSON function block are as follows: Operation parameters: used to select the conversion between JSON string and object; Attribute parameter: used to fill in msg.payload; Object to JSON parameter: used to check the formatting JSON string.
10. A system for converting database data in the Internet of Things using a development tool, characterized in that: The system implements the method for converting database data in the Internet of Things using a development tool as claimed in any one of claims 1 to 9, and the system includes: Node-RED building module, used to build and run the Node-RED development environment; The target database connection module is used to connect to the target database using the Node-RED development environment; The database query statement code writing module is used to write database query statement codes and perform data screening using the Node-RED development environment; The operation module is used to use the Node-RED development environment to add, delete, and modify data in the database; The JSON format conversion module is used to convert the filtered data into JSON format using the Node-RED development environment.
