A database initialization method and device for application deployment
By parsing the mapping rules between the application's pre-built data files and the database, generating SQL files and initializing data, the problems of low database initialization efficiency and high maintenance difficulty in existing technologies are solved, achieving efficient database initialization and data management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- QI-ANXIN LEGENDSEC INFORMATION TECH (BEIJING) INC
- Filing Date
- 2022-12-12
- Publication Date
- 2026-08-04
AI Technical Summary
Existing database initialization schemes for application deployment have significant limitations, resulting in poor initialization efficiency and high maintenance difficulty. They cannot effectively support the writing of dynamic field data and data maintenance is difficult.
By determining the pre-built data file of the application to be deployed, the SQL file is generated based on the mapping rules between the pre-built data file and the database, and data initialization operations are performed, including the processing of static and dynamic values, supporting the writing of dynamic field data and the updating or writing of duplicate data.
It effectively reduces the difficulty and cost of database initialization during application deployment, facilitates data maintenance and management, and improves the efficiency of database initialization.
Smart Images

Figure CN118193561B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of application deployment technology, specifically to a database initialization method and apparatus for application deployment. Additionally, it relates to an electronic device and a processor-readable storage medium. Background Technology
[0002] In recent years, with the rapid development of internet technology, large-scale software applications have become increasingly widespread. During the installation and runtime of large software applications, the process typically requires initializing the database before starting the application process. Database initialization is mostly accomplished by submitting SQL (Structured Query Language) files through version control tools. These files contain necessary table structures, configuration data, and pre-defined business data required for application runtime. Since this pre-defined data is fully bound to the code, excessive pre-defined data leads to lengthy SQL files, requiring simultaneous changes to the SQL when data changes occur, which is detrimental to SQL version management. Furthermore, different language environments, projects, and clients cannot automatically select different pre-defined data, and dynamic field data writing is not supported. Data maintenance is also difficult, often requiring the involvement of multiple roles such as product managers, data maintenance personnel, and developers, resulting in high maintenance and management complexity and introducing additional costs to software application development. Therefore, designing a more efficient database initialization scheme for application deployment to improve database initialization efficiency has become a pressing problem. Summary of the Invention
[0003] To address this, the present invention provides a database initialization method and apparatus for application deployment, thereby solving the shortcomings of existing database initialization schemes for application deployment, which have high limitations, resulting in poor initialization efficiency and high maintenance difficulty.
[0004] In a first aspect, the present invention provides a database initialization method for application deployment, comprising:
[0005] Determine the pre-configured data file corresponding to the application to be deployed; wherein, the pre-configured data file is a table file used to manage the pre-configured data of the application;
[0006] Based on the mapping rules between the preset data file and the database, the preset data file is parsed to obtain the SQL file corresponding to the database;
[0007] The database is initialized based on the SQL file.
[0008] Furthermore, based on the mapping rules between the preset data file and the database, the preset data file is parsed to obtain the SQL file corresponding to the database, including:
[0009] The preset data file is identified based on the mapping rules to determine the data type of the preset data;
[0010] The preset data file is parsed based on the data type to generate corresponding SQL assignment statements; the SQL file is obtained based on the SQL assignment statements.
[0011] Furthermore, based on the aforementioned mapping rules, the preset data file is identified to determine the data type of the preset data, specifically including:
[0012] Based on the mapping rules, special identifiers are identified in the preset data file. If the special identifier is not present in the preset data of a cell in the preset data file, the data type of the preset data is determined to be a static value. If the preset data of a cell in the preset data file contains a preset special identifier, the data type of the preset data is determined to be a dynamic value.
[0013] Based on the data type, the preset data file is parsed to generate corresponding SQL assignment statements, specifically including:
[0014] When the data type of the preset data is a static value, the preset data file is parsed based on a preset static value parsing rule to generate a corresponding first SQL assignment statement; and / or, when the data type of the preset data is a dynamic value, the preset data file is parsed based on a preset dynamic value parsing rule to generate a corresponding second SQL assignment statement.
[0015] Furthermore, the data initialization operation of the database based on the SQL file specifically includes: determining whether there are corresponding duplicate row data in the database based on the SQL file; if so, generating an update statement and performing a data update operation on the duplicate row data in the database based on the update statement; if not, generating a write statement and performing a data write operation on the database based on the write statement.
[0016] Furthermore, before determining the pre-configured data file corresponding to the application to be deployed, the method further includes: pre-acquiring the pre-configured data required for the application to be deployed and run, storing the pre-configured data in an initial table file to obtain the pre-configured data file; wherein the pre-configured data includes the original configuration data and pre-configured business data required for the application to be deployed and run; constructing a mapping relationship between the rows and columns of the pre-configured data file and the rows and columns of the database, and constructing a mapping relationship between the worksheets of the pre-configured data file and the data tables of the database; wherein each worksheet corresponds to one data table.
[0017] Furthermore, determining the preset data file corresponding to the application to be deployed includes: determining the actual deployment scenario characteristics of the application under the deployment scenario, and selecting the corresponding preset data file based on the actual deployment scenario characteristics.
[0018] Furthermore, before parsing the preset data file based on the mapping rules between the preset data file and the database, the method further includes: pre-encapsulating the import process of the preset data in the preset data file and determining the HTTP endpoint corresponding to the import process; receiving the import request input by the user, and triggering the HTTP endpoint to execute the import control of the preset data based on the import request.
[0019] Secondly, the present invention also provides a database initialization apparatus for application deployment, comprising:
[0020] A preset data file determination unit is used to determine the preset data file corresponding to the application to be deployed; wherein, the preset data file is a table file used to manage the preset data of the application;
[0021] The SQL file acquisition unit is used to parse the preset data file based on the mapping rules between the preset data file and the database to obtain the SQL file corresponding to the database.
[0022] The database initialization unit is used to perform data initialization operations on the database based on the SQL file.
[0023] Furthermore, the SQL file acquisition unit is specifically used for:
[0024] The preset data file is identified based on the mapping rules to determine the data type of the preset data;
[0025] The preset data file is parsed based on the data type to generate corresponding SQL assignment statements; the SQL file is obtained based on the SQL assignment statements.
[0026] Furthermore, based on the mapping rules between the preset data file and the database, the preset data file is identified to determine the data type of the preset data, specifically including:
[0027] Based on the mapping rules, special identifiers are identified in the preset data file. If the special identifier is not present in the preset data of a cell in the preset data file, the data type of the preset data is determined to be a static value. If the preset data of a cell in the preset data file contains a preset special identifier, the data type of the preset data is determined to be a dynamic value.
[0028] Based on the data type, the preset data file is parsed to generate corresponding SQL assignment statements, specifically including:
[0029] When the data type of the preset data is a static value, the preset data file is parsed based on a preset static value parsing rule to generate a corresponding first SQL assignment statement; and / or, when the data type of the preset data is a dynamic value, the preset data file is parsed based on a preset dynamic value parsing rule to generate a corresponding second SQL assignment statement.
[0030] Furthermore, the database initialization unit is specifically used to: determine whether there are corresponding duplicate row data in the database based on the SQL file; if so, generate an update statement and perform a data update operation on the duplicate row data in the database based on the update statement; if not, generate a write statement and perform a data write operation on the database based on the write statement.
[0031] Furthermore, before determining the pre-configured data file corresponding to the application to be deployed, the system further includes: a mapping relationship construction unit, used to pre-obtain the pre-configured data required for the application deployment and runtime, store the pre-configured data in an initial table file to obtain the pre-configured data file; wherein, the pre-configured data includes the original configuration data and pre-configured business data required for the application deployment and runtime; constructing the mapping relationship between the rows and columns of the pre-configured data file and the rows and columns of the database, and constructing the mapping relationship between the worksheets of the pre-configured data file and the data tables of the database; wherein, each worksheet corresponds to one data table.
[0032] Furthermore, the preset data file determination unit is specifically used to: determine the actual deployment scenario characteristics corresponding to the application under the application deployment scenario, and select the corresponding preset data file based on the actual deployment scenario characteristics.
[0033] Furthermore, before parsing the preset data file based on the mapping rules between the preset data file and the database, the system further includes: a preset data import unit, used to pre-encapsulate the import process of the preset data in the preset data file and determine the HTTP endpoint corresponding to the import process; receive an import request input by the user, and trigger the HTTP endpoint to execute the import control of the preset data based on the import request.
[0034] Thirdly, the present invention also provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of a database initialization method for application deployment as described in any of the preceding claims.
[0035] Fourthly, the present invention also provides a processor-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the database initialization method for application deployment as described in any of the preceding claims.
[0036] The database initialization method for application deployment provided by this invention determines the preset data file corresponding to the application to be deployed, and parses the preset data file based on the mapping rules between the preset data file and the database to obtain the SQL file corresponding to the database; then, the database is initialized based on the SQL file. This method can effectively reduce the difficulty and cost of database initialization during application deployment, facilitate data maintenance and management, and improve the efficiency of database initialization during application deployment. Attached Figure Description
[0037] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0038] Figure 1 This is a flowchart illustrating the database initialization method for application deployment provided in an embodiment of the present invention;
[0039] Figure 2 This is a complete flowchart illustrating the database initialization method for application deployment provided in this embodiment of the invention.
[0040] Figure 3 This is a schematic diagram of the file parsing process in the database initialization method for application deployment provided in this embodiment of the invention.
[0041] Figure 4 This is a schematic diagram of the structure of the database initialization device for application deployment provided in an embodiment of the present invention;
[0042] Figure 5 This is a schematic diagram of the physical structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation
[0043] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0044] The following describes in detail embodiments of the database initialization method for application deployment based on the present invention. Figure 1 The diagram shown is a flowchart illustrating the database initialization method for application deployment provided in an embodiment of the present invention. The specific process includes the following steps:
[0045] Step 101: Determine the preset data file corresponding to the application to be deployed; wherein, the preset data file is a table file used to manage the preset data of the application.
[0046] In this embodiment of the invention, before determining the pre-configured data file corresponding to the application to be deployed, it is necessary to obtain the pre-configured data required for the application's deployment and runtime, and store the pre-configured data in an initial table file to obtain the pre-configured data file. The pre-configured data includes the original configuration data and pre-configured business data required for the application's deployment and runtime. Then, a mapping relationship is constructed between the rows and columns of the pre-configured data file and the rows and columns of the database, and between the worksheets of the pre-configured data file and the data tables of the database. Each worksheet corresponds to one data table, and the table file can be an Excel file, with each worksheet referring to a sheet page within the Excel file. A mapping relationship is established between the sheet pages of the Excel file and the data tables in the database, with each sheet page corresponding to one data table, thereby achieving data isolation. In the specific implementation of this step, under the application deployment scenario, it is necessary to determine the actual deployment scenario characteristics corresponding to the application, and select the corresponding pre-configured data file based on these characteristics.
[0047] Step 102: Based on the mapping rules between the preset data file and the database, parse the preset data file to obtain the SQL file corresponding to the database.
[0048] In the specific implementation of this step, the preset data file can be identified based on the mapping rules between the preset data file and the database to determine the data type of the preset data; the preset data file can be parsed based on the data type to generate corresponding SQL assignment statements; and the SQL file can be obtained based on the SQL assignment statements. Alternatively, the memo information of the cells in the preset data file can be parsed based on the mapping rules between the preset data file and the database. Based on the memo information, it can be determined whether a joint unique constraint exists in the preset data file. If so, a unique constraint verification statement is generated. After verification, it is determined whether there are corresponding duplicate rows in the database. If so, an update statement is executed according to the joint unique constraint to cover the duplicate rows.
[0049] For example, when a specially identified Sheet is parsed, the program will handle it specially so that additional business actions can be performed after the pre-written data is completed. During parsing, the first row of data in the Sheet is identified as a field declaration in the data table, and the data in other rows of each column will be parsed as the assignment of that field in the database. At the same time, the comments of the cells containing the fields in each data table are parsed. When the comments are "Key", it is determined that the value of that field in the current data table cannot be duplicated. When multiple columns are identified with "Key" comments, it is determined that these fields form a joint unique constraint. When the comments are "Install", the pre-written data in that column will only be updated or inserted when the application is installed. When the comments are "Update", the pre-written data in that column will only be updated or inserted when the application is upgraded. The definition of the comments described in this invention supports extension. Only by enhancing the application capabilities can more special scenarios be handled, making it simpler and more efficient.
[0050] It should be noted that when parsing the preset data file based on the mapping rules between the preset data file and the database, different Excel elements in the Excel file correspond to different standardized meanings. For example, if the Excel element is "Sheet Page Name", the standardized meaning obtained after parsing is "unless otherwise identified, it is uniformly recognized as the name of the data table in the database"; if the Excel element is "$(POST_SQL)Sheet Page", the standardized meaning obtained after parsing is "the SQL statement that needs to be executed after the preset data is written"; if the Excel element is "Row", the standardized meaning obtained after parsing is "except for the first row of data, all other rows of data are mapped to a row (record) of the data table in the database"; if the Excel element is "Column", the standardized meaning obtained after parsing is "except for the first row of data, each column of data is mapped to a column of the data table in the database"; if the Excel element is "First Row", the standardized meaning obtained after parsing is "the declaration / definition of the field in the data table"; if the Excel element is "First Row Comment or Remark Information", the standardized meaning obtained after parsing is "the cell where the field is declared in the data table has a comment key added, indicating that the field is unique", etc., which will not be elaborated further here.
[0051] In this embodiment of the invention, special identifiers in the preset data file are identified based on the mapping rules between the preset data file and the database. If the preset data in a cell of the preset data file does not have a preset special identifier, the preset data is determined to be a static value. If the preset data in a cell of the preset data file has a preset special identifier, the preset data is determined to be a dynamic value. The preset data file is parsed based on preset static value parsing rules to generate a corresponding first SQL assignment statement. And / or, the preset data file is parsed based on preset dynamic value parsing rules to generate a corresponding second SQL assignment statement.
[0052] Specifically, during the parsing process, the first cell in the pre-built data file is identified as a field declaration. A comment containing "key" (i.e., a memo) identifies the uniqueness of the data in that column, allowing for combined unique constraints. When importing data, a SQL template (i.e., an SQL statement template) is automatically generated based on the unique constraints. Before writing the data, it checks if the data already exists. If duplicate data exists, an UPDATE statement is executed based on the unique constraints; otherwise, it is not overwritten. The database automatically converts the data type of the data being written based on the table declaration. Therefore, when assembling data with the generated SQL template, no special type conversion is performed on individual data; all data is written as strings by default. The database automatically converts values to a format consistent with the table declaration during writing. For example, if the data being written is 't' and its assigned field type is Boolean, the final value will be true.
[0053] The data in each cell of every row except the first row is parsed into values to be assigned to different fields in the data table. If the cell data does not have any special identifier, it is identified as a static value and the corresponding preset data file is parsed based on the preset static value parsing rules to generate the corresponding first SQL assignment statement. That is, the static value is directly assembled with the dynamically generated SQL template to form the final first SQL assignment statement. Static values refer to data written to the database that is consistent with the data declared in the imported preset data file.
[0054] When a preset special identifier is detected in the current cell of the pre-set data file, it will be divided into two categories: "data constraint expression" and "function expression". This means that before the data (i.e. data value) of the cell is inserted into the data table, the data needs to obtain dynamic values based on the deployment environment information, the dynamic data of other data tables and other actual deployment scenario characteristics, such as foreign keys, ID, time and other dynamic values.
[0055] The dynamic value parsing rules include: When data in a cell of a table file begins with ${ and ends with}, the content within the parentheses is recognized as a "data qualifying expression," indicating that the data needs to be dynamically retrieved based on values from other tables or the current table when written. According to a preset declaration method, the table name (e.g., the name of the sheet page), the "field and condition value" for filtering data, and the value field are parsed from the "data qualifying expression." The conditional statement supports multiple condition combinations and is ultimately converted into a second SQL assignment statement, thereby dynamically assigning a value to a specific field in the current data table. When data in a cell of a preset data file begins with $( and ends with ), the content within the parentheses is recognized as a "function expression," indicating that the value needs to be dynamically retrieved through a function expression when written. The function expression is converted into a second SQL assignment statement, thus writing dynamic data (i.e., dynamic values) to that field in the data table in real time. The preset declaration methods include: The dynamic value is "${data-qualified expression}", which declares "how the data value of this cell in the preset data file is obtained through specific syntax"; the dynamic value is "${data-qualified expression}", with an example declaration of "${table_name#field1(value1).assignment_field}", which declares "the assignment value is: SELECT assignment_field FROM table_name WHERE field1 = value1"; the dynamic value is "${data-qualified expression}", with an example declaration of "${table_name#field1(value1)#field2(value2).assignment_field}", which declares "the assignment value is: SELECT assignment_field FROM table_name WHERE field1 = value1 AND field2 = value2". Additionally, the default declaration methods include: a dynamic value of "$(function expression)", which is declared as "calling the database's own function expression to assign a value"; and a dynamic value of "$(function expression)", with the declaration instance being "$(now())", which is declared as "assigning the value: SELECT now(); i.e., the current time. Note: if the "example" is directly written as now(), then the value assigned is: now() text".
[0056] In the actual implementation of this invention, during the design phase, the data table design is obtained in advance, and data maintenance personnel translate the application requirements and data specifications into the format of pre-built data files. During the R&D or testing phases, when the pre-built data is adjusted due to market and other factors, data maintenance personnel need to update the pre-built data without modifying the code. During application integration, the pre-built data of each functional module is uniformly integrated and managed. For example, based on the table file, the pre-built business data or basic configuration data corresponding to the vulnerability scanning function of antivirus software (i.e., the application) are uniformly integrated and managed. During application deployment, the corresponding pre-built data file is selected according to the actual deployment scenario characteristics such as the deployment language environment and customer type. Before parsing the pre-built data file based on the mapping rules between the pre-built data file and the database, the import process of the pre-built data in the pre-built data file is encapsulated in advance, and the HTTP endpoint corresponding to the import process is determined. The user input import request is received, and the HTTP endpoint is triggered to execute the import control of the pre-built data based on the import request. The data initialization of all business is completed by triggering the exposed HTTP control endpoint. After the data import is triggered, the control program will parse the preset data file to determine the data type, tablespace, uniqueness, etc. of the preset data, and dynamically generate an SQL template to complete the import of the preset data, thereby achieving the purpose of application data initialization.
[0057] Step 103: Perform data initialization operations on the database based on the SQL file.
[0058] Specifically, the system can determine whether there are duplicate rows in the database based on the SQL file. If so, an update statement is generated, and a data update operation is performed on the duplicate rows in the database based on the update statement. If not, a write statement is generated, and a data write operation is performed on the database based on the write statement.
[0059] In a flexible and configurable large-scale software database initialization scheme, pre-built data refers to the static and dynamic values carried within the product during product release. Static values include menu names and function lists. This is achieved by mapping relational database rows and columns to Excel file rows and columns, tablespaces (i.e., data tables), and sheet pages. During the deployment and runtime of large-scale software, the process always initializes the database first, then starts the application process. Database initialization is mostly completed by submitting SQL files through version control tools, which includes the necessary table structure and configuration data for software runtime; it also includes pre-built software business data. This invention divides the pre-built data into two parts: a small amount of software configuration data and pre-built business data, with the business data imported during the data migration phase. This invention requires data maintenance personnel to maintain the pre-built data uniformly through Excel files. During data migration, the program identifies the table structure relationships, fields, data, and external relationships between data in the Excel file and automatically writes these into the corresponding data tables in the database. In subsequent scenarios requiring one-click switching of the runtime language, the data import program can encapsulate the import process. The business exposure interface and externally exposed endpoints are controlled.
[0060] This invention provides a configurable, decoupled, and automated data pre-provisioning method. Pre-provisioned data is declared in a table file according to corresponding parsing rules and imported into the database corresponding to the application. The content of the table file is then parsed into data tables, fields, and data according to these rules. Figure 3 The strategy completes the enrichment and combination of SQL files, and through Figure 2 The process completes the initialization of the preset data.
[0061] The database initialization method for application deployment described in this invention determines the preset data file corresponding to the application to be deployed, and parses the preset data file based on the mapping rules between the preset data file and the database to obtain the SQL file corresponding to the database; then, the database is initialized based on the SQL file. This method can effectively reduce the difficulty and cost of database initialization during application deployment, facilitate the maintenance and management of the application's preset data, and improve the efficiency of database initialization during application deployment.
[0062] Corresponding to the above-described method for initializing a database for application deployment, this invention also provides an apparatus for initializing a database for application deployment. Since the embodiments of this apparatus are similar to the method embodiments described above, the description is relatively simple. For relevant details, please refer to the description in the method embodiment section above. The embodiments of the application deployment database initialization apparatus described below are merely illustrative. Please refer to... Figure 4The diagram shown is a structural schematic of a database initialization device for application deployment provided in an embodiment of the present invention.
[0063] The database initialization device for application deployment according to the present invention specifically includes the following parts:
[0064] The preset data file determination unit 401 is used to determine the preset data file corresponding to the application to be deployed; wherein, the preset data file is a table file used to manage the preset data of the application;
[0065] SQL file acquisition unit 402 is used to parse the preset data file based on the mapping rules between the preset data file and the database to obtain the SQL file corresponding to the database;
[0066] The database initialization unit 403 is used to perform data initialization operations on the database based on the SQL file.
[0067] Furthermore, the SQL file acquisition unit is specifically used for:
[0068] The preset data file is identified based on the mapping rules to determine the data type of the preset data;
[0069] The preset data file is parsed based on the data type to generate corresponding SQL assignment statements; the SQL file is obtained based on the SQL assignment statements.
[0070] Furthermore, based on the mapping rules between the preset data file and the database, the preset data file is identified to determine the data type of the preset data, specifically including:
[0071] Based on the mapping rules, special identifiers are identified in the preset data file. If the special identifier is not present in the preset data of a cell in the preset data file, the data type of the preset data is determined to be a static value. If the preset data of a cell in the preset data file contains a preset special identifier, the data type of the preset data is determined to be a dynamic value.
[0072] Based on the data type, the preset data file is parsed to generate corresponding SQL assignment statements, specifically including:
[0073] When the data type of the preset data is a static value, the preset data file is parsed based on a preset static value parsing rule to generate a corresponding first SQL assignment statement; and / or, when the data type of the preset data is a dynamic value, the preset data file is parsed based on a preset dynamic value parsing rule to generate a corresponding second SQL assignment statement.
[0074] Furthermore, the database initialization unit is specifically used to: determine whether there are corresponding duplicate row data in the database based on the SQL file; if so, generate an update statement and perform a data update operation on the duplicate row data in the database based on the update statement; if not, generate a write statement and perform a data write operation on the database based on the write statement.
[0075] Furthermore, before determining the pre-configured data file corresponding to the application to be deployed, the system further includes: a mapping relationship construction unit, used to pre-obtain the pre-configured data required for the application deployment and runtime, store the pre-configured data in an initial table file to obtain the pre-configured data file; wherein, the pre-configured data includes the original configuration data and pre-configured business data required for the application deployment and runtime; constructing the mapping relationship between the rows and columns of the pre-configured data file and the rows and columns of the database, and constructing the mapping relationship between the worksheets of the pre-configured data file and the data tables of the database; wherein, each worksheet corresponds to one data table.
[0076] Furthermore, the preset data file determination unit is specifically used to: determine the actual deployment scenario characteristics corresponding to the application under the application deployment scenario, and select the corresponding preset data file based on the actual deployment scenario characteristics.
[0077] Furthermore, before parsing the preset data file based on the mapping rules between the preset data file and the database, the system further includes: a preset data import unit, used to pre-encapsulate the import process of the preset data in the preset data file and determine the HTTP endpoint corresponding to the import process; receive an import request input by the user, and trigger the HTTP endpoint to execute the import control of the preset data based on the import request.
[0078] The database initialization device for application deployment described in this embodiment of the invention determines the preset data file corresponding to the application to be deployed, and parses the preset data file based on the mapping rules between the preset data file and the database to obtain the SQL file corresponding to the database; then, it performs data initialization operations on the database based on the SQL file. This can effectively reduce the difficulty and cost of database initialization during application deployment, facilitate the maintenance and management of the application's preset data, and improve the efficiency of database initialization during application deployment.
[0079] Corresponding to the database initialization method for application deployment provided above, this invention also provides an electronic device. Since the embodiment of this electronic device is similar to the method embodiment described above, it is described simply. For relevant details, please refer to the description in the method embodiment section above. The electronic device described below is merely illustrative. Figure 5 The diagram shown is a schematic representation of the physical structure of an electronic device disclosed in an embodiment of the present invention. The electronic device may include a processor 501, a memory 502, and a communication bus 503. The processor 501 and the memory 502 communicate with each other via the communication bus 503 and communicate with external systems via a communication interface 504. The processor 501 can call logical instructions in the memory 502 to execute a database initialization method for application deployment. This method includes: determining a preset data file corresponding to the application to be deployed; wherein the preset data file is a table file used to manage preset data of the application; parsing the preset data file based on the mapping rules between the preset data file and the database to obtain an SQL file corresponding to the database; and performing data initialization operations on the database based on the SQL file.
[0080] Furthermore, the logical instructions in the aforementioned memory 502 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as memory chips, USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0081] On the other hand, embodiments of the present invention also provide a computer program product, the computer program product including a computer program stored on a processor-readable storage medium, the computer program including program instructions, and when the program instructions are executed by a computer, the computer is able to execute the database initialization method for application deployment provided in the above-described method embodiments. The method includes: determining a preset data file corresponding to the application to be deployed; wherein the preset data file is a table file used to manage preset data of the application; parsing the preset data file based on the mapping rules between the preset data file and the database to obtain an SQL file corresponding to the database; and performing data initialization operations on the database based on the SQL file.
[0082] In another aspect, embodiments of the present invention also provide a processor-readable storage medium storing a computer program, which, when executed by a processor, implements a database initialization method for application deployment provided in the above embodiments. The method includes: determining a preset data file corresponding to the application to be deployed; wherein the preset data file is a table file for managing preset data of the application; parsing the preset data file based on a mapping rule between the preset data file and a database to obtain an SQL file corresponding to the database; and performing data initialization operations on the database based on the SQL file.
[0083] The processor-readable storage medium can be any available medium or data storage device that the processor can access, including but not limited to magnetic memory (e.g., floppy disk, hard disk, magnetic tape, magneto-optical disk (MO)), optical memory (e.g., CD, DVD, BD, HVD), and semiconductor memory (e.g., ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)).
[0084] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0085] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0086] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A database initialization method for application deployment, characterized in that, include: Determine the pre-configured data file corresponding to the application to be deployed; wherein, the pre-configured data file is a table file used to manage the pre-configured data of the application; Based on the mapping rules between the preset data file and the database, the preset data file is parsed to obtain the SQL file corresponding to the database; Perform data initialization operations on the database based on the SQL file; Parsing the preset data file based on the mapping rules between the preset data file and the database to obtain the SQL file corresponding to the database includes: identifying the preset data file based on the mapping rules to determine the data type of the preset data; parsing the preset data file based on the data type to generate corresponding SQL assignment statements; and obtaining the SQL file based on the SQL assignment statements. Identifying the preset data file based on the aforementioned mapping rules to determine the data type of the preset data specifically includes: identifying special identifiers in the preset data file based on the mapping rules; if the preset data in a cell of the preset data file does not contain the special identifier, determining that the data type of the preset data is a static value; if the preset data in a cell of the preset data file contains a preset special identifier, determining that the data type of the preset data is a dynamic value; parsing the preset data file based on the data type to generate corresponding SQL assignment statements specifically includes: when the data type of the preset data is a static value, parsing the preset data file based on preset static value parsing rules to generate corresponding first SQL assignment statements; and / or, when the data type of the preset data is a dynamic value, parsing the preset data file based on preset dynamic value parsing rules to generate corresponding second SQL assignment statements.
2. The database initialization method for application deployment according to claim 1, characterized in that, The data initialization operation of the database based on the SQL file specifically includes: determining whether there are corresponding duplicate row data in the database based on the SQL file; if so, generating an update statement and performing a data update operation on the duplicate row data in the database based on the update statement; if not, generating a write statement and performing a data write operation on the database based on the write statement.
3. The database initialization method for application deployment according to claim 1, characterized in that, Before determining the pre-configured data file corresponding to the application to be deployed, the method further includes: pre-acquiring the pre-configured data required for the application to be deployed and run, storing the pre-configured data in an initial table file to obtain the pre-configured data file; wherein the pre-configured data includes the original configuration data and pre-configured business data required for the application to be deployed and run; constructing the mapping relationship between the rows and columns of the pre-configured data file and the rows and columns of the database, and constructing the mapping relationship between the worksheets of the pre-configured data file and the data tables of the database; wherein each worksheet corresponds to one data table.
4. The database initialization method for application deployment according to claim 1, characterized in that, The step of determining the preset data file corresponding to the application to be deployed includes: In the application deployment scenario, the actual deployment scenario characteristics corresponding to the application are determined, and the corresponding preset data file is selected based on the actual deployment scenario characteristics.
5. The database initialization method for application deployment according to claim 1, characterized in that, Before parsing the preset data file based on the mapping rules between the preset data file and the database, the method further includes: pre-encapsulating the import process of the preset data in the preset data file and determining the HTTP endpoint corresponding to the import process; receiving the import request input by the user, and triggering the HTTP endpoint to execute the import control of the preset data based on the import request.
6. A database initialization device for application deployment, characterized in that, include: A preset data file determination unit is used to determine the preset data file corresponding to the application to be deployed; wherein, the preset data file is a table file used to manage the preset data of the application; The SQL file acquisition unit is used to parse the preset data file based on the mapping rules between the preset data file and the database to obtain the SQL file corresponding to the database. The unit includes: identifying the preset data file based on the mapping rules to determine the data type of the preset data; parsing the preset data file based on the data type to generate corresponding SQL assignment statements; and obtaining the SQL file based on the SQL assignment statements. Identifying the preset data file based on the aforementioned mapping rules to determine the data type of the preset data specifically includes: identifying special identifiers in the preset data file based on the mapping rules; if the preset data in a cell of the preset data file does not contain the special identifier, determining that the data type of the preset data is a static value; if the preset data in a cell of the preset data file contains a preset special identifier, determining that the data type of the preset data is a dynamic value; parsing the preset data file based on the data type to generate corresponding SQL assignment statements specifically includes: when the data type of the preset data is a static value, parsing the preset data file based on preset static value parsing rules to generate corresponding first SQL assignment statements; and / or, when the data type of the preset data is a dynamic value, parsing the preset data file based on preset dynamic value parsing rules to generate corresponding second SQL assignment statements; The database initialization unit is used to perform data initialization operations on the database based on the SQL file.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the database initialization method for application deployment as described in any one of claims 1 to 5.
8. A processor-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the database initialization method for application deployment as described in any one of claims 1 to 5.