A record table generation method, device, equipment and storage medium
Patent Information
- Application Number
- CN202410532243.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-29
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2044-04-29
AI Technical Summary
[0003]现有技术中,在数据库中新增数据表时,需要开发人员查看新增数据表中包含的每个字段以及字段对应的含义,再根据SPI实现类的编写规范编写该数据表对应的SPI实现类,才能在该数据表被修改时,将该数据表的修改内容展示在数据库修改记录表中,导致在数据库中新接入数据表的效率较低,并且容易出错,无法快速生成新的数据库修改记录表
[0018]本申请实施例第四方面提供一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时,实现本申请第一方面所述的方法的步骤。
Smart Images

Figure CN118535573B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and more specifically, to a method, apparatus, device, and storage medium for generating record tables. Background Technology
[0002] Servers typically store data tables that record various types of information in a database. The system requires that every important field in each data table has a complete modification record. Currently, modifications to each data table in the system are recorded through a database modification record table. When displaying the modification records of the data tables in the database modification record table, the fields in each data table are displayed through the SPI (Service Provider Interface) mechanism.
[0003] In existing technologies, when adding a new data table to a database, developers need to examine each field in the new data table and its meaning, and then write the corresponding SPI implementation class for that data table according to the SPI implementation class writing specifications. Only then can the changes to the data table be displayed in the database modification record table when the data table is modified. This results in low efficiency and a high risk of errors when adding new data tables to the database, and makes it impossible to quickly generate a new database modification record table. Summary of the Invention
[0004] This application provides a method, apparatus, device, and storage medium for generating a record table, which aims to quickly generate a database modification record table.
[0005] A first aspect of this application provides a method for generating a record table, the method comprising:
[0006] Read the input file and determine the file type of the input file, where the file type includes data table definition files and data tables;
[0007] When the input file is a data table definition file, a corresponding data table and SPI implementation class are generated based on the field information in the data table definition file. The SPI implementation class is used to record the correspondence between the field content and field description of each field in the data table.
[0008] The data table is stored in the database, and the SPI implementation class is compiled into the general code.
[0009] When the data in the data table is modified, the information change record corresponding to the data table is parsed through the SPI implementation class;
[0010] The modified content obtained from the parsed data table is loaded into the database modification record table.
[0011] A second aspect of this application provides a record table generation apparatus, the apparatus comprising:
[0012] The file type confirmation module is used to read the input file and determine the file type of the input file, wherein the file type includes data table definition file and data table;
[0013] The first SPI implementation class acquisition module is used to generate a corresponding data table and SPI implementation class based on the field information in the data table definition file when the file type of the input file is a data table definition file. The SPI implementation class is used to record the correspondence between the field content and field description of each field in the data table.
[0014] A data table storage module is used to store the data table in a database and to compile the SPI implementation class into general code.
[0015] The data parsing module is used to parse the corresponding modification records in the data table through the SPI implementation class when the data in the data table is modified.
[0016] The data synchronization module is used to load the modified content in the parsed data table into the database modification record table.
[0017] A third aspect of this application provides a readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps described in the first aspect of this application.
[0018] A fourth aspect of this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the method described in the first aspect of this application.
[0019] Using the record table generation method provided in this application, the corresponding data table and SPI implementation class can be generated by reading the data table definition file. When adding a new data table in the database, the corresponding SPI implementation class can be obtained based on the read data table definition file. When the data table in the database is modified, the data table change record is parsed through the newly added SPI implementation class, and the parsing result is synchronized to the database modification record table. When adding a new data table, it is not necessary to manually view the fields and the field descriptions of each field to write the SPI implementation class, thus quickly generating the database modification record table. Attached Figure Description
[0020] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart of a record table generation method proposed in an embodiment of this application;
[0022] Figure 2 This is a flowchart of a record table generation method proposed in an embodiment of this application;
[0023] Figure 3 This is a flowchart of a record table generation method proposed in an embodiment of this application;
[0024] Figure 4 This is a flowchart of a record table generation method proposed in an embodiment of this application;
[0025] Figure 5 This is a flowchart of a record table generation method proposed in an embodiment of this application;
[0026] Figure 6 This is a flowchart of a record table generation method proposed in an embodiment of this application;
[0027] Figure 7 This is a flowchart of a record table generation method proposed in an embodiment of this application;
[0028] Figure 8 This is a schematic flowchart of a record table generation method according to an embodiment of this application;
[0029] Figure 9 This is a schematic diagram of a record table generation device according to an embodiment of this application. Detailed Implementation
[0030] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0031] refer to Figure 1 , Figure 1 This is a flowchart of a record table generation method proposed in an embodiment of this application. Figure 1 As shown, the method includes the following steps:
[0032] S11: Read the input file and determine the file type of the input file, wherein the file type includes a data table definition file and a data table.
[0033] In this embodiment, the data table definition file (JavaBean file) includes code that defines each item in the data table, defines the name of each item, and provides a description of the item name. The data table definition is essentially a program class that encapsulates a custom program to implement the corresponding functionality. By writing the data table definition file, the various items of the input data table are defined, and the function of generating the corresponding data table and SPI implementation class based on the input data table definition file can be implemented. The data table is a table for recording business data.
[0034] In this embodiment, the database stores data from many different business processes. Each business process has a corresponding data table that records the data, and each data table records specific items. When data in the database is modified, the specific data recorded under the corresponding item in the data table will change. The database modification record table will record the specific items modified in the data table and provide personalized displays of the changes to each field in each data table.
[0035] In this embodiment, when a new data table is accessed, the fields in the data table need to be displayed in a personalized manner in the database modification record table. First, the input file is read to determine the file type of the input file. The type of the input file can be a data table definition file or a data table.
[0036] In this embodiment, reference Figure 2 , Figure 2 This is a flowchart of a record table generation method according to an embodiment of this application, such as... Figure 2 Step S11 shown specifically includes:
[0037] S11-1: Obtain the file extension of the input file.
[0038] In this embodiment, the file name includes the base file name and the file extension. The file extension, also called the suffix, can represent the type of the file.
[0039] In this embodiment, after receiving the input file, the file name of the file is read to obtain the file extension.
[0040] For example, the file extension for a data table definition file is .isp, and the file extension for a data table is myi, myd, frm, ibd, isl, etc.
[0041] S11-2: Determine the file type of the input file based on the file extension.
[0042] In this embodiment, the file types include data table definition files and data tables.
[0043] In this embodiment, after obtaining the file extension of the input file, the file type of the file is determined based on the file extension. When the file extension is the extension corresponding to a data table definition file, the file type of the file is determined to be a data table definition file. When the file extension is the extension corresponding to a data table file, the file type of the file is determined to be a data table.
[0044] For example, if the file extension of the input file is .isp, the file type of the file is determined to be a data table definition file; if the file extension of the input file is any one of myi, myd, frm, ibd, or isl, the file type of the file is determined to be a data table.
[0045] S12: If the input file is a data table definition file, generate a corresponding data table and SPI implementation class based on the field information in the data table definition file. The SPI implementation class is used to record the correspondence between the field content and field description of each field in the data table.
[0046] In this embodiment, the field information includes the fields of each item in the data table that needs to be accessed in the database, along with their corresponding descriptions. The SPI (Service Provider Interface) implementation class is a concrete implementation class dynamically loaded based on the SPI mechanism, dynamically loading the correspondence between each field and its description in the data table.
[0047] In this embodiment, when the file type of the input file is determined to be a data table definition file, a corresponding table creation statement is generated based on the field information of each field in the data table included in the data table definition file. The table creation statement is then executed to create the corresponding data table. At the same time, a corresponding SPI implementation class is generated based on the field information of the fields included in the data table definition file.
[0048] In this embodiment, reference Figure 3 , Figure 3 This is a flowchart of a record table generation method according to an embodiment of this application, as follows: Figure 3 As shown, step S12 specifically includes:
[0049] S12-1: Generate the table creation statement according to the field information and the preset table creation statement generation rules.
[0050] In this embodiment, the field information includes the field content and corresponding field description for each field. Based on each field and its description, a corresponding table creation statement can be generated. A table creation statement is a program statement used to create a data table. Executing the table creation statement creates the corresponding data table. The table creation statement generation rule is a rule for generating the corresponding data table based on the field information of the data table contained in the data table definition file. This rule is also called a table creation statement generation template. This rule is predefined and is directly invoked when the data table definition file is received.
[0051] In this embodiment, after obtaining the data table definition file, the statements in the file are parsed to obtain the field information contained therein. Then, the field content and corresponding field description of each field in the data table to be created are determined. Based on the field content and corresponding field description of each field, a table creation statement is generated. At the same time, based on the field content and corresponding description of each field, a corresponding SPI implementation class is generated. This SPI implementation class records the correspondence between the field content and field description of each field, and can be dynamically loaded into the database modification record table through the SPI mechanism.
[0052] In this embodiment, after obtaining the field information from the data table definition file, the preset table creation statement generation rules are called, and the corresponding table creation statement is generated according to the preset table creation statement generation rules. That is, the program corresponding to the pre-written table creation statement generation rules is called, the program is run, and the corresponding table creation statement is generated according to the field information. The table creation statement specifies the table name and each field of the data table to be created in a standardized way. Running the table creation statement can create a new table.
[0053] For example, the table creation statement generation rules are based on the writing rules of SQL (Structured Query Language). The generated statement is an SQL statement, which is the default statement of the database system. For example, when adding a new "Operation Information Table", the generated table creation statement includes "Create new table, table name: Operation Information Table, field 1: ..., field 2: ... etc."
[0054] S12-2: Based on the field information, generate the SPI implementation class according to the preset SPI implementation class generation rules.
[0055] In this embodiment, the generation rules for the SPI implementation class are pre-written. The common parts of the SPI implementation class are written as a fixed template, and the remaining parts can be filled with the corresponding data table information. When generating the SPI implementation class, the field information of the data table for which the SPI implementation class needs to be generated is input into the template to obtain the corresponding SPI implementation class.
[0056] In this embodiment, after obtaining the field information, each field and its corresponding field description are input into a fixed template. After the input is completed, the statement that fills in the field information is executed, thereby generating the corresponding SPI implementation class. The SPI implementation class records the correspondence between each field in the data table and the field description, and is loaded through the SPI mechanism when needed.
[0057] For example, in the self-media table, an item is identified as having video permissions based on the field information. For this item, field 1 represents that it has been enabled and field 0 represents that it has not been enabled, thereby generating the SPI implementation class "1-enabled" and "0-not enabled".
[0058] S12-3: Execute the table creation statement to generate the data table corresponding to the data table definition file.
[0059] In this embodiment, after the table creation statement is generated, the table creation statement is executed to generate the data table corresponding to the data table definition file.
[0060] For example, when the data table added to the database is named "Self-Media Table," the corresponding data table definition file specifies the field content and corresponding field description for each category in the data table. Based on the field content and corresponding field descriptions, and according to preset write rules, the corresponding SPI implementation class is generated. For instance, a category named "Authentication Source" includes four fields: 0, 1, 2, and 3. Field 0 is described as "Historical Data Synchronization," field 1 as "PCweb Registration," field 2 as "Mobile Registration," and field 3 as "Operator." After obtaining the field content and corresponding field descriptions for each category of the Self-Media Table, the corresponding table creation statement is generated, and then executed to generate the data table corresponding to the data table definition file.
[0061] S13: Store the data table in the database.
[0062] In this embodiment, after generating a data table based on the input file, the generated data table is stored in the database.
[0063] In this embodiment, when a new data table is added to the database, the corresponding table creation statement is generated by inputting the data table definition file corresponding to the data table. The data table can be obtained by executing the table creation statement and then stored in the database, thus completing the addition of the data table.
[0064] In this embodiment, after storing the data table in the database, the generated SPI implementation class is placed in the synchronization code package. After placing it in the synchronization code package, the synchronization code package is compiled into the database's general code. Only then can the changes to the data table be synchronized to the database modification record table through the SPI mechanism when the data table is modified.
[0065] For example, the database is a MySQL database, which is a relational database that can store data in different tables. When needed, the desired data can be viewed by calling the tables.
[0066] In this embodiment, the database modification record table is used to record the modification status of each field in each data table of the database, including the modification time of each field, the content before modification, and the content after modification.
[0067] In this embodiment, after obtaining the SPI implementation class corresponding to the data table definition, the code of the SPI implementation class is copied into the general code package, and then the general code package is compiled into the general code of the database for use by database users.
[0068] In this embodiment, reference Figure 4 , Figure 4 This is a flowchart of a record table generation method proposed in an embodiment of this application, such as... Figure 4 As shown, after loading the SPI implementation class into the database, the method further includes:
[0069] S21: Place the SPI implementation class into the synchronization code package.
[0070] In this embodiment, the synchronization code package is a code program package that synchronizes data to the database. By running the synchronization code package, the data that needs to be stored in the database can be synchronized to the database.
[0071] In this embodiment, while storing the data table in the database, the generated SPI implementation class is copied into the synchronization code package.
[0072] S22: Compile the synchronization code package containing the SPI implementation class into the general code corresponding to the database.
[0073] In this embodiment, the generic code is the generic code of the database project that runs on the computer.
[0074] In this embodiment, the synchronization code package is compiled into the general code corresponding to the database. First, the synchronization code package is added to the general code, and then the general code is recompiled. After the compilation is completed, the synchronization code package is compiled into the general code.
[0075] In this embodiment, after compiling the synchronization code package into the general code, the projects that depend on the general code are repackaged, and the projects corresponding to the newly connected data tables can be put online for use by project users.
[0076] S23: Load the modified content from the parsed data table into the database modification record table, including:
[0077] The modifications in the data table are synchronized to the database modification record table through the SPI mechanism.
[0078] In this embodiment, the code corresponding to the SPI implementation class is placed in a synchronization code package, and then the synchronization code package is compiled into the general code corresponding to the database. When the data on the data table in the database changes, the code corresponding to the SPI implementation class is run to parse the modified content of the data table, and then the parsed modified content in the data table is synchronized to the database modification record table.
[0079] For example, when the data table to be accessed is a "self-media table", a data table definition file corresponding to the self-media table is provided. Based on the data table definition file, the self-media table and the corresponding SPI implementation class are generated. The SPI implementation class is added to the synchronization code package. After the synchronization code package is compiled into the general code, the database can call this part of the code at any time. When the self-media table is modified, the database modification record table can determine which fields in the self-media table have been modified based on the SPI implementation class corresponding to the self-media table, and then load the modified content into the database modification record table.
[0080] S14: If the data in the data table is modified, the information change record corresponding to the data table is parsed through the SPI implementation class.
[0081] In this embodiment, the information change record is the time and content of the information change in the data table that the database records when the data in the data table changes.
[0082] In this embodiment, when data in a newly accessed data table is modified, the database records the modification time and the modified content. Specifically, it records the field content of each data item in the data table before and after the modification. The SPI implementation class records the correspondence between each field in the data table and its description. After a certain field in the data table is modified, the SPI implementation class corresponding to that data table is called. Based on the pre-stored correspondence between fields and their descriptions, the information change record of the data table is parsed to determine which field and which value was modified.
[0083] For example, the accessed data table is the "Self-Media Table". If the field in the second row of the second column is changed from 0 to 1, the corresponding information change record will be "Modification time: 2023-7-22-12:00, content before modification 0, content after modification 1". The SPI implementation class in the Self-Media Table stores the video permission field in the second row of the second column of the Self-Media Table. Field 0 indicates no permission, and field 1 indicates permission. By parsing the information change record based on the stored content, it is determined that the video permission field has been modified from no permission to permission.
[0084] S15: Load the modified content from the parsed data table into the database modification record table.
[0085] In this embodiment, after obtaining the parsing result, the parsed result is loaded into the database modification record table through the SPI mechanism, thereby generating the latest database modification record table.
[0086] In this embodiment, when a new data table is added to the database, a data table definition file is provided. Based on pre-set table creation statement generation rules and SPI implementation class generation rules, the corresponding table creation statement and SPI implementation class are generated, enabling rapid data table integration into the database. The generation scheme of the SPI implementation class corresponding to the data table has been standardized. Only the data table definition file is needed to generate the corresponding SPI implementation class based on the field information in the data table definition file. This method is applicable to every data table, eliminating the need to manually write the corresponding SPI implementation class every time a new data table is added. Each field in the database modification record table is displayed in a personalized manner. Based on the SPI mechanism, the relationship between the field content and field description of each field is dynamically loaded into the database modification record table. This allows for rapid parsing of information change records when the data table undergoes information changes, thereby generating the corresponding database modification record table and enabling rapid integration of new data tables into the database.
[0087] In another embodiment of this application, reference is made to Figure 5 , Figure 5 This is a flowchart of a record table generation method according to an embodiment of this application, as follows: Figure 5 As shown, the procedure before step S13 also includes:
[0088] S31: If the input file type is a data table, generate the corresponding data table definition file and the SPI implementation class according to the table information of the data table.
[0089] In this embodiment, the table information includes the field content of each column in the data table and the field description corresponding to each field, the name of the data table, the size of the data table, and other data table-related information.
[0090] In this embodiment, when accessing a data table, the business can directly provide the data table to be accessed and input the data table into the database. When the type of the input file is detected as a data table, the table information of the data table is read from the database, thereby obtaining the field content and corresponding field description of each field in the data table. Based on the table information of the data table, a corresponding data table definition file is generated according to the preset data table definition file generation rules, and a corresponding SPI implementation class is generated according to the preset SPI implementation class generation rules.
[0091] For example, if you directly input "self-media table" into the database, when the input file is detected as a data table, connect to the MySQL database, obtain the table information of the data table, determine the field content and field description of each column in the data table, then call the preset data table definition file generation rules to generate the data table definition file corresponding to the data table, and call the preset SPI generation rules to generate the SPI implementation class corresponding to the data table.
[0092] In this embodiment, reference Figure 6 , Figure 6 This is a flowchart of a record table generation method according to an embodiment of this application, as follows: Figure 6 As shown, step S31 includes:
[0093] S31-1: Read the data table to obtain the table information of the data table.
[0094] In this embodiment, when a new data table is added to the database, the newly added data table is read. The field content of each column in the data table and the field description corresponding to each field are read to determine the name of the data table, the size of the data table, and other information, thereby obtaining the table information of the data table.
[0095] For example, after accessing the data table, the data table is read to obtain the table name "Self-Media Table", as well as the field content of each column in the Self-Media Table, and then the field description corresponding to each field is obtained.
[0096] S31-2: Based on the table information, determine the field content and field description of each field contained in the data table.
[0097] In this embodiment, after obtaining the table information, the field content and field descriptions contained in the data table are determined.
[0098] For example, the first row of a certain section contains the field "Video Permissions", the second row contains the field "0", the field description for 0 is 0 - permission not enabled, and the third row contains the field "1", the field description for 1 is 1 - permission enabled.
[0099] S31-3: Generate the data table definition file and the SPI implementation class based on the field content and the field description.
[0100] In this embodiment, a data table definition file and an SPI implementation class are generated based on the field content and field description of the access data table. When generating the data table definition file, the field content and corresponding field description of each field are written. When generating the SPI implementation class, the field content and corresponding field description of each field are written.
[0101] In this embodiment, reference Figure 7 , Figure 7 This is a flowchart of a record table generation method according to an embodiment of this application, as follows: Figure 7 Step S31-3 shown includes:
[0102] S31-3-1: The field content and field description are written into a file according to the preset writing rules to obtain the data table definition file.
[0103] In this embodiment, the preset writing rules correspond to a template program for generating data table definition files. By filling the field content and field descriptions into the template program and running the template program, the corresponding data table definition file can be obtained.
[0104] For example, when the received data table is a "self-media table", the table information of the obtained self-media table will be used to compose the corresponding data table definition file according to the Java file format.
[0105] S31-3-2: Write the correspondence between the field content and the field description according to the preset writing rules to obtain the SPI implementation class.
[0106] In this embodiment, the preset writing rule corresponds to a template program for generating SPI implementation classes. The field content and the corresponding field description are filled into the template program to obtain the corresponding SPI implementation class.
[0107] In this embodiment, if the data table definition file is not found in the project user code, the data table definition file is synchronized to the project user code.
[0108] In this embodiment, the project user code is the code run by the party using the database.
[0109] In this embodiment, if the data table definition file is not found in the project user code, the generated data table definition file is copied to the project user code, and then the project user code is recompiled to synchronize the data table definition file to the project user code. After having the data table definition file, the data table can be called by running the file.
[0110] In this embodiment, after recompiling the project code, the code of the project's dependent projects is repackaged, that is, the code corresponding to the data table related to the data table is packaged and put into the same data package, and then the data package is put into the background of the online database for execution.
[0111] In this embodiment, when the provided file is a data table, the corresponding data table definition file and SPI implementation class can be generated by identifying the table information in the data table. Alternatively, the SPI implementation class of the data table can be automatically generated when accessing the data table, eliminating the need for manual writing according to the writing rules of the SPI implementation class. This improves the speed of data table access and allows the information of the data table to be quickly entered into the database modification record table.
[0112] refer to Figure 8 , Figure 8 This is a schematic flowchart of a record table generation method according to an embodiment of this application, as shown below. Figure 8 As shown, when adding a new data table to the database, a data table definition file can be used or the data table can be provided directly. When a data table definition file is provided, table creation statements are generated based on the data table definition file, and a corresponding SPI implementation class is also generated. The generated statements are then executed to create the data table. Afterward, the SPI implementation class is placed into a synchronization code package, which is then compiled into the general code. When the provided file is a data table, the table information is read, and a data table definition file and an SPI implementation class are generated based on the read table information. If the project already has a data table definition file, the SPI implementation class is directly placed into the synchronization code package, which is then compiled into the general code. If the project does not have a data table definition file, it also needs to be included in the user's project.
[0113] In the above embodiments of this application, when a new data table is added to the database, in order to quickly generate a new database modification record table, the corresponding data table and corresponding SPI implementation class are generated when the provided file is a data table definition file. Based on the fields and field descriptions contained in the provided file, the corresponding SPI implementation class is generated according to the corresponding generation rules. When the data table is modified, the field description corresponding to each field can be determined according to the generated SPI implementation class to parse the modification of the record table. The modification details of the data table are recorded in the database modification record table. This eliminates the need to manually write an SPI implementation class for each newly added data table, improving the efficiency of data table access to the database and increasing the speed of generating the database modification record table.
[0114] Based on the same inventive concept, one embodiment of this application provides a record table generation apparatus. (Reference) Figure 9 , Figure 9 This is a schematic diagram of a record table generation apparatus 900 according to an embodiment of this application. Figure 9 As shown, the device includes:
[0115] The file type confirmation module 901 is used to read the input file and determine the file type of the input file, wherein the file type includes a data table definition file and a data table.
[0116] The first SPI implementation class acquisition module 902 is used to generate a corresponding data table and SPI implementation class based on the field information in the data table definition file when the file type of the input file is a data table definition file. The SPI implementation class is used to record the correspondence between the field content and field description of each field in the data table.
[0117] The data table storage module 903 is used to store the data table in a database and to compile the SPI implementation class into general code.
[0118] The data parsing module 904 is used to parse the corresponding modification record of the data table through the SPI implementation class when the data in the data table is modified.
[0119] The data synchronization module 905 is used to load the modified content in the parsed data table into the database modification record table.
[0120] Optionally, the device further includes:
[0121] The second SPI implementation class acquisition module is used to generate a corresponding data table definition file and the SPI implementation class based on the table information of the data table when the file type of the input file is a data table.
[0122] Optionally, the file type confirmation module includes:
[0123] The file extension acquisition submodule is used to obtain the file extension of the input file;
[0124] The file type confirmation submodule is used to determine the file type of the input file based on the file extension.
[0125] Optionally, the first SPI implementation class acquisition module includes:
[0126] The table creation statement generation submodule is used to generate the table creation statement according to the field information and a preset table creation statement generation rule.
[0127] The first SPI implementation class generation module is used to generate the SPI implementation class according to the field information and the preset SPI implementation class generation rules.
[0128] The data table generation submodule is used to execute the table creation statement and generate the data table corresponding to the data table definition file.
[0129] Optionally, the second SPI implementation class acquisition module includes:
[0130] The table information acquisition submodule is used to read the data table and obtain the table information of the data table;
[0131] The field information acquisition submodule is used to determine the field content and field description of each field contained in the data table based on the table information.
[0132] The second SPI implementation class acquisition submodule is used to generate the data table definition file and the SPI implementation class based on the field content and the field description.
[0133] Optionally, the second implementation class generation submodule includes:
[0134] The data table definition file acquisition submodule is used to write the field content and the field description into a file according to preset writing rules to obtain the data table definition file;
[0135] The second SPI implementation class generation submodule is used to write the correspondence between the field content and the field description according to the preset writing rules to obtain the SPI implementation class.
[0136] Optionally, the device further includes:
[0137] The implementation class loading module is used to load the SPI implementation class into the database, including:
[0138] The code packaging submodule is used to put the SPI implementation class into the synchronization code package;
[0139] The code compilation submodule is used to compile the synchronization code package containing the SPI implementation class into the general code corresponding to the database;
[0140] The data synchronization module is used to load the modified content from the parsed data table into the database modification record table, including:
[0141] The data synchronization submodule is used to synchronize the modified content in the data table to the database modification record table through the SPI mechanism.
[0142] Based on the same inventive concept, another embodiment of this application provides a readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the record table generation method as described in any of the above embodiments of this application.
[0143] Based on the same inventive concept, another embodiment of this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the steps in the record table generation method described in any of the above embodiments of this application.
[0144] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0145] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0146] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, embodiments of this application can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of this application can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0147] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0148] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0149] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0150] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.
[0151] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0152] The above provides a detailed description of the record table generation method, apparatus, device, and storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for generating a record table, characterized in that, The method includes: Read the input file and determine its file type; When the input file is a data table definition file, the table creation statement is generated according to the field information in the data table definition file and a preset table creation statement generation rule. The table creation statement generation rule is a rule for generating the corresponding data table based on the field information of the data table contained in the data table definition file. The field information includes the field content of each field and the corresponding field description. Based on the field information, the SPI implementation class is generated according to the preset SPI implementation class generation rules; the SPI implementation class is used to record the correspondence between the field content and field description of each field in the data table; Execute the table creation statement to generate the data table corresponding to the data table definition file; Store the data table in the database; When the data in the data table is modified, the information change record corresponding to the data table is parsed through the SPI implementation class; The modified content obtained from the parsed data table is loaded into the database modification record table.
2. The method according to claim 1, characterized in that, Before storing the data table in the database, the method further includes: If the input file is a data table, a corresponding data table definition file and the SPI implementation class are generated based on the table information of the data table.
3. The method according to claim 1, characterized in that, Determining the file type of the input file includes: Obtain the file extension of the input file; The file type of the input file is determined based on the file extension.
4. The method according to claim 2, characterized in that, The step of generating the corresponding data table definition file and the SPI implementation class based on the table information of the data table includes: The data table is read to obtain the table information of the data table; Based on the table information, determine the field content and field description of each field contained in the data table; Based on the field content and the field description, the data table definition file and the SPI implementation class are generated.
5. The method according to claim 4, characterized in that, The step of generating the data table definition file and the SPI implementation class based on the field content and the field description includes: The field content and field description are written into a file according to preset writing rules to obtain the data table definition file; The correspondence between the field content and the field description is written according to the preset writing rules to obtain the SPI implementation class.
6. The method according to claim 1, characterized in that, After loading the SPI implementation class into the database, the method further includes: Place the SPI implementation class into the synchronization code package; Compile the synchronization code package containing the SPI implementation class into the general code corresponding to the database; The modified content obtained from the parsed data table is loaded into the database modification record table, including: The modifications in the data table are synchronized to the database modification record table through the SPI mechanism.
7. A record table generation device, characterized in that, The device includes: The file type confirmation module is used to read the input file and determine the file type of the input file; The first SPI implementation class generation module is used to generate a corresponding data table and SPI implementation class based on the field information in the data table definition file when the input file is a data table definition file. The SPI implementation class is used to record the correspondence between the field content and field description of each field in the data table. A data storage module is used to store the data table in a database; The data parsing module is used to parse the corresponding modification records in the data table through the SPI implementation class when the data in the data table is modified. The data synchronization module is used to load the modified content in the parsed data table into the database modification record table; The first SPI implementation class acquisition module includes: The table creation statement generation submodule is used to generate the table creation statement according to the field information and a preset table creation statement generation rule. The table creation statement generation rule is the rule for generating the corresponding data table based on the field information of the data table contained in the data table definition file. The field information includes the field content of each field and the corresponding field description. The first SPI implementation class generation module is used to generate the SPI implementation class according to the field information and the preset SPI implementation class generation rules. The data table generation submodule is used to execute the table creation statement and generate the data table corresponding to the data table definition file.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 6.
9. 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 method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Data storage method and device, electronic equipment and medium
CN114610808A
Business data change recording method and device, computer equipment and medium
CN115858471A
Method for generating API based on DSL analysis resources
CN117234529A