Synchronization method and apparatus for data customization, electronic device, and storage medium
By automating and customizing the synchronization of user account information between the cloud and on-premises databases in MongoDB, the problems of errors and long processing times caused by manual synchronization are solved, improving the accuracy and efficiency of data synchronization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHERY AUTOMOBILE CO LTD
- Filing Date
- 2023-06-26
- Publication Date
- 2026-07-10
AI Technical Summary
In existing technologies, when MongoDB data is manually synchronized by operations and maintenance personnel, problems such as human error, incorrect data synchronization, and long synchronization time are prone to occur, which affect the normal login of new users' accounts in cloud projects.
A data-customized synchronization method is provided. By retrieving the current account information in the first database and comparing it with the account information in the previous database, inconsistent target account information is obtained and automatically synchronized to the corresponding business table in the second database, including the account's role, menu, and permission information.
It improves the efficiency of operation and maintenance and the accuracy of data synchronization, overcomes the limitations of single-point deployment, and realizes automated and customized synchronization of user account information on the cloud and on-premises.
Smart Images

Figure CN116737835B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a data-customized synchronization method, apparatus, electronic device, and storage medium. Background Technology
[0002] MongoDB is a distributed file-based database written in C++, designed to provide scalable, high-performance data storage solutions for web applications. Therefore, both on-premises and cloud-based projects use MongoDB as their primary data storage for user account-related business data.
[0003] In related technologies, while MongoDB was initially used as the data storage in the software architecture, most of the data was manually synchronized by operations and maintenance personnel. However, the development of a user management module service was not considered to solve the problems of daily addition, deletion, modification and query of user accounts, as well as the decoupling of cloud and on-premises business data and the dependence of cloud projects on user account data stored in MongoDB.
[0004] However, manually synchronizing data by operations and maintenance personnel is prone to problems such as human error, incorrect data synchronization, and long synchronization time, which affect work efficiency and the normal login of new users' accounts on cloud projects. These issues urgently need to be addressed. Summary of the Invention
[0005] This application provides a data-customized synchronization method, apparatus, electronic device, and storage medium to address the limitations of single-point deployment in related technologies, and the problems that easily occur when synchronizing data manually, such as human error, incorrect data synchronization, and long synchronization time.
[0006] The first aspect of this application provides a data-customized synchronization method, including the following steps:
[0007] Retrieve at least one account information of a user in the first database at the current moment;
[0008] If any account information at the current moment is inconsistent with the account information at the previous moment, then at least one target account information that is inconsistent with the account information at the previous moment is obtained from at least one account information at the current moment; and
[0009] The information of at least one target account is synchronized to the corresponding business table in the second database.
[0010] According to one embodiment of this application, the account information includes at least one of the account's corresponding role, account menu, and account item permissions.
[0011] According to one embodiment of this application, before determining that any account information at the current moment is inconsistent with the account information at the previous moment, the method further includes:
[0012] The system retrieves at least one account information of a user in the first database at the current moment using a preset script in the second database, and generates retrieval results for at least one account information of a user in the first database at the current moment.
[0013] The search results are compared with the user's account information in the first database at the previous moment, and the comparison results are used to determine whether any account information at the current moment is consistent with the account information at the previous moment.
[0014] If the comparison results are inconsistent, it is determined that at least one account information at the current moment is inconsistent with the account information at the previous moment, and at least one target account information at the current moment is generated.
[0015] According to one embodiment of this application, determining whether any account information at the current time is consistent with the account information at the previous time based on the comparison result includes:
[0016] If the comparison results are consistent, it is determined that at least one account information at the current time is consistent with the account information at the previous time, and at least one account information at the current time that is consistent with the account information at the previous time is not synchronized to the business table corresponding to the second database.
[0017] According to one embodiment of this application, synchronizing the at least one target account information to the business table corresponding to the second database includes:
[0018] Based on at least one target account information at the current time, at least one target account information at the current time is retrieved from the first database through a preset script in the second database, and a connection between the first database and the target account information of the client is established.
[0019] Read the target account information, establish a connection between the second database and the target account information of the client, synchronize the at least one target account information to the business table corresponding to the second database, and generate the synchronization result of the at least one target account information.
[0020] According to one embodiment of this application, after synchronizing the at least one target account information to the business table corresponding to the second database and generating the synchronization result of the at least one target account information, the method further includes:
[0021] Verify at least one target account information in the first database with at least one target account information in the second database, and after the verification is passed, calculate the synchronization result of the at least one target account information.
[0022] According to one embodiment of this application, after statistically analyzing the synchronization results of the at least one target account information, the method further includes:
[0023] Based on the statistical synchronization results, it is determined whether the information of the at least one target account has been successfully synchronized.
[0024] After the at least one target account information is successfully synchronized, the synchronization result is reported back to the preset management platform; otherwise, a synchronization failure reminder is sent to the preset management platform, and the at least one target account information is resynchronized to the business table corresponding to the second database.
[0025] According to the data customization synchronization method of this application embodiment, at least one account information of a user at the current time is retrieved from the first database. If any account information at the current time is inconsistent with the account information at the previous time, at least one target account information that is inconsistent with the account information at the previous time is obtained from the at least one account information at the current time, and the at least one target account information is synchronized to the corresponding business table in the second database. This solves the limitations of single-point deployment in related technologies, and addresses the problems of human error, incorrect data synchronization, and long synchronization time when synchronizing data manually. By automating and customizing the synchronization of user account information on the cloud and on-premises, and feeding back the synchronization results to the relevant management platform after synchronization is completed, the efficiency of operation and maintenance and the accuracy of data synchronization are improved.
[0026] A second aspect of this application provides a data-customized synchronization device, comprising:
[0027] The retrieval module is used to retrieve at least one account information of a user in the first database at the current moment;
[0028] The acquisition module is configured to, if any account information at the current moment is inconsistent with the account information at the previous moment, acquire at least one target account information from the at least one account information at the current moment that is inconsistent with the account information at the previous moment; and
[0029] The synchronization module is used to synchronize the at least one target account information to the corresponding business table in the second database.
[0030] According to one embodiment of this application, the account information includes at least one of the account's corresponding role, account menu, and account item permissions.
[0031] According to one embodiment of this application, before determining that any account information at the current moment is inconsistent with the account information at the previous moment, the acquisition module is further configured to:
[0032] The system retrieves at least one account information of a user in the first database at the current moment using a preset script in the second database, and generates retrieval results for at least one account information of a user in the first database at the current moment.
[0033] The search results are compared with the user's account information in the first database at the previous moment, and the comparison results are used to determine whether any account information at the current moment is consistent with the account information at the previous moment.
[0034] If the comparison results are inconsistent, it is determined that at least one account information at the current moment is inconsistent with the account information at the previous moment, and at least one target account information at the current moment is generated.
[0035] According to one embodiment of this application, the acquisition module is specifically used for:
[0036] If the comparison results are consistent, it is determined that at least one account information at the current time is consistent with the account information at the previous time, and at least one account information at the current time that is consistent with the account information at the previous time is not synchronized to the business table corresponding to the second database.
[0037] According to one embodiment of this application, the synchronization module is specifically used for:
[0038] Based on at least one target account information at the current time, at least one target account information at the current time is retrieved from the first database through a preset script in the second database, and a connection between the first database and the target account information of the client is established.
[0039] Read the target account information, establish a connection between the second database and the target account information of the client, synchronize the at least one target account information to the business table corresponding to the second database, and generate the synchronization result of the at least one target account information.
[0040] According to one embodiment of this application, after synchronizing the at least one target account information to the business table corresponding to the second database and generating a synchronization result for the at least one target account information, the synchronization module is further configured to:
[0041] Verify at least one target account information in the first database with at least one target account information in the second database, and after the verification is passed, calculate the synchronization result of the at least one target account information.
[0042] According to one embodiment of this application, after statistically analyzing the synchronization results of the at least one target account information, the synchronization module is further configured to:
[0043] Based on the statistical synchronization results, it is determined whether the information of the at least one target account has been successfully synchronized.
[0044] After the at least one target account information is successfully synchronized, the synchronization result is reported back to the preset management platform; otherwise, a synchronization failure reminder is sent to the preset management platform, and the at least one target account information is resynchronized to the business table corresponding to the second database.
[0045] According to the data customization synchronization device of this application embodiment, at least one account information of a user at the current moment is retrieved from the first database. If any account information at the current moment is inconsistent with the account information at the previous moment, at least one target account information that is inconsistent with the account information at the previous moment is obtained from the at least one account information at the current moment, and the at least one target account information is synchronized to the corresponding business table in the second database. This solves the limitations of single-point deployment in related technologies, and addresses the problems of human error, incorrect data synchronization, and long synchronization time when synchronizing data manually. By automating and customizing the synchronization of user account information on the cloud and on-premises, and feeding back the synchronization results to the relevant management platform after synchronization is completed, the efficiency of operation and maintenance and the accuracy of data synchronization are improved.
[0046] A third 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, wherein the processor executes the program to implement a data-customized synchronization method as described in the above embodiments.
[0047] A fourth aspect of this application provides a computer-readable storage medium storing computer instructions for causing the computer to perform a data-customized synchronization method as described in the above embodiments.
[0048] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0049] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0050] Figure 1 This is a flowchart illustrating a data customization synchronization method provided according to an embodiment of this application;
[0051] Figure 2 This is a schematic diagram illustrating cloud-on-premises data synchronization according to an embodiment of this application;
[0052] Figure 3 A block diagram illustrating a data-customized synchronization device according to embodiments of this application;
[0053] Figure 4 This is a schematic diagram of the structure of an electronic device provided according to an embodiment of this application. Detailed Implementation
[0054] The embodiments of this application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0055] The following description, with reference to the accompanying drawings, outlines a data-customized synchronization method, apparatus, electronic device, and storage medium according to embodiments of this application. Addressing the limitations of single-point deployment in related technologies mentioned in the background section, and the problems of human error, incorrect data synchronization, and lengthy synchronization times when synchronizing data manually, this application provides a data-customized synchronization method. In this method, at least one account information of a user at the current moment is retrieved from a first database. If any account information at the current moment is inconsistent with account information at the previous moment, at least one target account information that is inconsistent with the account information at the previous moment is obtained from the at least one account information at the current moment, and the at least one target account information is synchronized to the corresponding business table in a second database. This solves the limitations of single-point deployment in related technologies and the problems of human error, incorrect data synchronization, and lengthy synchronization times when synchronizing data manually. By automating and customizing the synchronization of user account information on both the cloud and on-premises platforms, and providing feedback on the synchronization results to the relevant management platform after synchronization, the efficiency of operation and maintenance and the accuracy of data synchronization are improved.
[0056] Specifically, Figure 1 This is a flowchart illustrating a data customization synchronization method provided in an embodiment of this application.
[0057] like Figure 1 As shown, this customized data synchronization method includes the following steps:
[0058] In step S101, at least one account information of the user at the current moment is retrieved from the first database.
[0059] Specifically, in this embodiment of the application, in order to improve the personalized, automated, accurate and fast data synchronization of user account data on the cloud network, this embodiment of the application first uses the pymongo module in Python to periodically retrieve at least one account information of the user at the current moment in the first database, that is, to retrieve at least one account information of the user at the current moment in the on-premises MongoDB database, such as the corresponding role, account menu and account item permissions of the user's account at the current moment.
[0060] In step S102, if any account information at the current moment is inconsistent with the account information at the previous moment, then at least one target account information that is inconsistent with the account information at the previous moment is obtained from at least one account information at the current moment.
[0061] According to one embodiment of this application, before determining that any account information at the current moment is inconsistent with the account information at the previous moment, the method further includes: retrieving at least one account information of the user at the current moment from the first database through a preset script of the second database, and generating a retrieval result of at least one account information of the user at the current moment from the first database; comparing the retrieval result with the account information of the user at the previous moment from the first database, and determining whether any account information at the current moment is consistent with the account information at the previous moment based on the comparison result; if the comparison result is inconsistent, determining that at least one account information at the current moment is inconsistent with the account information at the previous moment, and generating at least one target account information at the current moment.
[0062] The preset script can be any script used by a person skilled in the art based on search requirements, and no specific limitations are made here.
[0063] Specifically, such as Figure 2 As shown, in this embodiment of the application, after retrieving at least one account information of a user at the current moment in the first database, a retrieval result of at least one account information of the user at the current moment in the first database is generated. The retrieval result is compared with the account information of the user at the previous moment in the first database, and it is determined whether the at least one account information of the user at the current moment in the cloud MongoDB database is consistent with the account information at the previous moment. If the comparison result is inconsistent, it is determined that the at least one account information at the current moment is inconsistent with the account information at the previous moment, and at least one target account information at the current moment is generated.
[0064] For example, if, in this embodiment of the application, a preset script in the second database (i.e., a Python script in the cloud database) periodically retrieves information from the first database that the current role and permissions of user Zhang San have changed from the previous time, from the original platform early warning management role to the platform level 3 alarm management role, thereby enabling the changed role to access multiple menus and have the permission to use the new menus, then user Zhang San's account information at the previous time can be represented as follows:
[0065] Transaction ID: 5ac32373b6ba7b7376973933
[0066] Account / Character ID: 5aa25a9bc31614401376887a
[0067] Email: zhangsan@sample.org
[0068] Mobile phone number: 13754212323
[0069] Name: Zhang San
[0070] Username: zhangsan
[0071] User password: "34npatwYyxaALl9khxjNh7rktVKpu6DF5gROzsYkMX3="
[0072] Status: 1
[0073] Account type: T01
[0074] Department ID: 3
[0075] Brand code: KARRY
[0076] Company Name: "Karry New Energy Commercial Vehicle Co., Ltd."
[0077] User Zhang San's current account information can be represented as follows:
[0078] Transaction ID: 5ac32373b6ba7b7376973933
[0079] Account / Character ID: 5aa25a9bc31614401376778b
[0080] Email: zhangsan@sample.org
[0081] Mobile phone number: 13754212323
[0082] Name: Zhang San
[0083] Username: zhangsan
[0084] User password: "34npatwYyxaALl9khxjNh7rktVKpu6DF5gROzsYkMX3="
[0085] Status: 1
[0086] Account type: T01
[0087] Department ID: 3
[0088] Brand code: KARRY
[0089] Company Name: "Karry New Energy Commercial Vehicle Co., Ltd."
[0090] This shows that at least one target account information at the current moment is the account role field.
[0091] According to one embodiment of this application, determining whether any account information at the current time is consistent with the account information at the previous time based on the comparison result includes: when the comparison result is consistent, determining that at least one account information at the current time is consistent with the account information at the previous time, and not synchronizing at least one account information at the current time that is consistent with the account information at the previous time to the business table corresponding to the second database.
[0092] Specifically, such as Figure 2 As shown, if the comparison result between at least one account information of the user at the current time and the account information at the previous time in the first database is consistent, then it is determined that at least one account information at the current time is consistent with the account information at the previous time. That is, at least one account information that is consistent with the account information at the previous time is not synchronized to the corresponding business table in the second database.
[0093] In step S103, at least one target account information is synchronized to the corresponding business table in the second database.
[0094] According to one embodiment of this application, synchronizing at least one target account information to the corresponding business table of the second database includes: based on at least one target account information at the current time, retrieving at least one target account information at the current time from the first database through a preset script of the second database, establishing a target account information connection between the first database and the client; reading the target account information, establishing a target account information connection between the second database and the client, synchronizing at least one target account information to the corresponding business table of the second database, and generating a synchronization result of at least one target account information.
[0095] Specifically, in this embodiment of the application, after obtaining at least one target account information that is inconsistent with the account information of the previous time from at least one account information at the current time, based on at least one target account information at the current time, the system retrieves at least one target account information at the current time from the first database through a preset script of the second database and establishes a client connection between the first database and the MongoDB data table of the second database. The system reads the target account information as a parameter and writes it into memory for temporary storage. Then, the system establishes a client connection between the second database and the MongoDB data table of the second database, synchronizes at least one target account information to the corresponding business table of the second database through Update or Merge, and generates a synchronization result for at least one target account information.
[0096] According to one embodiment of this application, after synchronizing at least one target account information to the business table corresponding to the second database and generating the synchronization result of at least one target account information, the method further includes: verifying at least one target account information in the first database and at least one target account information in the second database, and after the verification is passed, calculating the synchronization result of at least one target account information.
[0097] Specifically, in this embodiment, after synchronizing at least one target account information to the corresponding business table in the second database and generating the synchronization result of at least one target account information, the Python script performs data verification between at least one target account information in the first database and at least one target account information in the second database. After the verification passes, the synchronization result of at least one target account information is summarized in a table, as shown in Table 1:
[0098] Table 1
[0099]
[0100] According to one embodiment of this application, after statistically analyzing the synchronization results of at least one target account information, the method further includes: determining whether the at least one target account information has been successfully synchronized based on the statistically analyzed synchronization results; if the at least one target account information has been successfully synchronized, reporting the synchronization result to a preset management platform; otherwise, sending a synchronization failure reminder to the preset management platform and resynchronizing the at least one target account information to the business table corresponding to the second database.
[0101] The preset management platform can be any management platform adopted by those skilled in the art based on actual usage needs, and no specific limitations are made here.
[0102] Specifically, in this embodiment, after the synchronization results of at least one target account information are statistically completed, based on the statistically completed synchronization results, after at least one target account information is successfully synchronized, a Python script is used to send a notification of the statistically completed synchronization results to a preset management platform via email or other communication methods and to provide feedback on the synchronization results. If, based on the statistically completed synchronization results, at least one target account information is not successfully synchronized, a synchronization failure reminder is sent to the preset management platform, and at least one target account information is resynchronized to the corresponding business table in the second database, until at least one target account information is successfully synchronized, thereby completing the automated and customized synchronization operation of user account information MongoDB data from the first database to the second database.
[0103] According to the data customization synchronization method of this application embodiment, at least one account information of a user at the current time is retrieved from the first database. If any account information at the current time is inconsistent with the account information at the previous time, at least one target account information that is inconsistent with the account information at the previous time is obtained from the at least one account information at the current time, and the at least one target account information is synchronized to the corresponding business table in the second database. This solves the limitations of single-point deployment in related technologies, and addresses the problems of human error, incorrect data synchronization, and long synchronization time when synchronizing data manually. By automating and customizing the synchronization of user account information on the cloud and on-premises, and feeding back the synchronization results to the relevant management platform after synchronization is completed, the efficiency of operation and maintenance and the accuracy of data synchronization are improved.
[0104] Next, a data-customized synchronization device according to an embodiment of this application is described with reference to the accompanying drawings.
[0105] Figure 3 This is a block diagram of a data-customized synchronization device according to an embodiment of this application.
[0106] like Figure 3 As shown, the data-customized synchronization device 10 includes: a retrieval module 100, an acquisition module 200, and a synchronization module 300.
[0107] The retrieval module 100 is used to retrieve at least one account information of a user in the first database at the current moment.
[0108] The acquisition module 200 is used to acquire at least one target account information that is inconsistent with the account information of the previous time from at least one account information at the current time; and
[0109] The synchronization module 300 is used to synchronize at least one target account information to the corresponding business table in the second database.
[0110] According to one embodiment of this application, the account information includes at least one of the account's corresponding role, account menu, and account item permissions.
[0111] According to one embodiment of this application, before determining that any account information at the current moment is inconsistent with the account information at the previous moment, the acquisition module 200 is further configured to:
[0112] The system retrieves at least one account information of a user in the first database at the current moment using a preset script in the second database, and generates retrieval results for at least one account information of a user in the first database at the current moment.
[0113] The search results are compared with the user's account information in the first database at the previous moment. Based on the comparison results, it is determined whether any account information at the current moment is consistent with the account information at the previous moment.
[0114] If the comparison results are inconsistent, determine that at least one account information at the current moment is inconsistent with the account information at the previous moment, and generate at least one target account information at the current moment.
[0115] According to one embodiment of this application, the acquisition module 200 is specifically used for:
[0116] If the comparison results are consistent, it is determined that at least one account information at the current time is consistent with the account information at the previous time. At least one account information at the current time that is consistent with the account information at the previous time is not synchronized to the business table corresponding to the second database.
[0117] According to one embodiment of this application, the synchronization module 300 is specifically used for:
[0118] Based on at least one target account information at the current moment, at least one target account information at the current moment is retrieved from the first database through a preset script in the second database, and a connection between the first database and the target account information of the client is established.
[0119] Read the target account information, establish a connection between the second database and the target account information on the client, synchronize at least one target account information to the corresponding business table in the second database, and generate a synchronization result for at least one target account information.
[0120] According to one embodiment of this application, after synchronizing at least one target account information to the corresponding business table of the second database and generating a synchronization result for at least one target account information, the synchronization module 300 is further configured to:
[0121] Verify at least one target account information in the first database with at least one target account information in the second database, and after the verification is passed, count the synchronization results of at least one target account information.
[0122] According to one embodiment of this application, after calculating the synchronization results of at least one target account information, the synchronization module is further configured to:
[0123] Based on the statistical synchronization results, determine whether at least one target account information has been successfully synchronized.
[0124] After at least one target account information is successfully synchronized, the synchronization result is reported back to the preset management platform; otherwise, a synchronization failure reminder is sent to the preset management platform, and at least one target account information is resynchronized to the corresponding business table in the second database.
[0125] According to the data customization synchronization device of this application embodiment, at least one account information of a user at the current moment is retrieved from the first database. If any account information at the current moment is inconsistent with the account information at the previous moment, at least one target account information that is inconsistent with the account information at the previous moment is obtained from the at least one account information at the current moment, and the at least one target account information is synchronized to the corresponding business table in the second database. This solves the limitations of single-point deployment in related technologies, and addresses the problems of human error, incorrect data synchronization, and long synchronization time when synchronizing data manually. By automating and customizing the synchronization of user account information on the cloud and on-premises, and feeding back the synchronization results to the relevant management platform after synchronization is completed, the efficiency of operation and maintenance and the accuracy of data synchronization are improved.
[0126] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include:
[0127] The memory 401, the processor 402, and the computer program stored on the memory 401 and capable of running on the processor 402.
[0128] When the processor 402 executes the program, it implements the data customization synchronization method provided in the above embodiments.
[0129] Furthermore, electronic devices also include:
[0130] Communication interface 403 is used for communication between memory 401 and processor 402.
[0131] The memory 401 is used to store computer programs that can run on the processor 402.
[0132] The memory 401 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0133] If the memory 401, processor 402, and communication interface 403 are implemented independently, then the communication interface 403, memory 401, and processor 402 can be interconnected via a bus to complete communication between them. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be divided into address buses, data buses, control buses, etc. For ease of representation, Figure 4 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0134] Optionally, in a specific implementation, if the memory 401, processor 402, and communication interface 403 are integrated on a single chip, then the memory 401, processor 402, and communication interface 403 can communicate with each other through an internal interface.
[0135] Processor 402 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.
[0136] This embodiment also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described data-customized synchronization method.
[0137] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0138] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0139] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more N executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.
[0140] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which programs can be printed, because programs can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.
[0141] It should be understood that the various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0142] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by a program instructing related hardware, and the program can be stored in a computer-readable storage medium. When executed, the program includes one or a combination of the steps of the method embodiments.
[0143] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0144] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.
Claims
1. A data-customized synchronization method, characterized in that, Includes the following steps: Retrieve at least one account information of a user in the first database at the current moment; If any account information at the current moment is inconsistent with the account information at the previous moment, then at least one target account information that is inconsistent with the account information at the previous moment is obtained from at least one account information at the current moment. as well as Synchronize the at least one target account information to the corresponding business table in the second database; Before determining that any account information at the current moment is inconsistent with the account information at the previous moment, the method further includes: retrieving at least one account information of the user at the current moment from the first database using a preset script in the second database, generating a retrieval result of at least one account information of the user at the current moment in the first database; comparing the retrieval result with the account information of the user at the previous moment in the first database, and determining whether any account information at the current moment is consistent with the account information at the previous moment based on the comparison result; if the comparison result is inconsistent, determining that at least one account information at the current moment is inconsistent with the account information at the previous moment, and generating at least one target account information at the current moment. The step of synchronizing the at least one target account information to the business table corresponding to the second database includes: based on the at least one target account information at the current time, retrieving the at least one target account information at the current time from the first database through a preset script in the second database, establishing a target account information connection between the first database and the client; reading the target account information, establishing a target account information connection between the second database and the client, synchronizing the at least one target account information to the business table corresponding to the second database, and generating a synchronization result for the at least one target account information; After synchronizing the at least one target account information to the business table corresponding to the second database and generating the synchronization result of the at least one target account information, the method further includes: verifying the at least one target account information in the first database and the at least one target account information in the second database, and after the verification is passed, calculating the synchronization result of the at least one target account information; Specifically, the pymongo module in Python periodically retrieves at least one account information of a user in the first database at the current moment. The first database is an on-premises MongoDB database, and the second database is a cloud-based database. The default script is a Python script. Establishing a connection between the first database and the client's target account information involves the client connecting to the MongoDB data table in the first database and the second database, reading the target account information as a parameter, and writing it into memory for temporary storage. Establishing a connection between the second database and the client's target account information involves the client connecting to the second database and its MongoDB data table, synchronizing at least one target account information to the corresponding business table in the second database via Update or Merge, and generating a synchronization result for at least one target account information.
2. The method according to claim 1, characterized in that, The account information includes at least one of the account's corresponding role, account menu, and account item permissions.
3. The method according to claim 1, characterized in that, The step of determining whether any account information at the current moment is consistent with the account information at the previous moment based on the comparison result includes: If the comparison results are consistent, it is determined that at least one account information at the current time is consistent with the account information at the previous time, and at least one account information at the current time that is consistent with the account information at the previous time is not synchronized to the business table corresponding to the second database.
4. A data-customized synchronization device, characterized in that, include: The retrieval module is used to retrieve at least one account information of a user in the first database at the current moment; The acquisition module is used to acquire at least one target account information that is inconsistent with the account information of the previous time from at least one account information at the current time if any account information at the current time is inconsistent with the account information of the previous time. as well as The synchronization module is used to synchronize the at least one target account information to the corresponding business table in the second database; Before determining that any account information at the current moment is inconsistent with the account information at the previous moment, the acquisition module is further configured to: retrieve at least one account information of the user at the current moment from the first database using a preset script in the second database, and generate a retrieval result of at least one account information of the user at the current moment in the first database; compare the retrieval result with the account information of the user at the previous moment in the first database, and determine whether any account information at the current moment is consistent with the account information at the previous moment based on the comparison result; if the comparison result is inconsistent, determine that at least one account information at the current moment is inconsistent with the account information at the previous moment, and generate at least one target account information at the current moment; The synchronization module is specifically used for: based on at least one target account information at the current time, retrieving at least one target account information at the current time from the first database through a preset script in the second database, establishing a connection between the first database and the target account information of the client; reading the target account information, establishing a connection between the second database and the target account information of the client, synchronizing the at least one target account information to the corresponding business table in the second database, and generating a synchronization result for the at least one target account information; After synchronizing the at least one target account information to the business table corresponding to the second database and generating the synchronization result of the at least one target account information, the synchronization module is further configured to: verify the at least one target account information in the first database and the at least one target account information in the second database, and after the verification is passed, count the synchronization result of the at least one target account information; Specifically, the pymongo module in Python periodically retrieves at least one account information of a user in the first database at the current moment. The first database is an on-premises MongoDB database, and the second database is a cloud-based database. The default script is a Python script. Establishing a connection between the first database and the client's target account information involves the client connecting to the MongoDB data table in the first database and the second database, reading the target account information as a parameter, and writing it into memory for temporary storage. Establishing a connection between the second database and the client's target account information involves the client connecting to the second database and its MongoDB data table, synchronizing at least one target account information to the corresponding business table in the second database via Update or Merge, and generating a synchronization result for at least one target account information.
5. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, the processor executing the program to implement the data-customized synchronization method as described in any one of claims 1-3.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that, The program is executed by the processor to implement the data-customized synchronization method as described in any one of claims 1-3.