CN118193561A - Database initialization method and device for application deployment - Google Patents

Database initialization method and device for application deployment Download PDF

Info

Publication number
CN118193561A
CN118193561A CN202211600612.5A CN202211600612A CN118193561A CN 118193561 A CN118193561 A CN 118193561A CN 202211600612 A CN202211600612 A CN 202211600612A CN 118193561 A CN118193561 A CN 118193561A
Authority
CN
China
Prior art keywords
preset data
database
file
data
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211600612.5A
Other languages
Chinese (zh)
Inventor
董进
朱二夫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Qianxin Technology Group Co Ltd
Secworld Information Technology Beijing Co Ltd
Original Assignee
Qianxin Technology Group Co Ltd
Secworld Information Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Qianxin Technology Group Co Ltd, Secworld Information Technology Beijing Co Ltd filed Critical Qianxin Technology Group Co Ltd
Priority to CN202211600612.5A priority Critical patent/CN118193561A/en
Publication of CN118193561A publication Critical patent/CN118193561A/en
Pending legal-status Critical Current

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a database initialization method and device for application program deployment. The method comprises the following steps: determining a preset data file corresponding to an application program to be deployed; wherein the preset data file is a table file for managing preset data of the application program; analyzing 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 carrying out data initialization operation on the database based on the SQL file. The database initialization method for application program deployment can effectively reduce the difficulty and cost of database initialization when the application program is deployed, is convenient for data maintenance and management, and improves the database initialization efficiency when the application program is deployed.

Description

