Relational database version updating method and device for SCADA (supervisory control and data acquisition) system
By writing and executing database update operation script files, the database version management tool is used to automatically complete the version upgrade of relational databases, solving the problems of cumbersome, omissions and duplication of update operations in the existing technology, ensuring the safe operation of the SCADA system.
Patent Information
- Application Number
- CN202510077547.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-17
- Publication Date
- 2025-04-25
AI Technical Summary
In the prior art, the table structure and data update and modification process of the SCADA system relational database are cumbersome, and update omissions and repeated update operations are prone to updates, which seriously affects the safe operation of the SCADA system.
A relational database version update method is provided for SCADA system. By writing a database update operation script file and storing it in a pre-created db folder, the database version management tool is used to judge based on the database version number and execute the newly added database update operation script file to complete the relational database update operation operation.
The automatic version upgrade of the relational database is realized, which reduces the complexity of update operations, avoids the phenomenon of omissions and repeated executions, and ensures the safe operation of the SCADA system.
Smart Images

Figure CN119884083A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of database version updating, and in particular relates to a relational database version updating method and device for a SCADA system. Background Art
[0002] The SCADA (Supervisory Control And Data Acquisition) system, or supervisory control system, is an automation system used for real-time monitoring, control and data acquisition. At present, most new energy sites such as wind turbines and photovoltaics are equipped with SCADA systems, which can not only improve the operating efficiency and safety of new energy sites, but also provide strong support for the intelligent upgrade of new energy sites.
[0003] With the continuous advancement of computer technology and Internet technology, the SCADA system needs to be continuously upgraded and updated. When the SCADA system is upgraded and updated, the table structure and data of the relational database often need to be updated and modified. At present, database connection tools, such as navicat tools, are usually used for the table structure and data update and modification process of the relational database. The specific process is: first use the database connection tool to establish a connection with the relational database, and then select the corresponding database to execute SQL statements, or manually enter relevant new data on the SCADA system page. However, the existing update operation process is cumbersome, and there are cases of update omissions and repeated update operations, which seriously affect the safe operation of the SCADA system. Summary of the invention
[0004] In view of the technical problems existing in the prior art, the present invention provides a relational database version update method and device for a SCADA system to solve the technical problems that the existing table structure and data update and modification process for the relational database has update omissions and repeated update operations, which seriously affects the safe operation of the SCADA system.
[0005] In order to achieve the above object, the technical solution adopted by the present invention is: The present invention provides a relational database version updating method for a SCADA system, comprising: According to the version update requirements of the relational database, a database update operation script file is written; wherein the file name of the database update operation script file contains the database version number; The database update operation script file is stored in a pre-created db folder; Based on the database version number, determine whether there is a new database update operation script file in the db folder; If it exists, the database version management tool is used to execute the newly added database update operation script file to complete the update operation of the relational database.
[0006] Furthermore, the format of the database update operation script file is a .sql file.
[0007] Furthermore, the file name of the database update operation script file is specifically: database version number+update+user information.sql.
[0008] Furthermore, the pre-created db folder is saved in a resource file directory that can be read in the SCADA system.
[0009] Furthermore, based on the database version number, the process of determining whether there is a newly added database update operation script file in the db folder is as follows: Read the database version number corresponding to the latest database update operation script file from the file name of the latest database update operation script file; Compare the database version number corresponding to the latest database update operation script file with the database version number recorded in the database update operation log; If the database version number corresponding to the latest database update operation script file is less than or equal to the database version number recorded in the database update operation log, then there is no new database update operation script file in the db folder; If the database version number corresponding to the latest database update operation script file is less than or equal to the database version number recorded in the database update operation log, then a new database update operation script file exists in the db folder; among them, the latest database update operation script file is the new database update operation script file in the db folder.
[0010] Furthermore, database update operation logs are stored in the pre-created flyway log table.
[0011] Furthermore, the database version management tool adopts the flyway tool; wherein the flyway tool is integrated in the SCADA system.
[0012] The present invention also provides a relational database version updating device for a SCADA system, comprising: A file writing module, used to write a database update operation script file according to the version update requirements of the relational database; wherein the file name of the database update operation script file contains the database version number; A file storage module, used for storing the database update operation script file in a pre-created db folder; The version judgment module is used to judge whether there is a new database update operation script file in the db folder based on the database version number; The update execution module is used to execute the newly added database update operation script file using the database version management tool to complete the update operation of the relational database.
[0013] The present invention also provides a relational database version updating device for a SCADA system, comprising: a processor suitable for executing a computer program; A computer-readable storage medium having a computer program stored therein, wherein when the computer program is executed by the processor, the method for updating the relational database version for the SCADA system is executed.
[0014] The present invention also 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 method for updating the relational database version for a SCADA system is implemented.
[0015] Compared with the prior art, the present invention has the following beneficial effects: The relational database version updating method for a SCADA system provided by the present invention comprises the following steps: according to the version updating requirement of the relational database, a database updating operation script file is written and stored in a pre-created db folder; based on the database version number, a database version management tool is used to execute the database updating operation script file newly added in the db folder to realize the updating operation of the relational database; when the relational database version is updated, only the database updating operation script file needs to be written and executed according to the version updating requirement of the relational database, so that the version upgrading action of the database can be automatically completed, thereby greatly reducing the complexity of the updating operation; at the same time, updating is performed based on the database version number, thereby avoiding the phenomenon of update omission and repeated execution, thereby ensuring the safe operation of the SCADA system.
[0016] The relational database version updating system for a SCADA system, the relational database version updating device for a SCADA system, the computer-readable storage medium and the computer program product provided by the present invention have all the advantages of the relational database version updating method for a SCADA system. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 A flowchart of a relational database version update method for a SCADA system provided in Example 1; Figure 2 A structural block diagram of a relational database version update system for a SCADA system provided in Example 2; Figure 3 This is a structural block diagram of a relational database version updating device for a SCADA system provided in Example 3. DETAILED DESCRIPTION
[0019] In order to make the technical problems, technical solutions and beneficial effects solved by this application clearer, the technical solutions in the embodiments of this application will be described clearly and completely in combination with the drawings in the embodiments of this application; obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0020] Example 1 The relational database version update method for the SCADA system provided in the present embodiment 1 first integrates the flyway tool in the SCADA system; then creates a db folder under the readable resource file directory of the SCADA system; and stores the written database update operation script file in the db folder in the format of a .sq file; a new database update operation script file can be added for each update; wherein, the version number of the latter database update operation script file is greater than the previous version number; when the SCADA system is started, the flyway tool will create a flyway log table for recording the log of the executed database update operation script file, so that the version number of the database update operation script file is read when the system is restarted next time, and the read version number is compared with the version number recorded in the flyway log table; if the read version number is less than or equal to the latest version number in the flyway log table, the database update operation script file will not be executed, thereby ensuring that the situation of repeatedly executing the database update operation script file is avoided; by judging whether there is a newly added database update operation script file in the db folder, the update operation of this relational database is completed by executing the newly added database update operation script file.
[0021] As attached Figure 1 As shown, this embodiment 1 provides a relational database version update method for a SCADA system, which specifically includes the following steps: Step 1: Integrate a database version management tool into the SCADA system. The database version management tool is based on the flyway database version management tool, i.e., the flyway tool.
[0022] Step 2: Write a database update operation script file according to the version update requirements of the relational database. The version update requirements of the relational database include adding new tables, modifying table structures, updating data or deleting tables; the format of the database update operation script file is a .sql file, and the file name of the database update operation script file contains the database version number; specifically, the file name of the database update operation script file is database version number + update + user information.sql, for example: V1.0.0__update_user_info.sql.
[0023] Step 3, create a db folder under the readable resource file directory of the SCADA system to obtain a pre-created db folder; store the database update operation script file in the pre-constructed db folder. It should be noted that each time the relational database is updated, the database update operation script file is stored in the pre-constructed db folder, and the update operation of the relational database is implemented by executing the database update operation script file in the pre-constructed db folder; wherein, the database version number corresponding to the previous update is less than the database version number corresponding to the next update.
[0024] Step 4: Start the flyway tool and create a flyway log table. The flyway log table is used to store database update operation logs. Specifically, after each execution of the database update operation script file, the database version number corresponding to the executed database update operation script file is recorded, and the database update operation log is generated and stored in the flyway log table.
[0025] Step 5: Based on the database version number, determine whether there is a newly added database update operation script file in the db folder. Specifically, the process of determining whether there is a newly added database update operation script file in the db folder is as follows: Step 501: Read the database version number corresponding to the latest database update operation script file from the file name of the latest database update operation script file.
[0026] Step 502: Compare the database version number corresponding to the latest database update operation script file with the database version number recorded in the database update operation log.
[0027] Step 503: If the database version number corresponding to the latest database update operation script file is less than or equal to the database version number recorded in the database update operation log, there is no new database update operation script file in the db folder. At this time, there is no need to perform an update operation on the relational database, and feedback is returned to step 1 to wait for the next update.
[0028] Step 504: If the database version number corresponding to the latest database update operation script file is less than or equal to the database version number recorded in the database update operation log, there is a newly added database update operation script file in the db folder, and jump to step 6; wherein the latest database update operation script file is the newly added database update operation script file in the db folder.
[0029] Step 6: Use the flyway tool to execute the newly added database update operation script file to complete the update operation of the relational database. It should be noted that when using the flyway tool to execute the database update operation script file, by running the Flyway command in the command line or integrated into the build tool, Flyway will automatically scan the script files in the preset path, determine which scripts are new or have not been executed based on the version number in the file name, and execute them in the order of the version number.
[0030] In this embodiment 1, by including the database version number in the file name of the database update operation script file, each update script is closely associated with its corresponding database version; the database update operation script file is stored in a pre-created db folder, and by judging based on the database version number, it is identified whether there is a newly added database update operation script file in the db folder; if so, the database version management tool is used to automatically execute the newly added database update operation script file to complete the update operation of the relational database, and the need for manual intervention is reduced through the automated update process, the risk of human error is reduced, and the update efficiency is improved; the present invention helps to reduce errors and failures that may occur during the update process through a structured update process, ensuring that the database remains stable and secure during the update process.
[0031] Example 2 As attached Figure 2 As shown, this embodiment 2 provides a relational database version update system for a SCADA system, including a tool integration module, a file writing module, a file storage module, a log table creation module, a version judgment module and an update execution module.
[0032] A tool integration module is used to integrate a database version management tool into a SCADA system; a file writing module is used to write a database update operation script file according to the version update requirements of a relational database; a file storage module is used to create a db folder under a readable resource file directory of the SCADA system to obtain a pre-created db folder; the database update operation script file is stored in a pre-built db folder; a log table creation module is used to start a flyway tool and create a flyway log table; a version judgment module is used to judge whether there is a newly added database update operation script file in the db folder based on the database version number; an update execution module is used to use the flyway tool to execute the newly added database update operation script file to complete the update operation of the relational database.
[0033] Example 3 As attached Figure 3 As shown, this embodiment 3 also provides a relational database version update device for a SCADA system, including: a processor, a memory, and a computer program stored in the memory and executable on the processor, such as a relational database version update program for a SCADA system; wherein the attached Figure 3 The communication interface in is used to access external devices to obtain data.
[0034] When the processor executes the computer program, the steps in the above-mentioned method for updating the relational database version of the SCADA system are implemented, for example: Integrate a database version management tool into a SCADA system; write a database update operation script file according to the version update requirements of a relational database; create a db folder under a readable resource file directory of the SCADA system to obtain a pre-created db folder; store the database update operation script file in a pre-built db folder; start a flyway tool to create a flyway log table; based on the database version number, determine whether there is a newly added database update operation script file in the db folder; use the flyway tool to execute the newly added database update operation script file to complete the update operation of the relational database.
[0035] Alternatively, when the processor executes the computer program, the functions of each module in the above-mentioned relational database version update system for the SCADA system are realized, for example: A tool integration module is used to integrate a database version management tool into a SCADA system; a file writing module is used to write a database update operation script file according to the version update requirements of a relational database; a file storage module is used to create a db folder under a readable resource file directory of the SCADA system to obtain a pre-created db folder; the database update operation script file is stored in a pre-built db folder; a log table creation module is used to start a flyway tool and create a flyway log table; a version judgment module is used to judge whether there is a newly added database update operation script file in the db folder based on the database version number; an update execution module is used to use the flyway tool to execute the newly added database update operation script file to complete the update operation of the relational database.
[0036] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the relational database version update method and device for a SCADA system.
[0037] For example, the computer program can be divided into a tool integration module, a file writing module, a file storage module, a log table creation module, a version judgment module and an update execution module, and the specific functions of each module are as follows: a tool integration module, used to integrate the database version management tool into the SCADA system; a file writing module, used to write a database update operation script file according to the version update requirements of the relational database; a file storage module, used to create a db folder under a readable resource file directory of the SCADA system to obtain a pre-created db folder; the database update operation script file is stored in a pre-built db folder; a log table creation module, used to start the flyway tool and create a flyway log table; a version judgment module, used to determine whether there is a newly added database update operation script file in the db folder based on the database version number; an update execution module, used to use the flyway tool to execute the newly added database update operation script file to complete the update operation of the relational database.
[0038] The relational database version update device for the SCADA system can be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server. The relational database version update device for the SCADA system may include, but is not limited to, a processor and a memory. Those skilled in the art can understand that the relational database version update device for the SCADA system is only an example of a terminal device and does not constitute a limitation on the terminal device. It can include more or fewer components, or a combination of certain components, or different components. For example, the relational database version update device for the SCADA system can also include input and output devices, network access devices, and buses.
[0039] The relational database version update device for the SCADA system can be a computing device such as a desktop computer, a notebook, a palm computer, and a cloud server. The relational database version update device for the SCADA system may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that the attached Figure 3 The schematic diagram is merely an example of a relational database version update device for a SCADA system and does not constitute a limitation on the relational database version update device for a SCADA system. The device may include more or fewer components than shown in the diagram, or a combination of certain components, or different components. For example, the relational database version update device for a SCADA system may also include input and output devices, network access devices, buses, etc.
[0040] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the relational database version update device for the SCADA system, and uses various interfaces and lines to connect various parts of the entire relational database version update device for the SCADA system.
[0041] The memory can be used to store the computer program and / or module, and the processor implements various functions of the relational database version update device for the SCADA system by running or executing the computer program and / or module stored in the memory and calling the data stored in the memory.
[0042] The memory may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc.
[0043] In addition, the memory may include a high-speed random access memory and may also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0044] Example 4 This embodiment 4 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 of the method for updating a relational database version for a SCADA system are implemented, for example: Integrate a database version management tool into a SCADA system; write a database update operation script file according to the version update requirements of a relational database; create a db folder under a readable resource file directory of the SCADA system to obtain a pre-created db folder; store the database update operation script file in a pre-built db folder; start a flyway tool to create a flyway log table; based on the database version number, determine whether there is a newly added database update operation script file in the db folder; use the flyway tool to execute the newly added database update operation script file to complete the update operation of the relational database.
[0045] If the module / unit integrated in the relational database version update system for the SCADA system 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.
[0046] Based on such understanding, this embodiment 4 implements all or part of the processes in the relational database version update method for the SCADA system described in the above embodiment 1, and can also be completed by instructing related hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the relational database version update method for the SCADA system can be implemented. 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 preset intermediate form, etc.
[0047] The computer-readable storage medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal and software distribution medium, etc.
[0048] It should be noted that the content contained in the computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable storage media do not include electrical carrier signals and telecommunication signals.
[0049] The relational database version updating method for a SCADA system of the present invention stores a database update operation script file in a pre-created db folder, determines whether there is a newly added database update operation script file in the db folder based on a judgment based on a database version number, and automatically executes the newly added database update operation script file using a database version management tool to complete the update operation of the relational database; with the continuous iteration of the database version, a new update script can be easily added to the db folder and executed through the same process, has good flexibility and scalability, and can adapt to the needs of future database version updates; because each update script is closely associated with its corresponding database version and is stored in a unified db folder, the update history of the database can be easily audited and traced, which is of great significance for troubleshooting, system recovery, compliance auditing, etc.
[0050] The above embodiment is only one of the implementation methods that can realize the technical solution of the present invention. The scope of protection claimed by the present invention is not limited only to this embodiment, but also includes changes, replacements and other implementation methods that can be easily thought of by any technician familiar with the technical field within the technical scope disclosed by the present invention.
Claims
1. A method for updating a relational database version for a SCADA system, characterized in that: include: According to the version update requirements of the relational database, a database update operation script file is written; wherein the file name of the database update operation script file contains the database version number; The database update operation script file is stored in a pre-created db folder; Based on the database version number, determine whether there is a new database update operation script file in the db folder; If it exists, the database version management tool is used to execute the newly added database update operation script file to complete the update operation of the relational database.
2. A method for updating a relational database version for a SCADA system according to claim 1, characterized in that: The format of the database update operation script file is a .sql file.
3. A relational database version updating method for a SCADA system according to claim 1, characterized in that: The file name of the database update operation script file is specifically: database version number+update+user information.sql.
4. A relational database version updating method for a SCADA system according to claim 1, characterized in that: The pre-created db folder is saved to a resource file directory that can be read in the SCADA system.
5. A relational database version updating method for a SCADA system according to claim 1, characterized in that: Based on the database version number, the process of determining whether there is a new database update operation script file in the db folder is as follows: Read the database version number corresponding to the latest database update operation script file from the file name of the latest database update operation script file; Compare the database version number corresponding to the latest database update operation script file with the database version number recorded in the database update operation log; If the database version number corresponding to the latest database update operation script file is less than or equal to the database version number recorded in the database update operation log, then there is no new database update operation script file in the db folder; If the database version number corresponding to the latest database update operation script file is less than or equal to the database version number recorded in the database update operation log, then a new database update operation script file exists in the db folder; among them, the latest database update operation script file is the new database update operation script file in the db folder.
6. A method for updating a relational database version for a SCADA system according to claim 5, characterized in that: Database update operation logs are stored in the pre-created flyway log table.
7. A method for updating a relational database version for a SCADA system according to claim 1, characterized in that: The database version management tool adopts the flyway tool, and the flyway tool is integrated in the SCADA system.
8. A relational database version updating device for a SCADA system, characterized in that: include: A file writing module, used to write a database update operation script file according to the version update requirements of the relational database; wherein the file name of the database update operation script file contains the database version number; A file storage module, used for storing the database update operation script file in a pre-created db folder; The version judgment module is used to judge whether there is a new database update operation script file in the db folder based on the database version number; The update execution module is used to execute the newly added database update operation script file using the database version management tool to complete the update operation of the relational database.
9. A relational database version update device for a SCADA system, characterized in that: include: a processor suitable for executing a computer program; A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by the processor, the method for updating the relational database version for a SCADA system according to any one of claims 1 to 7 is executed.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for updating a relational database version for a SCADA system as described in any one of claims 1 to 7 is implemented.