Data synchronization method and device, equipment, storage medium and program product
By obtaining the synchronization task name and obtaining the synchronization task configuration information and field mapping information, generating synchronization requests and creating temporary tables, the problem of data synchronization taking time and workload in the existing technology is solved, and an efficient data synchronization process is realized.
Patent Information
- Application Number
- CN202411790273.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-03-28
AI Technical Summary
In the prior art, the data synchronization process takes a long time and has a large workload, and there is a lack of efficient methods to quickly obtain synchronization task configuration information and data to be synchronized, which can easily lead to data synchronization failure and data loss.
By responding to the triggered synchronization task, obtain the synchronization task name and obtain the synchronization task configuration information and field mapping information based on this. Generate synchronization requests and create temporary tables, obtain data to be synchronized based on synchronization requests and write them to temporary tables to prevent data loss. Finally, the data in the temporary table is written into the target table to improve the data synchronization efficiency.
It realizes the rapid acquisition of synchronization task configuration information and data to be synchronized, preventing data loss caused by failure of data synchronization, thereby improving the efficiency of data synchronization.
Smart Images

Figure CN119719223A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the technical field of data synchronization, and in particular, to a data synchronization method, apparatus, device, storage medium, and program product. Background Art
[0002] The data asset management platform is used to manage data and make data assets visible, understandable, usable, evaluable, and operable. Therefore, in the construction of the platform, it is necessary to obtain data from other components or systems to form data assets. Therefore, synchronizing data from one system to another is an important process. In the existing technology, data synchronization has the disadvantages of being time-consuming and labor-intensive. Summary of the invention
[0003] The embodiments of the present invention provide a data synchronization method, apparatus, device, storage medium and program product, which can improve the efficiency of data synchronization.
[0004] In a first aspect, an embodiment of the present invention provides a data synchronization method, including:
[0005] In response to the triggered synchronization task, obtain the synchronization task name;
[0006] Acquire synchronization task configuration information and field mapping information based on the synchronization task name;
[0007] Generate a synchronization request and create a temporary table according to the synchronization task configuration information;
[0008] Acquire the data to be synchronized according to the synchronization request, and write the data to be synchronized into the temporary table according to the field mapping information;
[0009] The data in the temporary table is written into the target table according to the field mapping information.
[0010] In a second aspect, an embodiment of the present invention further provides a data synchronization device, the device comprising:
[0011] A synchronization task name acquisition module, used to obtain a synchronization task name in response to a triggered synchronization task;
[0012] An information acquisition module, used to acquire synchronization task configuration information and field mapping information based on the synchronization task name;
[0013] A synchronization request generation module, used to generate a synchronization request and create a temporary table according to the synchronization task configuration information;
[0014] A to-be-synchronized data acquisition module, used to acquire the to-be-synchronized data according to the synchronization request, and write the to-be-synchronized data into the temporary table according to the field mapping information;
[0015] A data writing module is used to write the data in the temporary table into the target table according to the field mapping information.
[0016] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a data synchronization method as described in any one of the embodiments of the present invention is implemented.
[0017] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a data synchronization method as described in any one of the embodiments of the present invention.
[0018] In a fifth aspect, an embodiment of the present invention further provides a computer program product, including a computer program, which, when executed by a processor, implements a data synchronization method as described in any one of the embodiments of the present invention.
[0019] The embodiment of the present invention discloses a data synchronization method, device, equipment, storage medium and program product, including: in response to a triggered synchronization task, obtaining a synchronization task name; obtaining synchronization task configuration information and field mapping information based on the synchronization task name; generating a synchronization request and creating a temporary table according to the synchronization task configuration information; obtaining the data to be synchronized according to the synchronization request, and writing the data to be synchronized into the temporary table according to the field mapping information; writing the data in the temporary table into the target table according to the field mapping information. The above technical scheme, first, can quickly obtain the synchronization task configuration information and field mapping information according to the acquired synchronization task name; secondly, generate a synchronization request and create a temporary table according to the synchronization task configuration information, and quickly obtain the data to be synchronized according to the synchronization request; then, write the data to be synchronized into the temporary table first according to the field mapping information, which can prevent data loss caused by data synchronization failure; finally, write the data in the temporary table into the target table according to the field mapping information, which can improve the efficiency of data synchronization. Compared with the prior art, the technical solution provided in this embodiment can quickly obtain synchronization task configuration information, field mapping information and data to be synchronized, and write the data to be synchronized into a temporary table first, which can prevent data loss caused by data synchronization failure, thereby improving the efficiency of data synchronization. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0021] Figure 1 A flowchart of a data synchronization method provided by an embodiment of the present invention;
[0022] Figure 2 A flowchart of a data synchronization method provided by an embodiment of the present invention;
[0023] Figure 3 A schematic diagram of the structure of a data synchronization device provided by an embodiment of the present invention;
[0024] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0025] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0026] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. At the same time, in the description of the present invention, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance. The acquisition, storage, use, processing, etc. of data in the technical solution of this application comply with the relevant provisions of national laws and regulations. It should be noted that in the embodiments of this application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. The purpose is only to illustrate the feasibility of the implementation of the technical solution of this application, but it does not mean that the applicant has or will necessarily use the solution.
[0027] In the prior art, to implement the data synchronization method of the interface, the first step is to communicate between the two systems about the synchronization method of the interface, whether to use the method of data pull or data push, and whether to synchronize the full amount or incrementally. The second step is to determine which data to synchronize. The third step is to provide a complete interface document, including the request address, request method, request data, and corresponding data. The fourth step is to develop the synchronization data interface, including parsing the data after the request interface obtains the data and finally storing it in the database. The fifth step is to test and debug the two interfaces. The above method has the following defects: 1. For the synchronization of each system and each data, a whole set of process communication and interface design are required, which is time-consuming. 2. For each type of data, a separate code needs to be developed for data synchronization. System A needs to synchronize 10 types of data, so 10 sets of interfaces need to be developed for data synchronization. Although some interface reuse methods can be adopted, the workload is still relatively large. 3. Once any party of the synchronization needs to increase the synchronization parameters, assuming that the original synchronization of one type of data has 9 data, and now it is increased to 10 or reduced to 8, then both parties need to modify the code to synchronize the data. 4. There may be changes in data items. When the database field name needs to be modified, the code also needs to be modified before data synchronization can be performed.
[0028] Figure 1 This is a flow chart of a data synchronization method provided by an embodiment of the present invention. This embodiment is applicable to the case of synchronizing data from one system to another system. The method can be executed by a data synchronization device, which can be implemented in the form of software and / or hardware. Optionally, it can be implemented by an electronic device, which can be a mobile terminal, a PC or a server. Specifically, it includes the following steps:
[0029] S110. In response to a triggered synchronization task, obtain a synchronization task name.
[0030] In this embodiment, the synchronization task can be understood as a task of synchronizing data in one system to another system, such as synchronizing data in system A to a data asset management platform. In this embodiment, the synchronization task can be actively triggered by the user or timed triggered. For active user triggering, for example, the user clicks the synchronization button; for timed triggering, for example, the triggering time is pre-set, and the trigger is triggered according to the set triggering time.
[0031] In this embodiment, the synchronization task name can be understood as a unique identifier of the synchronization task, which is used to distinguish different synchronization tasks. Specifically, in actual business scenarios, there are often multiple synchronization tasks. In order to distinguish different synchronization tasks, each synchronization task needs to be given a name. For example, the synchronization task name is test1.
[0032] S120. Acquire synchronization task configuration information and field mapping information based on the synchronization task name.
[0033] In this embodiment, the synchronization task configuration information can be understood as key configuration information related to the synchronization task, and the field mapping information can be understood as the mapping relationship between fields. Specifically, the synchronization task configuration information may include an interface address and an interface request parameter. In this embodiment, the data to be synchronized needs to be obtained through an interface, and the interface address can be understood as the address of the interface to be called to obtain the data to be synchronized. The interface request parameter can be understood as the data information passed to the interface when the data to be synchronized is obtained through the interface, which is used to inform the interface which specific data needs to be returned.
[0034] Furthermore, the field mapping information may include mapping relationships between multiple interface fields and database table fields and attribute information of each mapping relationship, wherein the attribute information is whether to retain updates or whether it is a default value. Among them, the interface field is the content of the data to be synchronized obtained through the interface, and the data to be synchronized contains multiple different interface fields, such as data1, data2, ..., datan, etc. Specifically, in the process of synchronizing data from one system to another target system, it is necessary to synchronize the data to the target table of the target system, wherein the target table is located in the database of the target system, and the database table field can be understood as a field in the target table, and the target table contains multiple different database table fields, such as Data1, Data2, ..., Datan, etc. The mapping relationship between the interface field and the database table field can be understood as one interface field corresponding to one database table field, for example, if a certain interface field is data1, its corresponding database table field is Data1.
[0035] Optionally, the synchronization task configuration information may also include: a database number and a synchronization data source, wherein the target system includes multiple databases, each database has a corresponding number, and the database number is used to determine which database of the target system the data is synchronized to. The synchronization data source is used to identify which system or component the synchronization data comes from.
[0036] In this embodiment, the synchronization task configuration information and field mapping information corresponding to different synchronization tasks may be different, so it is necessary to obtain the synchronization task configuration information and field mapping information according to the synchronization task name. Specifically, the synchronization task configuration information and field mapping information can be obtained from a setting database according to the synchronization task name, wherein the setting database pre-stores different synchronization task names and their corresponding synchronization task configuration information and field mapping information.
[0037] Continuing with the above description, in an actual data synchronization scenario, there may be a situation where the synchronization task configuration information and field mapping information corresponding to a certain synchronization task need to be updated. Furthermore, the present embodiment may also include: in response to an update operation on the synchronization task configuration information, adding or deleting interface request parameters. Among them, new interface request parameters may be added or existing interface request parameters may be deleted in the setting database. Similarly, the present embodiment may also include: in response to an update operation on the field mapping information, adding or deleting a mapping relationship between an interface field and a database table field. Among them, a new mapping relationship may be added or an existing mapping relationship may be deleted in the setting database.
[0038] In this embodiment, in response to an update operation on the synchronization task configuration information, interface request parameters are added or deleted, and in response to an update operation on the field mapping information, the mapping relationship between the interface fields and the database table fields is added or deleted, thereby ensuring the modifiability of the synchronization task configuration information and the field mapping information, and having a certain degree of flexibility when facing different data synchronization scenarios.
[0039] S130: Generate a synchronization request according to the synchronization task configuration information and create a temporary table.
[0040] In this embodiment, the synchronization request can be understood as an http request, which is similar to a link address and is used to obtain the data to be synchronized. The temporary table is used to temporarily store the data to be synchronized, which is equivalent to a transfer station for the data to be synchronized. The format of the temporary table is the same as that of the target table in the target system, that is, the fields included are the same. For example, if the fields included in the target table are Data1, Data2, ..., Datan, then the fields included in the temporary table are also Data1, Data2, ..., Datan.
[0041] In this embodiment, one implementation of generating a synchronization request according to the synchronization task configuration information can be described as: assembling the interface address and the interface request parameters according to a preset request template to obtain a synchronization request.
[0042] Continuing with the above description, the preset request template can be understood as a template for http request. For example, the template for http request is: http: / / [interface address][interface request parameter].com. Assuming that the interface address is a1 and the interface request parameter is p1, the synchronous request is http: / / [a1][p1].com.
[0043] In this embodiment, the interface address and the interface request parameters are assembled according to a preset request template to obtain a synchronization request, which can ensure the standardization and unification of the request format.
[0044] In this embodiment, one implementation of creating a temporary table can be described as: obtaining a database table field of a target table; and generating a temporary table based on the database table field.
[0045] Following the above description, multiple database table fields in the target table are obtained, such as Data1, Data2, ..., Datan, and the multiple database table fields are added to the temporary table.
[0046] In this embodiment, the database table fields of the target table are obtained, and a temporary table is generated based on the database table fields. The temporary table can be used to temporarily store the data to be synchronized to prevent data loss.
[0047] S140: Obtain the data to be synchronized according to the synchronization request, and write the data to be synchronized into a temporary table according to the field mapping information.
[0048] In this embodiment, the synchronization request carries an interface address and an interface request parameter.
[0049] In this embodiment, one implementation manner of acquiring the data to be synchronized according to the synchronization request can be described as: calling the target interface according to the interface address; and passing the interface request parameters to the target interface to acquire the data to be synchronized.
[0050] Continuing with the above description, different interface addresses correspond to different interfaces, so it is necessary to call the target interface according to the interface address, and then pass the interface request parameters to the target interface, and the target interface returns the data to be synchronized.
[0051] In this embodiment, the target interface is called according to the interface address, and the interface request parameters are passed to the target interface to obtain the data to be synchronized. The target interface can be accurately determined, and the data to be synchronized can be obtained in time.
[0052] In this embodiment, one implementation method of writing the to-be-synchronized data into the temporary table according to the field mapping information can be described as the following steps:
[0053] a1) parsing the data to be synchronized to extract the data value under each interface field in the data to be synchronized;
[0054] In this embodiment, the data to be synchronized includes data page number, number of paging entries, total number of entries, multiple different interface fields and their corresponding data values. After obtaining the data to be synchronized, it is necessary to parse the data to be synchronized and extract the data values under each interface field in the data to be synchronized. For example, the data value corresponding to the interface field data1 is s1, the data value corresponding to data2 is s2, ..., the data value corresponding to datan is sn, and so on.
[0055] b1) For each data value, write the data value into the database table field corresponding to the interface field in the temporary table according to the field mapping information.
[0056] Exemplarily, the database table fields in the temporary table are Data1, Data2, ..., Datan, and the mapping relationship between the interface field and the database table field in the field mapping information is: interface field data1 corresponds to database table field Data1, interface field data2 corresponds to database table field Data2, ..., interface field datan corresponds to database table field Datan. Therefore, for data value s1, data value s1 is written to database table field Data1 in the temporary table, for data value s2, data value s2 is written to database table field Data2 in the temporary table, and for other data values, they are written to the corresponding database table fields in the temporary table in a similar manner to the above method.
[0057] In this embodiment, the data to be synchronized is parsed to extract the data values under each interface field in the data to be synchronized. For each data value, the data value is written into the database table field corresponding to the interface field in the temporary table according to the field mapping information, which can prevent data loss caused by data synchronization failure.
[0058] In this embodiment, before writing the data to be synchronized into the temporary table according to the field mapping information, the following operation may be performed: structural processing is performed on the data to be synchronized to obtain the structured data to be synchronized.
[0059] Following the above description, after the data to be synchronized is obtained, the format of the data to be synchronized may not be the format specified by the target system, so the data to be synchronized needs to be processed according to the set format. The structured processing of the data to be synchronized can be understood as processing the data to be synchronized into the set format. Exemplarily, the structured processed data to be synchronized can be as follows:
[0060] {"CrnPgNo":"1", / / Current page number
[0061] "PgLineNum": "100", / / Number of paging lines
[0062] "RcrdLineNum": "10000", / / Total number of lines
[0063] "dataArray": / / list parameter name
[0064] {"data1":"s1" / / Interface field data1 and its corresponding data value s1
[0065] "data2": "s2" / / Interface field data2 and its corresponding data value s2
[0066] …
[0067] }
[0068] }
[0069] In this embodiment, the data to be synchronized is structured to obtain the structured data to be synchronized, which can ensure the standardization and unification of the format of the data to be synchronized.
[0070] S150. Write the data in the temporary table into the target table according to the field mapping information.
[0071] In this embodiment, one implementation method of writing the data in the temporary table into the target table according to the field mapping information can be described as the following steps:
[0072] a2) If the attribute information of the mapping relationship is to be retained and updated, the data value under the database table field in the temporary table is written into the corresponding position of the target table;
[0073] Exemplarily, the format of the temporary table is the same as that of the target table. The database table fields included in the target table are Data1, Data2, ..., Datan, and the database table fields included in the temporary table are also Data1, Data2, ..., Datan.
[0074] Furthermore, if the attribute information of the mapping relationship between each interface field and the database table field is retained and updated, the data values under the database table fields Data1, Data2, ..., Datan in the temporary table are written to the corresponding database table fields in the target table. For example, the data value s1 under the database table field Data1 in the temporary table is written to the database table field Data1 in the target table.
[0075] b2) If the attribute information of the mapping relationship is not to be retained and updated, the data value under the database table field in the target table is kept unchanged;
[0076] In this embodiment, if the attribute information of the mapping relationship between each interface field and the database table field is not retained and updated, the data values under the database table fields Data1, Data2, ..., Datan in the target table are kept unchanged, that is, the data in the temporary table is not written to the target table.
[0077] c2) If the attribute information of the mapping relationship is a default value, the default value is written into the database table field in the target table.
[0078] Exemplarily, if the attribute information of the mapping relationship between each interface field and the database table field is a default value, assuming the default value is m, the default value m is written into the database table fields Data1, Data2, ..., Datan in the target table.
[0079] Optionally, after writing the data in the temporary table into the target table according to the field mapping information, the following operation may be performed: deleting the temporary table. In this embodiment, after writing the data in the temporary table into the target table, the temporary table is no longer needed, so the temporary table may be deleted to release the storage space occupied by it.
[0080] The technical solution of this embodiment, in response to the triggered synchronization task, obtains the synchronization task name; obtains the synchronization task configuration information and field mapping information based on the synchronization task name; generates a synchronization request and creates a temporary table according to the synchronization task configuration information; obtains the data to be synchronized according to the synchronization request, and writes the data to be synchronized into the temporary table according to the field mapping information; writes the data in the temporary table into the target table according to the field mapping information. The above technical solution, first, can quickly obtain the synchronization task configuration information and field mapping information according to the acquired synchronization task name; secondly, generate a synchronization request and create a temporary table according to the synchronization task configuration information, and can quickly obtain the data to be synchronized according to the synchronization request; then, write the data to be synchronized into the temporary table first according to the field mapping information, which can prevent data loss caused by data synchronization failure; finally, write the data in the temporary table into the target table according to the field mapping information, which can improve the efficiency of data synchronization. The technical solution provided by this embodiment can quickly obtain the synchronization task configuration information, field mapping information and the data to be synchronized, and write the data to be synchronized into the temporary table first, which can prevent data loss caused by data synchronization failure, thereby improving the efficiency of data synchronization.
[0081] Figure 2 A flowchart of a data synchronization method provided by an embodiment of the present invention. Based on the above embodiment, the method includes the following steps:
[0082] S210: In response to a triggered synchronization task, obtain a synchronization task name.
[0083] S220. Acquire synchronization task configuration information and field mapping information based on the synchronization task name.
[0084] S230: Assemble the interface address and interface request parameters according to a preset request template to obtain a synchronization request.
[0085] S240: Obtain database table fields of the target table, and generate a temporary table based on the database table fields.
[0086] S250: Call the target interface according to the interface address.
[0087] S260: Transmit the interface request parameters to the target interface to obtain the data to be synchronized.
[0088] S270: Parse the data to be synchronized to extract data values under each interface field in the data to be synchronized.
[0089] S280. For each data value, write the data value into the database table field corresponding to the interface field in the temporary table according to the field mapping information.
[0090] S290. Write the data in the temporary table into the target table according to the field mapping information.
[0091] S2100. Delete the temporary table.
[0092] The above technical scheme can quickly obtain the synchronization task configuration information and field mapping information according to the acquired synchronization task name; assemble the interface address and interface request parameters according to the preset request template to obtain the synchronization request, which can ensure the standardization and unification of the request format; obtain the database table field of the target table, and generate a temporary table based on the database table field, which can be used to temporarily store data to prevent data loss; call the target interface according to the interface address, pass the interface request parameters to the target interface to obtain the data to be synchronized, and accurately determine the target interface and obtain the data to be synchronized in time; parse the data to be synchronized to extract the data values under each interface field in the data to be synchronized, and for each data value, write the data value into the database table field corresponding to the interface field in the temporary table according to the field mapping information, which can prevent data loss caused by data synchronization failure; write the data in the temporary table into the target table according to the field mapping information, which can improve the efficiency of data synchronization; delete the temporary table to release the storage space occupied by it.
[0093] Figure 3 A schematic diagram of the structure of a data synchronization device provided by an embodiment of the present invention is shown in FIG. Figure 3 As shown, the device comprises:
[0094] A synchronization task name acquisition module 310 is used to acquire a synchronization task name in response to a triggered synchronization task;
[0095] An information acquisition module 320 is used to acquire synchronization task configuration information and field mapping information based on the synchronization task name;
[0096] A synchronization request generation module 330, configured to generate a synchronization request and create a temporary table according to the synchronization task configuration information;
[0097] The to-be-synchronized data acquisition module 340 is used to acquire the to-be-synchronized data according to the synchronization request, and write the to-be-synchronized data into the temporary table according to the field mapping information;
[0098] The data writing module 350 is used to write the data in the temporary table into the target table according to the field mapping information.
[0099] Optionally, the synchronization task configuration information includes an interface address and interface request parameters, and the field mapping information includes a mapping relationship between multiple interface fields and database table fields and attribute information of each mapping relationship, wherein the attribute information is whether to retain updates or whether it is a default value.
[0100] Optionally, the synchronization request generating module 330 may be specifically used for:
[0101] The interface address and the interface request parameters are assembled according to a preset request template to obtain a synchronization request.
[0102] Optionally, it also includes: a temporary table creation module, which is used to create a temporary table, which can be used for:
[0103] Obtaining database table fields of the target table; and generating a temporary table based on the database table fields.
[0104] Optionally, the to-be-synchronized data acquisition module 340 may be specifically used for:
[0105] Calling the target interface according to the interface address;
[0106] The interface request parameters are passed into the target interface to obtain the data to be synchronized.
[0107] Optionally, it also includes: a temporary writing module, used to write the data to be synchronized into the temporary table according to the field mapping information, which can be specifically used to: parse the data to be synchronized to extract the data values under each interface field in the data to be synchronized; for each data value, write the data value into the database table field corresponding to the interface field in the temporary table according to the field mapping information.
[0108] Optionally, the data writing module 350 may be specifically used for:
[0109] If the attribute information of the mapping relationship is to be retained and updated, the data value under the database table field in the temporary table is written into the corresponding position of the target table;
[0110] If the attribute information of the mapping relationship is not to be retained and updated, the data value under the database table field in the target table is kept unchanged;
[0111] If the attribute information of the mapping relationship is a default value, the default value is written into the database table field in the target table.
[0112] Optionally, it also includes: a data processing module, used to: perform structured processing on the data to be synchronized to obtain structured processed data to be synchronized.
[0113] Optionally, it also includes: a synchronization task configuration information updating module, which is used to: add or delete the interface request parameter in response to an update operation on the synchronization task configuration information.
[0114] Optionally, it also includes: a field mapping information updating module, which is used to: in response to an update operation on the field mapping information, add or delete a mapping relationship between an interface field and a database table field.
[0115] Optionally, it also includes: a deletion module, used to: delete the temporary table.
[0116] The above device can execute the methods provided by all the above embodiments of the present invention, and has the corresponding functional modules and beneficial effects of executing the above methods. For technical details not described in detail in this embodiment, please refer to the methods provided by all the above embodiments of the present invention.
[0117] Figure 4 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0118] like Figure 4As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0119] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0120] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a data synchronization method.
[0121] In some embodiments, the data synchronization method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the data synchronization method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the data synchronization method in any other appropriate manner (e.g., by means of firmware).
[0122] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0123] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0124] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0125] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0126] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0127] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0128] An embodiment of the present invention further provides a computer program product, including a computer program, which, when executed by a processor, implements the data synchronization method provided in any embodiment of the present application.
[0129] In the process of implementation, the computer program product can be written in one or more programming languages or a combination thereof to perform the computer program code of the present invention, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0130] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A data synchronization method, characterized in that: include: In response to the triggered synchronization task, obtain the synchronization task name; Acquire synchronization task configuration information and field mapping information based on the synchronization task name; Generate a synchronization request and create a temporary table according to the synchronization task configuration information; Acquire the data to be synchronized according to the synchronization request, and write the data to be synchronized into the temporary table according to the field mapping information; The data in the temporary table is written into the target table according to the field mapping information.
2. The method according to claim 1, characterized in that The synchronization task configuration information includes an interface address and interface request parameters, and the field mapping information includes mapping relationships between multiple interface fields and database table fields and attribute information of each mapping relationship, wherein the attribute information is whether to retain updates or whether it is a default value.
3. The method according to claim 2, characterized in that Generating a synchronization request according to the synchronization task configuration information includes: The interface address and the interface request parameters are assembled according to a preset request template to obtain a synchronization request.
4. The method according to claim 2, characterized in that: Create a temporary table, including: Obtaining the database table fields of the target table; A temporary table is generated based on the database table fields.
5. The method according to claim 2, characterized in that: Acquiring the data to be synchronized according to the synchronization request includes: Calling the target interface according to the interface address; The interface request parameters are passed into the target interface to obtain the data to be synchronized.
6. The method according to claim 5, characterized in that Writing the to-be-synchronized data into the temporary table according to the field mapping information includes: Parsing the data to be synchronized to extract data values under each interface field in the data to be synchronized; For each data value, the data value is written into the database table field corresponding to the interface field in the temporary table according to the field mapping information.
7. The method according to claim 2, characterized in that Writing the data in the temporary table into the target table according to the field mapping information includes: If the attribute information of the mapping relationship is to be retained and updated, the data value under the database table field in the temporary table is written into the corresponding position of the target table; If the attribute information of the mapping relationship is not to be retained and updated, the data value under the database table field in the target table is kept unchanged; If the attribute information of the mapping relationship is a default value, the default value is written into the database table field in the target table.
8. The method according to claim 2, characterized in that: Before writing the to-be-synchronized data into the temporary table according to the field mapping information, the method further includes: The data to be synchronized is structured to obtain structured data to be synchronized.
9. The method according to claim 2, characterized in that: Also includes: In response to an update operation on the synchronization task configuration information, the interface request parameter is added or deleted.
10. The method according to claim 2, characterized in that Also includes: In response to an update operation on the field mapping information, a mapping relationship between an interface field and a database table field is added or deleted.
11. The method according to claim 1, characterized in that After writing the data in the temporary table into the target table according to the field mapping information, the method further includes: Delete the temporary table.
12. A data synchronization device, characterized in that: include: A synchronization task name acquisition module, used to obtain a synchronization task name in response to a triggered synchronization task; An information acquisition module, used to acquire synchronization task configuration information and field mapping information based on the synchronization task name; A synchronization request generation module, used to generate a synchronization request and create a temporary table according to the synchronization task configuration information; A to-be-synchronized data acquisition module, used to acquire the to-be-synchronized data according to the synchronization request, and write the to-be-synchronized data into the temporary table according to the field mapping information; A data writing module is used to write the data in the temporary table into the target table according to the field mapping information.
13. An electronic device, characterized in that: It comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the data synchronization method as described in any one of claims 1 to 11 when executing the computer program.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the data synchronization method as described in any one of claims 1-11 is implemented.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the data synchronization method according to any one of claims 1 to 11.