Database initialization method and device for application deployment
Technical Field
The invention relates to the technical field of application program deployment, in particular to a database initialization method and device for application program deployment. In addition, the invention also relates to an electronic device and a processor readable storage medium.
Background
In recent years, with the rapid development of internet technology, various large-scale software applications are becoming more and more widespread. When large software applications are installed, their flow typically requires initializing the database first and then starting the application process. The initialization of the database is mostly completed by submitting SQL (Structured Query Language; structured query language) files through a version management tool, which contains preset data such as table structures, configuration data, preset service data and the like necessary for the running of the application program. The initialization of the preset data is completed through SQL, and because the preset data and codes are completely bound, when the preset data is too much, SQL files are lengthy, SQL is required to be changed at the same time when the data is changed, and SQL version management is not facilitated. In addition, different language environments, different projects and different clients cannot automatically select different preset data, writing of dynamic field data cannot be supported, and data maintenance is difficult, and often, multiple roles such as products, data maintenance personnel, research and development are involved in data change, so that maintenance and management difficulty is high, and additional cost is introduced to software research and development application programs. Therefore, how to design a more efficient database initialization scheme for application deployment to improve the database initialization efficiency is a challenge to be solved.
Disclosure of Invention
Therefore, the invention provides a database initialization method and device for application program deployment, which are used for solving the defects of the prior art that the database initialization scheme for application program deployment has higher limitation, so that the initialization efficiency is poor and the maintenance difficulty is higher.
In a first aspect, the present invention provides a method for initializing a database for application deployment, including:
determining a preset data file corresponding to an application program to be deployed; wherein the preset data file is a table file for managing preset data of the application program;
analyzing 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 carrying out data initialization operation on the database based on the SQL file.
Further, analyzing 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, including:
Identifying the preset data file based on the mapping rule, and determining the data type of the preset data;
analyzing the preset data file based on the data type to generate a corresponding SQL assignment statement; and obtaining the SQL file based on the SQL assignment statement.
Further, identifying the preset data file based on the mapping rule, and determining the data type of the preset data specifically includes:
Identifying a special identifier in the preset data file based on the mapping rule, and judging the data type of the preset data to be a static value under the condition that the preset data of the unit cells in the preset data file does not exist the special identifier; under the condition that preset data of the unit cells in the preset data file have preset special marks, judging the data type of the preset data to be a dynamic value;
Analyzing the preset data file based on the data type to generate a corresponding SQL assignment statement, wherein the method specifically comprises the following steps:
When the data type of the preset data is a static value, analyzing the preset data file based on a preset static value analysis rule to generate a corresponding first SQL assignment statement; and/or when the data type of the preset data is a dynamic value, analyzing the preset data file based on a preset dynamic value analysis rule to generate a corresponding second SQL assignment statement.
Further, performing data initialization operation on the database based on the SQL file specifically includes: judging whether corresponding repeated data exist in the database based on the SQL file, if so, generating an update statement, and executing data update operation on the repeated data in the database based on the update statement; if not, generating a writing statement, and executing data writing operation on the database based on the writing statement.
Further, before determining the preset data file corresponding to the application program to be deployed, the method further includes: pre-acquiring preset data required by the deployment operation of the application program, and storing the preset data into an initial table file to obtain a preset data file; the preset data comprise original configuration data and preset service data required by the deployment and operation of the application program; constructing a mapping relation between the rows and the columns of the preset data file and the rows and the columns of the database, and constructing a mapping relation between a worksheet of the preset data file and a data sheet of the database; wherein each worksheet corresponds to a data sheet.
Further, the determining the preset data file corresponding to the application program to be deployed includes: and under the deployment condition of the application program, determining the actual deployment scene characteristics corresponding to the application program, and selecting a corresponding preset data file based on the actual deployment scene characteristics.
Further, before parsing the preset data file based on the mapping rule between the preset data file and the database, the method further includes: packaging an import procedure of preset data in the preset data file in advance, and determining an Http endpoint corresponding to the import procedure; and receiving an import request input by a user, and triggering the Http endpoint to execute import control of preset data based on the import request.
In a second aspect, the present invention also provides a database initializing device for application deployment, including:
a preset data file determining unit, configured to determine a preset data file corresponding to an application program to be deployed; wherein the preset data file is a table file for managing preset data of the application program;
The SQL file obtaining unit is used for analyzing the preset data file based on the mapping rule between the preset data file and the database to obtain an SQL file corresponding to the database;
And the database initializing unit is used for carrying out data initializing operation on the database based on the SQL file.
Further, the SQL file obtaining unit is specifically configured to:
Identifying the preset data file based on the mapping rule, and determining the data type of the preset data;
analyzing the preset data file based on the data type to generate a corresponding SQL assignment statement; and obtaining the SQL file based on the SQL assignment statement.
Further, identifying the preset data file based on a mapping rule between the preset data file and a database, and determining the data type of the preset data specifically includes:
Identifying a special identifier in the preset data file based on the mapping rule, and judging the data type of the preset data to be a static value under the condition that the preset data of the unit cells in the preset data file does not exist the special identifier; under the condition that preset data of the unit cells in the preset data file have preset special marks, judging the data type of the preset data to be a dynamic value;
Analyzing the preset data file based on the data type to generate a corresponding SQL assignment statement, wherein the method specifically comprises the following steps:
When the data type of the preset data is a static value, analyzing the preset data file based on a preset static value analysis rule to generate a corresponding first SQL assignment statement; and/or when the data type of the preset data is a dynamic value, analyzing the preset data file based on a preset dynamic value analysis rule to generate a corresponding second SQL assignment statement.
Further, the database initializing unit is specifically configured to: judging whether corresponding repeated data exist in the database based on the SQL file, if so, generating an update statement, and executing data update operation on the repeated data in the database based on the update statement; if not, generating a writing statement, and executing data writing operation on the database based on the writing statement.
Further, before determining the preset data file corresponding to the application program to be deployed, the method further includes: the mapping relation construction unit is used for acquiring preset data required by the deployment operation of the application program in advance, and storing the preset data into an initial table file to obtain a preset data file; the preset data comprise original configuration data and preset service data required by the deployment and operation of the application program; constructing a mapping relation between the rows and the columns of the preset data file and the rows and the columns of the database, and constructing a mapping relation between a worksheet of the preset data file and a data sheet of the database; wherein each worksheet corresponds to a data sheet.
Further, the preset data file determining unit is specifically configured to: and under the deployment condition of the application program, determining the actual deployment scene characteristics corresponding to the application program, and selecting a corresponding preset data file based on the actual deployment scene characteristics.
Further, before parsing the preset data file based on the mapping rule between the preset data file and the database, the method further includes: the preset data importing unit is used for encapsulating an importing process of preset data in the preset data file in advance and determining an Http endpoint corresponding to the importing process; and receiving an import request input by a user, and triggering the Http endpoint to execute import control of preset data based on the import request.
In a third aspect, the present invention also provides an electronic device, including: memory, a processor and a computer program stored on the memory and executable on the processor, the processor executing the computer program implementing the steps of the database initialization method for application deployment as described in any of the above.
In a fourth aspect, the present invention also provides a processor-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of a database initialization method for application deployment as described in any of the above.
According to the database initialization method for application deployment, the preset data files corresponding to the application to be deployed are determined, and the preset data files are analyzed based on the mapping rules between the preset data files and the database, so that SQL files corresponding to the database are obtained; and then, based on the SQL file, data initialization operation is carried out on the database, so that the difficulty and cost of database initialization during application program deployment can be effectively reduced, data maintenance and management are facilitated, and the database initialization efficiency during application program deployment is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following description will briefly describe the drawings that are required to be used in the embodiments or the prior art, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without any inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a database initialization method for application deployment according to an embodiment of the present invention;
fig. 2 is a complete flowchart of a database initialization method for application deployment according to an embodiment of the present invention.
Fig. 3 is a schematic flow chart of file parsing in a database initialization method for application deployment according to an embodiment of the present invention.
FIG. 4 is a schematic diagram of a database initializing apparatus for application deployment according to an embodiment of the present invention;
fig. 5 is a schematic diagram of an entity structure of an electronic device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which are derived by a person skilled in the art from the embodiments according to the invention without creative efforts, fall within the protection scope of the invention.
The following describes embodiments of the method for initializing a database based on application deployment according to the present invention. As shown in fig. 1, a flowchart of a database initialization method for application deployment according to an embodiment of the present invention includes the following steps:
Step 101: determining a preset data file corresponding to an application program to be deployed; wherein the preset data file is a table file for managing preset data of the application program.
In the embodiment of the invention, before a preset data file corresponding to an application program to be deployed is determined, preset data required by the deployment operation of the application program is required to be obtained in advance, and the preset data is stored in an initial table file to obtain a preset data file; the preset data comprise original configuration data and preset service data required by the deployment and operation of the application program; then, constructing a mapping relation between the rows and columns of the preset data file and the rows and columns of the database, and between the worksheet of the preset data file and the data sheet of the database; each worksheet corresponds to one data Sheet, the table file may refer to an Excel file, and the corresponding worksheet may refer to a Sheet page in the Excel file. And establishing a mapping relation between Sheet pages of the Excel file and data tables in a database, wherein each Sheet page corresponds to one data table, so that data isolation is realized. In the implementation process of the step, under the deployment condition of the application program, the actual deployment scene characteristics corresponding to the application program need to be determined, and the corresponding preset data files are selected based on the actual deployment scene characteristics.
Step 102: and analyzing 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.
In the implementation process of the step, the preset data file can be identified based on the mapping rule between the preset data file and the database, and the data type of the preset data can be determined; analyzing the preset data file based on the data type to generate a corresponding SQL assignment statement; and obtaining the SQL file based on the SQL assignment statement. And analyzing remark information of the unit cells in the preset data file based on a mapping rule between the preset data file and the database, judging whether joint unique constraint exists in the preset data file based on the remark information, if so, generating a unique constraint check statement, and judging whether corresponding repeated data exist in the database after verification, if so, executing an update statement according to the joint unique constraint to cover the repeated data.
For example, when parsing to a Sheet page of a special identity, the program will process it specially so that a corresponding additional business action can be performed after the preset data writing is completed. When parsing, the first row of data in the Sheet page is identified as the declaration of the field of the data table, and the data of the other rows in each column are parsed into the assignment of the field in the database. Meanwhile, remark information of a cell where a field in each data table is located is analyzed, when the remark information is Key, the value of the field in the current data table is analyzed to not allow repetition, and when multiple columns of Key remark information is identified to be added, the fields are analyzed to form a joint unique constraint; when the remark information is instrument, the column of preset data is updated or inserted only when the application program is installed; when the remark information is Update, the column of preset data will only be updated or inserted when the application is updated. The definition of remark information in the invention supports expansion, and can meet the processing of more special scenes only by enhancing the application capability, thereby being simpler and more efficient.
It should be noted that, when the preset data file is parsed based on the mapping rule between the preset data file and the database, different Excel elements in the Excel file correspond to different canonical meanings, for example, the Excel element is a "Sheet page name", and the canonical meaning obtained by parsing is "the name of the data table in the database is uniformly identified except for a special identifier"; the Excel element is "$ (post_sql) Sheet page", and the specification obtained by parsing means "the SQL statement which needs to be additionally executed after the completion of writing of preset data"; the Excel element is a row, and the specification obtained by analysis means that the row data except the first row data are mapped to one row (record) of the data table in the database; the Excel element is a column, and the specification obtained by analysis means that each column of data is mapped to one column of the data table in the database except the first row of data; excel element is "first line" and the specification obtained by parsing means "declaration/definition of field in data table"; the Excel element is "first line annotation or remark information" and the specification meaning obtained by parsing is "the cell declared by the field in the data table is added with the annotation key", which indicates that the field is unique ", and the like, and will not be described in detail herein.
In the embodiment of the invention, the special mark in the preset data file is identified based on the mapping rule between the preset data file and the database, and the preset data is judged to be a static value under the condition that the preset special mark does not exist in the preset data of the unit cell in the preset data file; under the condition that preset data of the unit cells in the preset data file have preset special marks, judging that the preset data are dynamic values; analyzing the preset data file based on a preset static value analysis rule to generate a corresponding first SQL assignment statement; and/or analyzing the preset data file based on a preset dynamic value analysis rule to generate a corresponding second SQL assignment statement.
Specifically, during parsing, the first row of cells in the preset data file will be identified as field declarations, where the annotation (i.e., remark information) added with a content of "key" is unique to identify the column data, allowing declarations to be associated with unique constraints. When the data is imported, a judging SQL template (namely an SQL statement template) is automatically generated according to the unique constraint, finally, whether the data exists or not is judged before writing, if the data is repeated, the UPDATE is executed according to the unique constraint, and otherwise, the UPDATE is not covered. The database automatically converts the written data types according to the table statement, so that when the data is assembled with the generated SQL template, special type conversion is not performed on single data, and the data are written in the form of character strings by default. The database library, when written, will automatically convert the value to a format consistent with the table declaration. For example, the write data is't', and the assigned field type is boolean, and then the final value is true.
And analyzing the data of each cell of other rows except the first row of data into values to be assigned in different fields in the data table. If the data of the unit cell is not provided with any special mark, identifying the corresponding preset data as a static value, analyzing the preset data file based on a preset static value analysis rule to generate a corresponding first SQL assignment statement, namely, directly assembling the static value and a dynamically generated SQL template into a final first SQL assignment statement. Static values refer to the data written to the database being consistent with the data declared in the imported preset data file.
When the preset special identification exists in the data in the current cell of the preset data file, the data is divided into two types, wherein one type is a data limiting expression and the other type is a function expression, and the data (namely the data value) representing the cell is written in the data table before being inserted into the data table, and dynamic values, such as external keys, IDs, time and the like, are required to be obtained according to the deployed environment information, the data dynamic and other actual deployment scene characteristics of other data tables and the like.
The dynamic value parsing rule includes: when the data identifying the cells in the table file starts with $ { starts with }, the content in the bracket is identified as a "data defining expression", which indicates that the data needs to be dynamically obtained according to the values of other tables or the current table when being written. According to a preset declaration mode, table names (such as names of Sheet pages) of data sources, condition fields and condition values of screening data and value fields are analyzed from a data limiting expression, a plurality of condition combinations are supported by a condition statement, and finally the condition statement is converted into a second SQL assignment statement, so that the purpose of dynamically assigning a value to a certain field of a current data table is achieved. When it is recognized that the cell data in the preset data file ends with $ (beginning ), the content in the bracket is recognized as a "function expression", which indicates that the data needs to be dynamically acquired through the function expression when being written. The functional expression is converted to a second SQL assignment statement to write dynamic data (i.e., dynamic values) for the field in the data table in real time. The preset declaration mode comprises the following steps: the dynamic value is "$ { data definition expression }" which states "how the data value of the cell in the preset data file is obtained by a specific syntax"; the dynamic value is "$ { data definition expression }", the declaration instance is "$ { table name # field 1 (value 1) }. Assignment field }", which is declared as "assignment: SELECT assignment field FROM table name WHERE field 1 = value 1"; the dynamic value is "$ { data definition expression }", the declaration instance is "$ { table name # field 1 (value 1) # field 2 (value 2) # assignment field }", which is declared as "assignment: SELECT assignment field FROM table name WHERE field 1=value 1AND field 2=value 2). In addition, the preset declaration mode further comprises: the dynamic value is "$ (function expression)", which is stated as "call database itself function expression to assign"; the dynamic value is "$ (functional expression)", the declaration instance is "$ (now ()", which is declared as "assigning: SELECT now (); i.e. the current time. Note that: if the "example" is written directly as now (), then the value is: non () text).
In the actual implementation process of the invention, in the design stage, the design of the data table is obtained in advance, and the data maintainer translates the requirement specification and the data specification of the application program into the format of a preset data file. In the research and development stage or the testing stage, when preset data is adjusted due to various factors such as market, a data maintainer is required to update the preset data without modifying codes. When the application program is integrated, the preset data of each functional module are subjected to unified integrated management, such as unified integrated management on preset business data or basic configuration data corresponding to the vulnerability scanning function of the antivirus software (namely the application program) based on a table file. When an application program is deployed, selecting a corresponding preset data file according to the actual deployment scene characteristics such as the deployed language environment, the client type and the like, and encapsulating an import procedure of preset data in the preset data file in advance and determining an Http endpoint corresponding to the import procedure before analyzing the preset data file based on the mapping rule between the preset data file and a database; and receiving an import request input by a user, and triggering the Http endpoint to execute import control of preset data based on the import request. And finishing data initialization of all services by triggering the exposed Http control endpoint. After the data is imported, the control program analyzes the imported preset data file, so that the data type, the table space, the uniqueness judgment and the like of the preset data are judged, and the SQL template is dynamically generated to complete the import of the preset data, so that the aim of initializing the data of the application program is fulfilled.
Step 103: and carrying out data initialization operation on the database based on the SQL file.
Specifically, whether corresponding repeated data exist in the database or not can be judged based on the SQL file, if yes, an update statement is generated, and data update operation is executed on the repeated data in the database based on the update statement; if not, generating a writing statement, and executing data writing operation on the database based on the writing statement.
In a flexible and configurable initialization scheme of a large software database, preset data refers to a static value and a dynamic value carried in a product when the product is released, wherein the static value is a menu name, a function list and the like carried in the product. By mapping the relational database rows and rows of Excel files, tablespaces (i.e., data tables) and Sheet pages. When large software is deployed and operated, the process always initializes the database first and then starts the application process. The initialization of the database is mostly completed by submitting SQL files through a version management tool, wherein the SQL files comprise necessary table structures and configuration data in the running process of software; and also contains preset software service data. The preset data is divided into two parts, namely a small amount of software configuration data and preset service data, wherein the preset service data is imported in a data migration stage. The invention maintains the preset data through the Excel file by the data maintainer in a unified way, and identifies the table structure relation, the field, the data and the external connection relation among the data in the Excel file through the program during data migration, and writes the data into the corresponding data table in the database automatically. In the subsequent scene of one-key switching operation language, the data importing program is designed by encapsulating the importing program. And controlling the external exposure endpoint by the service exposure interface.
The invention provides a configurable, decoupled, automated data presetting method. The preset data are declared in the form file according to the corresponding analysis rules and are imported into a database corresponding to the application program, the contents in the form file are analyzed into the forms of a data table, a field, data and the like according to the corresponding analysis rules, enrichment and combination of the SQL file are completed according to the strategy of fig. 3, and initialization of the preset data is completed through the flow of fig. 2.
According to the database initialization method for application deployment, the preset data file corresponding to the application to be deployed is determined, and the preset data file is analyzed based on the mapping rule between the preset data file and the database, so that the SQL file corresponding to the database is obtained; and then, carrying out data initialization operation on the database based on the SQL file, so that the difficulty and cost of database initialization during application program deployment can be effectively reduced, the maintenance and management of application program preset data are facilitated, and the database initialization efficiency during application program deployment is improved.
Corresponding to the database initialization method for application program deployment provided above, the invention also provides a database initialization device for application program deployment. Since the embodiments of the apparatus are similar to the method embodiments described above, the description is relatively simple, and reference should be made to the description of the method embodiments described above, and the embodiments of the application-deployed database initialization apparatus described below are merely illustrative. Fig. 4 is a schematic structural diagram of a database initializing device for application program deployment according to an embodiment of the present invention.
The invention relates to a database initializing device for application program deployment, which specifically comprises the following parts:
A preset data file determining unit 401, configured to determine a preset data file corresponding to an application program to be deployed; wherein the preset data file is a table file for managing preset data of the application program;
an SQL file obtaining unit 402, configured to parse 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 the database initializing unit 403 is configured to perform a data initializing operation on the database based on the SQL file.
Further, the SQL file obtaining unit is specifically configured to:
Identifying the preset data file based on the mapping rule, and determining the data type of the preset data;
analyzing the preset data file based on the data type to generate a corresponding SQL assignment statement; and obtaining the SQL file based on the SQL assignment statement.
Further, identifying the preset data file based on a mapping rule between the preset data file and a database, and determining the data type of the preset data specifically includes:
Identifying a special identifier in the preset data file based on the mapping rule, and judging the data type of the preset data to be a static value under the condition that the preset data of the unit cells in the preset data file does not exist the special identifier; under the condition that preset data of the unit cells in the preset data file have preset special marks, judging the data type of the preset data to be a dynamic value;
Analyzing the preset data file based on the data type to generate a corresponding SQL assignment statement, wherein the method specifically comprises the following steps:
When the data type of the preset data is a static value, analyzing the preset data file based on a preset static value analysis rule to generate a corresponding first SQL assignment statement; and/or when the data type of the preset data is a dynamic value, analyzing the preset data file based on a preset dynamic value analysis rule to generate a corresponding second SQL assignment statement.
Further, the database initializing unit is specifically configured to: judging whether corresponding repeated data exist in the database based on the SQL file, if so, generating an update statement, and executing data update operation on the repeated data in the database based on the update statement; if not, generating a writing statement, and executing data writing operation on the database based on the writing statement.
Further, before determining the preset data file corresponding to the application program to be deployed, the method further includes: the mapping relation construction unit is used for acquiring preset data required by the deployment operation of the application program in advance, and storing the preset data into an initial table file to obtain a preset data file; the preset data comprise original configuration data and preset service data required by the deployment and operation of the application program; constructing a mapping relation between the rows and the columns of the preset data file and the rows and the columns of the database, and constructing a mapping relation between a worksheet of the preset data file and a data sheet of the database; wherein each worksheet corresponds to a data sheet.
Further, the preset data file determining unit is specifically configured to: and under the deployment condition of the application program, determining the actual deployment scene characteristics corresponding to the application program, and selecting a corresponding preset data file based on the actual deployment scene characteristics.
Further, before parsing the preset data file based on the mapping rule between the preset data file and the database, the method further includes: the preset data importing unit is used for encapsulating an importing process of preset data in the preset data file in advance and determining an Http endpoint corresponding to the importing process; and receiving an import request input by a user, and triggering the Http endpoint to execute import control of preset data based on the import request.
According to the database initializing device for application program deployment, the preset data files corresponding to the application programs to be deployed are determined, and the preset data files are analyzed based on the mapping rules between the preset data files and the database, so that SQL files corresponding to the database are obtained; and then, carrying out data initialization operation on the database based on the SQL file, so that the difficulty and cost of database initialization during application program deployment can be effectively reduced, the maintenance and management of application program preset data are facilitated, and the database initialization efficiency during application program deployment is improved.
Corresponding to the database initialization method for application program deployment, the invention also provides electronic equipment. Since the embodiments of the electronic device are similar to the method embodiments described above, the description is relatively simple, and reference should be made to the description of the method embodiments described above, and the electronic device described below is merely illustrative. Fig. 5 is a schematic diagram of the physical structure of an electronic device according to an embodiment of the present invention. The electronic device may include: a processor (processor) 501, a memory (memory) 502 and a communication bus 503, wherein the processor 501 and the memory 502 complete communication with each other through the communication bus 503 and communicate with the outside through a communication interface 504. The processor 501 may invoke logic instructions in the memory 502 to perform a database initialization method for application deployment, the method comprising: determining a preset data file corresponding to an application program to be deployed; wherein the preset data file is a table file for managing preset data of the application program; analyzing 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 carrying out data initialization operation on the database based on the SQL file.
Further, the logic instructions in the memory 502 described above may be implemented in the form of software functional units and stored in a computer readable storage medium when sold or used as a stand alone product. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a Memory chip, a usb disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk.
In another aspect, embodiments of the present invention further provide a computer program product, including a computer program stored on a processor readable storage medium, the computer program including program instructions which, when executed by a computer, are capable of executing the database initialization method of application deployment provided by the above method embodiments. The method comprises the following steps: determining a preset data file corresponding to an application program to be deployed; wherein the preset data file is a table file for managing preset data of the application program; analyzing 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 carrying out data initialization operation on the database based on the SQL file.
In yet another aspect, embodiments of the present invention further provide a processor-readable storage medium having a computer program stored thereon, which when executed by a processor is implemented to perform the database initialization method for application deployment provided in the above embodiments. The method comprises the following steps: determining a preset data file corresponding to an application program to be deployed; wherein the preset data file is a table file for managing preset data of the application program; analyzing 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 carrying out data initialization operation on the database based on the SQL file.
The processor-readable storage medium may be any available medium or data storage device that can be accessed by a processor, including, but not limited to, magnetic storage (e.g., floppy disks, hard disks, magnetic tape, magneto-optical disks (MOs), etc.), optical storage (e.g., CD, DVD, BD, HVD, etc.), and semiconductor storage (e.g., ROM, EPROM, EEPROM, non-volatile storage (NAND FLASH), solid State Disk (SSD)), etc.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A method for initializing a database for application deployment, comprising:
determining a preset data file corresponding to an application program to be deployed; wherein the preset data file is a table file for managing preset data of the application program;
analyzing 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 carrying out data initialization operation on the database based on the SQL file.
2. The method for initializing a database for application deployment according to claim 1, wherein analyzing 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 comprises:
Identifying the preset data file based on the mapping rule, and determining the data type of the preset data;
analyzing the preset data file based on the data type to generate a corresponding SQL assignment statement; and obtaining the SQL file based on the SQL assignment statement.
3. The method for initializing a database for application deployment according to claim 2, wherein the identifying the preset data file based on the mapping rule, determining the data type of the preset data, specifically comprises:
Identifying a special identifier in the preset data file based on the mapping rule, and judging the data type of the preset data to be a static value under the condition that the preset data of the unit cells in the preset data file does not exist the special identifier; under the condition that preset data of the unit cells in the preset data file have preset special marks, judging the data type of the preset data to be a dynamic value;
Analyzing the preset data file based on the data type to generate a corresponding SQL assignment statement, wherein the method specifically comprises the following steps:
When the data type of the preset data is a static value, analyzing the preset data file based on a preset static value analysis rule to generate a corresponding first SQL assignment statement; and/or when the data type of the preset data is a dynamic value, analyzing the preset data file based on a preset dynamic value analysis rule to generate a corresponding second SQL assignment statement.
4. The method for initializing a database for application deployment according to claim 1, wherein the step of performing a data initializing operation on the database based on the SQL file comprises: judging whether corresponding repeated data exist in the database based on the SQL file, if so, generating an update statement, and executing data update operation on the repeated data in the database based on the update statement; if not, generating a writing statement, and executing data writing operation on the database based on the writing statement.
5. The method for initializing a database for application deployment according to claim 1, further comprising, before determining a preset data file corresponding to an application to be deployed: pre-acquiring preset data required by the deployment operation of the application program, and storing the preset data into an initial table file to obtain a preset data file; the preset data comprise original configuration data and preset service data required by the deployment and operation of the application program; constructing a mapping relation between the rows and the columns of the preset data file and the rows and the columns of the database, and constructing a mapping relation between a worksheet of the preset data file and a data sheet of the database; wherein each worksheet corresponds to a data sheet.
6. The method for initializing a database for application deployment according to claim 1, wherein the determining a preset data file corresponding to an application to be deployed comprises:
and under the deployment condition of the application program, determining the actual deployment scene characteristics corresponding to the application program, and selecting a corresponding preset data file based on the actual deployment scene characteristics.
7. The application deployed database initialization method of claim 1, further comprising, prior to parsing the preset data file based on a mapping rule between the preset data file and a database: packaging an import procedure of preset data in the preset data file in advance, and determining an Http endpoint corresponding to the import procedure; and receiving an import request input by a user, and triggering the Http endpoint to execute import control of preset data based on the import request.
8. A database initialization apparatus for application deployment, comprising:
a preset data file determining unit, configured to determine a preset data file corresponding to an application program to be deployed; wherein the preset data file is a table file for managing preset data of the application program;
The SQL file obtaining unit is used for analyzing the preset data file based on the mapping rule between the preset data file and the database to obtain an SQL file corresponding to the database;
And the database initializing unit is used for carrying out data initializing operation on the database based on the SQL file.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the database initialization method of an application deployment according to any one of claims 1 to 7 when the computer program is executed by the processor.
10. A processor readable storage medium having stored thereon a computer program, which when executed by a processor, implements the steps of the database initialization method of an application deployment according to any of claims 1 to 7.
CN202211600612.5A 2022-12-12 2022-12-12 Database initialization method and device for application deployment Pending CN118193561A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211600612.5A CN118193561A (en) 2022-12-12 2022-12-12 Database initialization method and device for application deployment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211600612.5A CN118193561A (en) 2022-12-12 2022-12-12 Database initialization method and device for application deployment

