Data synchronization method and device and medium
By automatically parsing and loading configuration files using pre-built JSON configuration standard templates, the problem of low data synchronization efficiency in the existing technology is solved, flexible configuration and dynamic adjustment are achieved, and data synchronization efficiency is improved.
Patent Information
- Application Number
- CN202410633014.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-21
- Publication Date
- 2024-08-27
AI Technical Summary
Existing data synchronization configuration methods require writing complex SQL scripts or hard-coded configurations, resulting in low data synchronization efficiency and difficulty in dynamic adjustment and expansion.
It uses pre-built configuration standard templates to define data sources, data targets and field mapping relationships in JSON format, automatically parses and loads configuration files, and achieves data synchronization without the need for users to write complex SQL statements or tedious coding, and supports dynamic adjustment and expansion.
It improves data synchronization efficiency, realizes flexible configuration and dynamic adjustment, and meets diverse business needs and data processing scenarios.
Smart Images

Figure CN118550764A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data synchronization method, device and medium. Background Art
[0002] As demand changes and business develops, processing large amounts of data or complex synchronization logic is a common operation, and data synchronization has become an important part of enterprise informatization construction.
[0003] However, current data synchronization configuration methods usually involve writing a large number of SQL scripts or hard-coded configurations, which are often complex and difficult to maintain. Whenever the business logic or data source changes, a large number of SQL statements need to be modified and tested, which is time-consuming and labor-intensive, and it is difficult to achieve dynamic adjustment and expansion of configuration, resulting in low data synchronization efficiency. Summary of the invention
[0004] The embodiments of the present application provide a data synchronization method, device and medium for solving the problem of low data synchronization efficiency.
[0005] The present application embodiment adopts the following technical solutions:
[0006] On the one hand, an embodiment of the present application provides a data synchronization method, which includes: receiving a data synchronization request from a client, and sending a pre-built configuration standard template to the client; receiving a configuration file uploaded by the client, parsing the configuration file, and obtaining an identifiable configuration object; the configuration file includes a data source, a data target, and a field mapping relationship for describing data synchronization; according to the field mapping relationship in the identifiable configuration object, a field mapping relationship between source data and target data is established; according to the field mapping relationship, synchronization source data is extracted from the data source, and the synchronization source data is loaded into the data target.
[0007] In one example, before receiving a data synchronization request from a client and sending a pre-built configuration standard template to the client, the method also includes: determining a top-level object in JSON data format; the first object of the top-level object is used to represent a unique identification code of a data target party, the second object of the top-level object is used to represent a custom extended synchronization parameter, the third object of the top-level object is used to represent the name of the data target party, and the fourth object of the top-level object is a data array, which is used to define data source table information and field mapping rules between source fields and target fields; and constructing the configuration standard template in JSON data format based on the top-level object.
[0008] In one example, the method also includes: the data array includes a fifth object, the first field of the fifth object is used to indicate the type of data source information, the second field of the fifth object is a JSON object, including multiple data source table sub-objects, each data source table sub-object is used to define a data target table name string array under each data source table, and the third field of the fifth object is a JSON object, including multiple data target table sub-objects, each data target table sub-object is used to define a field mapping relationship between a source field and a target field.
[0009] In one example, the configuration file is parsed to obtain a recognizable configuration object, specifically including: when the configuration file is in JSON format, determining whether the configuration file complies with the JSON format specification; if so, converting the configuration file into a data structure that can be processed by the program; determining whether the configuration file includes all required fields of a configuration standard template; if so, determining the data structure as a recognizable configuration object.
[0010] In one example, the method further includes: if the configuration file does not conform to the JSON format specification, generating format error prompt information of the configuration file, and feeding back the format error prompt information to the client to obtain an updated configuration file that conforms to the JSON format specification.
[0011] In one example, after the synchronization source data is loaded into the data target party, the method further includes: verifying whether the loaded data of the data target party is complete and correct based on the field mapping relationship and the synchronization source data; if the verification passes, determining that the configuration file loading is complete; if the verification fails, generating a loading failure prompt message, and feeding back the loading failure prompt message to the client.
[0012] In one example, if the verification passes and it is determined that the configuration file has been loaded, the method further includes: backing up the configuration file and the synchronization source data to generate backup data for data synchronization; in the backup database, retrieving the backup data queue of the data source, and outputting the backup data to the backup data queue.
[0013] In one example, the method also includes: generating log information for error prompt information during data synchronization, and outputting the log information to a log queue; generating a time distribution graph for the log queue within a preset time interval; the coordinate axes of the time distribution graph are time and specific error data, respectively.
[0014] On the other hand, an embodiment of the present application provides a data synchronization device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a data synchronization method described in any one of the above items.
[0015] On the other hand, an embodiment of the present application provides a data synchronization non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions can execute any of the data synchronization methods described above.
[0016] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:
[0017] It is possible to define key information such as data source, data target, field mapping and other custom parameters through the constructed configuration standard template, provide JSON configuration specifications, and automatically parse and load the generated configuration files, and automatically synchronize the source data to the target data without the user having to write complex SQL statements or perform tedious coding work, thereby improving data synchronization efficiency and achieving flexible configuration and dynamic adjustment of data synchronization to meet diverse business needs and data processing scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solution of the present application, some embodiments of the present application will be described in detail below in conjunction with the accompanying drawings, in which:
[0019] Figure 1 A flowchart of a data synchronization method provided in an embodiment of the present application;
[0020] Figure 2 A schematic diagram of a configuration standard template provided in an embodiment of the present application;
[0021] Figure 3 A schematic diagram of the structure of a data synchronization device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0023] Some embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0024] Figure 1 A flow chart of a data synchronization method provided in an embodiment of the present application. The method can be applied to different business fields, such as Internet financial business field, e-commerce business field, instant messaging business field, game business field, official business field, etc. Certain input parameters or intermediate results in the process allow manual intervention and adjustment to help improve accuracy.
[0025] The analysis method involved in the embodiments of the present application can be implemented by a terminal device or a server, and the present application does not impose any special restrictions on this. For the convenience of understanding and description, the following embodiments are described in detail by taking a server as an example.
[0026] It should be noted that the server may be a single device or a system consisting of multiple devices, that is, a distributed server, and this application does not make any specific limitation on this.
[0027] Figure 1 The process in includes the following steps:
[0028] S101: receiving a data synchronization request from a client, and sending a pre-built configuration standard template to the client.
[0029] In some embodiments of the present application, the process of constructing the configuration standard template is as follows:
[0030] Design a set of JSON configuration specifications to describe the parameters and properties of data synchronization.
[0031] Specifically, a top-level object in JSON data format is determined, wherein the first object of the top-level object is used to represent the unique identification code of the data target party, the second object of the top-level object is used to represent the custom extended synchronization parameter, the third object of the top-level object is used to represent the name of the data target party, and the fourth object of the top-level object is a data array, which is used to define the data source table information and the field mapping rules between the source field and the target field.
[0032] The data array includes a fifth object, the first field of the fifth object is used to indicate the type of data source information, the second field of the fifth object is a JSON object, including multiple data source table sub-objects, each of which is used to define a data target table name string array under each data source table, and the third field of the fifth object is a JSON object, including multiple data target table sub-objects, each of which is used to define a field mapping relationship between a source field and a target field. Each data target table name string array is used to define multiple data target table names.
[0033] More intuitively, Figure 2A schematic diagram of a configuration standard template provided in an embodiment of the present application.
[0034] The top-level object includes four objects. code is used to indicate the unique identification code of the data target. su is used to indicate a custom extended synchronization parameter, which indicates an application-specific custom object. name is used to indicate the name of the data target. data is a JSON array. The data has an object, which includes three fields. dtype is used to indicate the type of data source information. tableConfig is a JSON object, including multiple data source table sub-objects (for example, data source table name 1, data source table name 2). This sub-object is a JSON array, which is used to define the data target table name string array. config is an object, including multiple data target table sub-objects (for example, data target table name 1, data target table name 2). This sub-object defines the specific field mapping between the data source field and the data target field. For example, the mapping between data source field 1 and data target field 2 under data target table name 1, and the mapping between data source field 2 and data target field 2. For another example, the mapping between data source field 1 and data target field 2 under data target table name 2, and the mapping between data source field 2 and data target field 2.
[0035] It should be noted that the configuration standard template provides support for custom fields, allowing users to add custom parameters in the JSON configuration according to actual needs to meet the needs of specific business scenarios. For example, in Figure 2 The custom parameter in the configuration specification is su. In addition, an expansion port is reserved to support third-party developers to expand the functional scope of the data synchronization system.
[0036] In summary, on the client, you can assign values to various objects and fields in the configuration standard template to generate a configuration file.
[0037] S102: receiving a configuration file uploaded by the client, parsing the configuration file to obtain an identifiable configuration object; the configuration file includes a data source, a data target, and a field mapping relationship for describing data synchronization.
[0038] It should be noted that the configuration file is output to a configuration file database, and then the configuration file is read from the database.
[0039] In some embodiments of the present application, the JSON configuration file provided by the user is read in real time, and the configuration file is parsed into a configuration object that can be recognized by the system. Through the configuration loading mechanism, the parsed configuration object is loaded into the data synchronization system to realize the dynamic effectiveness of the configuration.
[0040] Specifically, it is determined whether the configuration file complies with the JSON format specification, that is, the format specification of the configuration standard template, wherein a JSON parser is used to check whether it complies with the JSON format specification.
[0041] If it meets the requirements, the configuration file is converted into a data structure that the program can process. A JSON parser is used to convert the JSON configuration file into a data structure that the program can process. In this process, an internal representation containing all fields and values is generated.
[0042] Determine whether the configuration file includes all required fields of the configuration standard template.
[0043] If included, the data structure is identified as a recognizable configuration object.
[0044] If not included, an error prompt message indicating that a required field is missing is generated and fed back to the client, and this process ends without executing S103 - S104.
[0045] It should be noted that if the configuration file does not conform to the JSON format specification, a format error prompt message of the configuration file is generated and the format error prompt message is fed back to the client to obtain an updated configuration file that conforms to the JSON format specification.
[0046] That is, after the update configuration file is obtained, step S102 is executed again until the verification is passed and the update configuration file conforming to the JSON format specification is obtained.
[0047] S103: Establishing a field mapping relationship between source data and target data according to the field mapping relationship in the identifiable configuration object.
[0048] That is, according to the field mapping relationship in the JSON object, that is, Figure 2 The mapping in the config field in the config field establishes the mapping relationship between the source data and the target data.
[0049] S104: extracting synchronization source data from the data source according to the field mapping relationship, and loading the synchronization source data into the data target.
[0050] In some embodiments of the present application, whether the loaded data of the data target party is complete and correct is verified based on the field mapping relationship and the synchronization source data.
[0051] If the verification is successful, the configuration file is loaded successfully. If the verification fails, a loading failure prompt message is generated and fed back to the client.
[0052] In some embodiments of the present application, in order to prevent configuration loss due to unexpected circumstances, the system regularly backs up the JSON configuration file and synchronization data, so that when necessary, the user can quickly restore the configuration and status of data synchronization by restoring the backup.
[0053] Based on this, the configuration file and the synchronization source data are backed up to generate the backup data for data synchronization. In the backup database, the backup data queue of the data source is retrieved and the backup data is output to the backup data queue. In other words, each data source has its own backup data queue.
[0054] In some embodiments of the present application, during the data synchronization process, the system records and processes the errors and abnormalities that occur, and generates corresponding log information. The user can locate the problem by viewing the log information and perform corresponding processing.
[0055] Based on this, log information is generated for error prompt information during the data synchronization process, and the log information is output to the log queue.
[0056] Generate a time distribution graph for the log queue within a preset time interval. The coordinate axes of the time distribution graph are time and specific error data.
[0057] To summarize, first, define a set of standard JSON configuration specifications to describe the source, target, field mapping, and other custom parameters of data synchronization.
[0058] Secondly, a dynamic parsing and loading mechanism is introduced, which can parse the JSON configuration file provided by the user in real time and load it into the data synchronization system. It also supports custom fields, allowing users to add new configuration fields according to actual needs.
[0059] Finally, error handling mechanisms such as error logging and exception handling are used to ensure data security during configuration parsing and execution. At the same time, configuration version control and logging functions are provided to facilitate user management and historical configuration tracing.
[0060] That is, by defining a set of standard JSON configuration specifications and using dynamic parsing and loading mechanisms, flexible configuration and dynamic adjustment of data synchronization can be achieved to meet diverse business needs and data processing scenarios. At the same time, this method also supports dynamic expansion and customization, allowing the data synchronization system to be continuously upgraded and improved as business needs change.
[0061] It should be noted that although the embodiments of the present application are based on Figure 1 Steps S101 to S104 are described in sequence, but this does not mean that steps S101 to S104 must be performed in a strict order. Figure 1 The order shown in the figure is to introduce and explain step S101 to step S104 in sequence, in order to facilitate those skilled in the art to understand the technical solution of the embodiment of the present application. In other words, in the embodiment of the present application, the order between step S101 to step S104 can be appropriately adjusted according to actual needs.
[0062] pass Figure 1 The method can define key information such as data source, data target, field mapping and other custom parameters through the constructed configuration standard template, provide JSON configuration specifications, and automatically parse and load the generated configuration files, and automatically synchronize the source data to the target data without the need for users to write complex SQL statements or perform tedious coding work, thereby improving data synchronization efficiency and achieving flexible configuration and dynamic adjustment of data synchronization to meet diverse business needs and data processing scenarios.
[0063] Based on the same idea, some embodiments of the present application also provide devices and non-volatile computer storage media corresponding to the above methods.
[0064] Figure 3 A schematic diagram of a data synchronization device provided in an embodiment of the present application, the device includes:
[0065] at least one processor; and,
[0066] a memory communicatively connected to the at least one processor; wherein,
[0067] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any one of the data synchronization methods described above.
[0068] Some embodiments of the present application provide a data synchronization non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions can execute any of the data synchronization methods described above.
[0069] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0070] The devices and media provided in the embodiments of the present application correspond one-to-one to the methods. Therefore, the devices and media also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.
[0071] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product 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.
[0072] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0073] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0074] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0075] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0076] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0077] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0078] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0079] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the technical principle of the present application should all fall within the protection scope of the present application.
Claims
1. A data synchronization method, characterized in that: The method comprises: Receiving a data synchronization request from a client, and sending a pre-built configuration standard template to the client; Receiving a configuration file uploaded by the client, parsing the configuration file to obtain an identifiable configuration object; the configuration file includes a data source, a data target, and a field mapping relationship for describing data synchronization; Establishing a field mapping relationship between source data and target data according to the field mapping relationship in the identifiable configuration object; According to the field mapping relationship, the synchronization source data is extracted from the data source, and the synchronization source data is loaded into the data target.
2. The method according to claim 1, characterized in that Before receiving the data synchronization request from the client and sending the pre-built configuration standard template to the client, the method further includes: Determine a top-level object in JSON data format; the first object of the top-level object is used to represent the unique identification code of the data target party, the second object of the top-level object is used to represent the custom extended synchronization parameter, the third object of the top-level object is used to represent the name of the data target party, and the fourth object of the top-level object is a data array, and the data array is used to define the data source table information and the field mapping rules between the source field and the target field; According to the top-level object, a configuration standard template in the JSON data format is constructed.
3. The method according to claim 2, characterized in that The method further comprises: The data array includes a fifth object, the first field of the fifth object is used to indicate the type of data source information, the second field of the fifth object is a JSON object, including multiple data source table sub-objects, each data source table sub-object is used to define a data target table name string array under each data source table, and the third field of the fifth object is a JSON object, including multiple data target table sub-objects, each data target table sub-object is used to define a field mapping relationship between a source field and a target field.
4. The method according to claim 1, characterized in that: The parsing of the configuration file to obtain an identifiable configuration object specifically includes: When the configuration file is in JSON format, determining whether the configuration file complies with JSON format specifications; If it is in compliance, converting the configuration file into a data structure that can be processed by the program; Determining whether the configuration file includes all the required fields of the configuration standard template; If included, the data structure is determined to be a recognizable configuration object.
5. The method according to claim 4, characterized in that The method further comprises: If the configuration file does not conform to the JSON format specification, format error prompt information of the configuration file is generated, and the format error prompt information is fed back to the client to obtain an updated configuration file that conforms to the JSON format specification.
6. The method according to claim 1, characterized in that After loading the synchronization source data into the data target, the method further includes: Verify whether the loaded data of the data target party is complete and correct according to the field mapping relationship and the synchronization source data; If the verification is successful, it is determined that the configuration file has been loaded; If the verification fails, a loading failure prompt message is generated and the loading failure prompt message is fed back to the client.
7. The method according to claim 6, characterized in that If the verification is successful and it is determined that the configuration file has been loaded, the method further includes: Backing up the configuration file and the synchronization source data to generate data synchronization backup data; In the backup database, the backup data queue of the data source is retrieved, and the backup data is output to the backup data queue.
8. The method according to claim 1, characterized in that The method further comprises: Generate log information for error prompt information during data synchronization, and output the log information to a log queue; In a preset time interval, a time distribution graph is generated for the log queue; the coordinate axes of the time distribution graph are time and specific error data respectively.
9. A data synchronization device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a data synchronization method as described in any one of claims 1 to 8.
10. A data synchronization non-volatile computer storage medium storing computer executable instructions, characterized in that: The computer executable instructions can execute a data synchronization method as described in any one of claims 1-8 above.
Citation Information
Cited By
Integration and data synchronization method
CN119848132A
Universal hydrological multi-element data mapping method and system and medium
CN121301614A
Process formula synchronization method and device, formula distribution management equipment and storage medium
CN121637577A
Process recipe synchronization method and apparatus, recipe dispensing management device, and storage medium
CN121637577B