Publications (1)

Publication Number Publication Date
CN118193561A true CN118193561A (en) 2024-06-14

Family

ID=91404816

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211600612.5A Pending CN118193561A (en) 2022-12-12 2022-12-12 Database initialization method and device for application deployment

Country Status (1)

Country Link
CN (1) CN118193561A (en)

Similar Documents

Publication Publication Date Title
US7240279B1 (en) XML patterns language
US8601438B2 (en) Data transformation based on a technical design document
US20050004973A1 (en) Reflection-based processing of input parameters for commands
CN106844380A (en) A kind of database operation method, information processing method and related device
AU2016302371A1 (en) Building and managing data-processing attributes for modeled data sources
US7610292B2 (en) Systems and methods for storing a dataset having a hierarchical data structure in a database
CN112328226B (en) Embedded system automatic test code generation method and device
CN112560100A (en) Data desensitization method and device, computer readable storage medium and electronic equipment
CN114625349A (en) Front-end page generation method and device, terminal equipment and storage medium
CN113901083A (en) Heterogeneous data source operation resource analysis positioning method and equipment based on multiple analyzers
CN116560642A (en) Code generation method and device, electronic equipment and storage medium
CN113703777A (en) Code generation method and device based on database table, storage medium and equipment
CN116450107B (en) Method and device for secondary development of software by low-code platform and electronic equipment
KR100762712B1 (en) Method for transforming of electronic document based on mapping rule and system thereof
CN112835638A (en) Configuration information management method and device based on embedded application program
CN112579604A (en) Test system number making method, device, equipment and storage medium
JP2003248635A (en) Database accessing method and system in management information base of network management protocol
US7856344B2 (en) Method for transforming overlapping paths in a logical model to their physical equivalent based on transformation rules and limited traceability
CN113672233B (en) Server out-of-band management method, device and equipment based on Redfish
CN118193561A (en) Database initialization method and device for application deployment
CN112114794B (en) Automatic generation method and device of website application program and computer storage medium
US7437714B1 (en) Category partitioning markup language and tools
US7428697B2 (en) Preserving content or attribute information during conversion from a structured document to a computer program
US20050268291A1 (en) Specifying user interface interactions for controls in a data driven system
CN111444161A (en) Data processing method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination