Database synchronization method, device, equipment, and storage medium based on difference detection

Through the difference detection method between the management terminal and the database management platform, query statements are automatically constructed and executed, which solves the problem of low database synchronization efficiency in the property management field, improves data repair efficiency and flexibility, and is suitable for non-professional operations.

CN118377833BActive Publication Date: 2024-09-03LINJIU WISDOM (GUANGDONG) TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410793237.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2024-09-03
Estimated Expiration
2044-06-19

AI Technical Summary

Technical Problem

In the field of property management, property management systems and databases are usually developed by third parties. As a result, property managers lack professional database programming knowledge, resulting in poor timeliness of maintenance when data anomalies occur. Existing difference detection scripts are inefficient and have poor flexibility, making it difficult to quickly repair. Data anomaly.

Method used

Provides a database synchronization method based on difference detection. Through communication between the management terminal and the database management platform, candidate objects and detection configuration tables are pushed, target query statements are generated, difference detection and update statements are automatically constructed, data synchronization and repair are realized, and the cost is reduced Operational complexity and data processing volume.

Benefits of technology

It improves the flexibility and applicability of database synchronization, realizes automated data synchronization, reduces the amount of data processing, and improves the efficiency of repairing data anomalies. It is suitable for non-professional database operators.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118377833B
    Figure CN118377833B
Patent Text Reader

Abstract

The present invention proposes a database synchronization method, device, equipment, and storage medium based on difference detection. The method includes: obtaining a detection configuration table sent by a management terminal; obtaining object information from a source database and a target database after generating a target query statement based on the detection configuration table to determine a difference detection result; when at least one difference object is determined, updating the target database according to an automatically constructed target update statement. In this way, operators who do not have database knowledge can flexibly configure target objects in a visual selection manner, thereby improving the applicability and flexibility of database synchronization; automatically constructing a query statement based on the detection configuration table, only obtaining the object information of the target object from the source database and the target database and completing the difference detection and data synchronization of the target database, can not only realize automatic data synchronization, but also reduce the amount of data to be processed, improve the data processing efficiency of the database, and thus improve the efficiency of repairing data anomalies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of database technology, and in particular to a database synchronization method, device, equipment, and storage medium based on difference detection. Background Art

[0002] With the development of Internet technology, property management has begun to adopt an online model. Residents can log in to the property management system through the relevant APP and perform relevant property operations online. In order to improve the resident experience, the property management system often launches new functions or modifies existing functions, and each system update involves the update of the system database. In order to ensure that the updated database is available, the source database and the target database are usually configured for the property management system. When the property management system is running, it obtains relevant data from the target database, creates, modifies or deletes relevant data tables in the source database when developing or updating functions, and synchronizes the data of the source database to the target database after the development is completed.

[0003] Cross-database data migration will inevitably lead to data inconsistency. In some related technologies, developers can construct query statements or use script files to obtain relevant data from the source database and the target database for comparison, so as to determine the difference data and perform relevant correction operations.

[0004] However, in the field of property management, property management systems and databases are usually developed by third parties. Property management personnel do not necessarily have professional database programming knowledge. When data anomalies occur, they entrust external developers to carry out maintenance, and the timeliness cannot be guaranteed. If script files provided by third parties are used for difference detection and data repair, the script files usually perform global detection on the database to ensure the comprehensiveness of the detection. The detection efficiency is low and the flexibility is poor, which is not conducive to quickly repairing data anomalies. Summary of the invention

[0005] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, the present invention proposes a database synchronization method, device, equipment, and storage medium based on difference detection, which can improve the flexibility and applicability of data difference detection and improve the efficiency of repairing data anomalies.

[0006] In a first aspect, an embodiment of the present invention provides a database synchronization method based on difference detection, which is applied to a database management platform, wherein the database management platform is communicatively connected with a source database, a target database, and a management terminal, and the method includes:

[0007] When a difference detection request sent by the management terminal is obtained, multiple candidate objects are pushed to the management terminal, and a detection configuration table and abnormal description information fed back by the management terminal are obtained, wherein the candidate objects are database objects of the source database, the object types of the candidate objects are different from each other, and the detection configuration table records at least one target object selected by the management terminal;

[0008] Generate a target query statement for each target object based on the detection configuration table, obtain first object information from the source database according to the target query statement, obtain second object information from the target database, and determine a difference detection result according to the first object information and the second object information, wherein the first object information and the second object information are used to indicate a data structure, object data or object definition of the target object;

[0009] When at least one difference object is determined based on the difference detection result, a reference style statement is constructed based on the difference detection result and the difference object, and a target update statement is obtained by filling the reference style statement based on the first object information;

[0010] The target update statement is sent to the target database for execution, and a difference detection record is created based on the exception description information and the detection configuration table.

[0011] According to some embodiments of the present invention, before pushing the multiple candidate objects to the management terminal, the method further includes:

[0012] Pushing a database list to the management terminal, wherein the database list includes multiple business databases, each of which belongs to a different business system;

[0013] Acquire the target database selected by the management terminal from the database list, and determine the source database associated with the target database;

[0014] Sending a preset reference query statement to the source database and the target database, and acquiring the candidate object of the source database when the first reference information fed back by the source database and the second reference information fed back by the target database are simultaneously acquired;

[0015] A first prompt message is sent to the management terminal so that the management terminal constructs a visualization interface, wherein the first prompt message is used to indicate that the connection check between the source database and the target database has passed, and the visualization interface is used to display the candidate object and input the exception description information.

[0016] According to some embodiments of the present invention, the pushing of multiple candidate objects to the management terminal and obtaining a detection configuration table fed back by the management terminal includes:

[0017] Building an object tree based on the multiple candidate objects, wherein the candidate objects are root nodes of the object tree;

[0018] When the candidate object includes multiple optional fields, determining the optional fields as child nodes of the corresponding candidate object;

[0019] Pushing the object tree to the management terminal so that the management terminal displays the object tree on the visualization interface;

[0020] The detection configuration table fed back by the management terminal is obtained, wherein, when the selected candidate object does not include the sub-node, the candidate object is determined as the target object, or, when the selected candidate object includes the sub-node, the target object is constructed based on the candidate object and the selected sub-node.

[0021] According to some embodiments of the present invention, generating a target query statement for each target object based on the detection configuration table includes:

[0022] When the object type of the target object is a table structure or index information, determining the system table of the source database or the target database as a target query table of the target query statement, and determining the table structure or the index information as a query object of the target query statement;

[0023] Alternatively, when the object type of the target object is table data, the database table to which the table data belongs is determined as the target query table, and the primary key or code value corresponding to the table data is determined as the query object of the target query statement;

[0024] Alternatively, when the object type of the target object is permission information, the system table or permission table of the source database or the target database is determined as the target query table, and the user permissions recorded in the target query table are determined as the query object of the target query statement;

[0025] Alternatively, when the object type of the target object is a stored procedure or a trigger, the definition statement of the target object is determined as the query object of the target query statement.

[0026] According to some embodiments of the present invention, constructing a reference style statement based on the difference detection result and the difference object, and filling the reference style statement based on the first object information to obtain a target update statement includes:

[0027] According to the difference detection result, determining a target keyword from an update keyword library of the difference object, wherein each candidate object is preset with the update keyword library, the update keyword library includes a plurality of available operation keywords, and the available operation keywords are used to indicate adding, deleting, modifying or authorizing;

[0028] Determine a target data table for recording the difference object, and construct the reference style statement according to the target data table and the target keyword, wherein the reference style statement includes a data bit, a table unit, and a field bit, the data bit and the field bit are empty, and the table unit records the target data table;

[0029] Determine difference data and difference fields based on the first object information of the difference object, fill the difference data into the data bits of the reference style statement, fill the difference fields into the field bits of the reference style statement, and determine the filled reference style statement as the target update statement.

[0030] According to some embodiments of the present invention, after creating a difference detection record based on the abnormal description information and the detection configuration table, the method further includes:

[0031] When a new difference detection request is obtained, a historical record set is pushed to the management terminal, wherein the historical record set includes at least one previously generated difference detection record;

[0032] When the management terminal selects a target detection record from the historical record set, a difference detection is re-run based on the detection configuration table recorded in the target detection record;

[0033] When the management terminal does not select the target detection record, the candidate object is pushed to the management terminal.

[0034] According to some embodiments of the present invention, after creating a difference detection record based on the abnormal description information and the detection configuration table, the method further includes:

[0035] Sending the difference detection record to the management terminal so that the management terminal creates a detection configuration interface, wherein the detection configuration interface is used to configure associated operations of the difference detection record;

[0036] When the timing configuration information of the management terminal is obtained, performing difference detection based on the timing configuration information and the detection configuration table;

[0037] Alternatively, when the record association information of the management terminal is acquired, a plurality of associated difference detection records are determined based on the record association information, and the plurality of associated difference detection records are combined into a combined detection record.

[0038] In a second aspect, an embodiment of the present invention provides a database synchronization device based on difference detection, comprising at least one control processor and a memory for communicating with the at least one control processor; the memory stores instructions executable by the at least one control processor, and the instructions are executed by the at least one control processor so that the at least one control processor can execute the database synchronization method based on difference detection as described in the first aspect above.

[0039] In a third aspect, an embodiment of the present invention provides an electronic device, comprising the database synchronization device based on difference detection as described in the second aspect above.

[0040] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the database synchronization method based on difference detection as described in the first aspect above.

[0041] According to the database synchronization method based on difference detection of the embodiment of the present invention, there are at least the following beneficial effects: when a difference detection request sent by the management terminal is obtained, multiple candidate objects are pushed to the management terminal, and a detection configuration table and abnormal description information fed back by the management terminal are obtained, wherein the candidate objects are database objects of the source database, the object types of the candidate objects are different from each other, and the detection configuration table records at least one target object selected by the management terminal; a target query statement for each target object is generated based on the detection configuration table, first object information is obtained from the source database according to the target query statement, and second object information is obtained from the target database, and a difference detection result is determined according to the first object information and the second object information, wherein the first object information and the second object information are used to indicate the data structure, object data or object definition of the target object; when at least one difference object is determined based on the difference detection result, a reference style statement is constructed based on the difference detection result and the difference object, and the reference style statement is filled based on the first object information to obtain a target update statement; the target update statement is sent to the target database for execution, and a difference detection record is created based on the abnormal description information and the detection configuration table. According to the technical solution of the embodiments of the present invention, operators who do not have database knowledge can flexibly configure target objects in a visual selection manner on the management terminal, thereby improving the applicability and flexibility of database synchronization; the database management platform automatically constructs query statements based on the detection configuration table, only obtains the object information of the target object from the source database and the target database, and completes difference detection and data synchronization of the target database, which not only realizes automatic data synchronization, but also reduces the amount of data processing, improves the data processing efficiency of the database, and thus improves the efficiency of repairing data anomalies. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 is a connection diagram of a database management platform provided by an embodiment of the present invention;

[0043] Figure 2 is a flowchart of a database synchronization method based on difference detection provided by another embodiment of the present invention;

[0044] Figure 3 is a schematic diagram of a management terminal custom detection configuration table provided by another embodiment of the present invention;

[0045] Figure 4 is a schematic diagram of a visual interface of a management terminal provided by another embodiment of the present invention;

[0046] Figure 5 It is a structural diagram of a database synchronization device based on difference detection provided by another embodiment of the present invention. DETAILED DESCRIPTION

[0047] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.

[0048] In the description of the present invention, it should be understood that descriptions involving orientations, such as up, down, front, back, left, right, etc., and orientations or positional relationships indicated are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present invention.

[0049] In the description of the present invention, "several" means one or more, "more" means more than two, "greater than", "less than", "exceed" etc. are understood as not including the number itself, and "above", "below", "within" etc. are understood as including the number itself. If there is a description of "first" or "second", it is only used for the purpose of distinguishing the technical features, and cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.

[0050] In the description of the present invention, unless otherwise clearly defined, terms such as setting, installing, connecting, etc. should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in the present invention based on the specific content of the technical solution.

[0051] The embodiment of the present invention provides a database synchronization method, apparatus, device, and storage medium based on difference detection, wherein the database synchronization method based on difference detection includes: when obtaining a difference detection request sent by a management terminal, pushing multiple candidate objects to the management terminal, obtaining a detection configuration table and abnormal description information fed back by the management terminal, wherein the candidate objects are database objects of a source database, the object types of each candidate object are different from each other, and the detection configuration table records at least one target object selected by the management terminal; generating a target query statement for each target object based on the detection configuration table, obtaining first object information from the source database according to the target query statement, obtaining second object information from the target database, and determining a difference detection result based on the first object information and the second object information, wherein the first object information and the second object information are used to indicate a data structure, object data, or object definition of the target object; when at least one difference object is determined based on the difference detection result, constructing a reference style statement based on the difference detection result and the difference object, and filling the reference style statement based on the first object information to obtain a target update statement; sending the target update statement to the target database for execution, and creating a difference detection record based on the abnormal description information and the detection configuration table. According to the technical solution of the embodiment of the present invention, operators who do not have database knowledge can flexibly configure target objects in a visual selection manner on the management terminal, thereby improving the applicability and flexibility of database synchronization; the database management platform automatically constructs query statements based on the detection configuration table, only obtains the object information of the target object from the source database and the target database, and completes difference detection and data synchronization of the target database, which not only realizes automatic data synchronization, but also reduces the amount of related processed data, improves the data processing efficiency of the database, and thus improves the efficiency of repairing data anomalies.

[0052] First, refer to Figure 1 , Figure 1 This is a connection diagram of a database management platform provided in an embodiment of the present invention. The database management platform 10 is communicatively connected with a source database 31 , a target database 32 and a management terminal 20 .

[0053] It should be noted that the database management platform 10 of this embodiment can be connected to multiple groups of databases. For example, in the field of real estate, a group of source databases 31 and target databases 32 can be configured for each community. Of course, multiple communities can also share a group of source databases 31 and target databases 32, and the data of different communities can be distinguished through different database tables. The database management platform 10 of this embodiment can access any target database 32, thereby realizing unified management of multiple database groups.

[0054] It should be noted that the management terminal 20 can be pre-bound to a database group, for example, the first management terminal responsible for cell A is bound to the first source database and the first target database. When the first management terminal is connected to the database management platform, the first source database and the first target database are automatically determined as the database group corresponding to this management, and the candidate objects of the first source database are pushed to the first management terminal. The management of all database groups can also be achieved through one management terminal 20. For example, the same property management personnel is responsible for the information management of multiple cells, each cell corresponds to a database group, and multiple database groups are displayed on the management terminal 20. When any target database is selected from them, the corresponding source database is automatically matched. Of course, in order to improve the convenience of management, the cell name can be displayed on the management terminal 20, and the corresponding source database 31 and target database 32 are automatically matched after the target cell is selected.

[0055] The following is based on the Figure 1 The property management system shown further illustrates the technical solution of the embodiment of the present invention.

[0056] Reference Figure 2 , Figure 2 A flowchart of a database synchronization method based on difference detection provided by an embodiment of the present invention, the database synchronization method based on difference detection includes but is not limited to the following steps:

[0057] S10, when a difference detection request sent by the management terminal is obtained, multiple candidate objects are pushed to the management terminal, and a detection configuration table and abnormal description information fed back by the management terminal are obtained, wherein the candidate objects are database objects of the source database, the object types of the candidate objects are different from each other, and the detection configuration table records at least one target object selected by the management terminal;

[0058] S20, generating a target query statement for each target object based on the detection configuration table, acquiring first object information from a source database according to the target query statement, acquiring second object information from a target database, and determining a difference detection result according to the first object information and the second object information, wherein the first object information and the second object information are used to indicate a data structure, object data or object definition of the target object;

[0059] S30, when at least one difference object is determined based on the difference detection result, a reference style statement is constructed based on the difference detection result and the difference object, and the reference style statement is filled based on the first object information to obtain a target update statement;

[0060] S40, sending the target update statement to the target database for execution, and creating a difference detection record based on the exception description information and the detection configuration table.

[0061] It should be noted that the difference detection request can be initiated through the visual interface of the management terminal, for example, a difference detection button is set in the management interface of the property management APP. The property management APP connects to the target database during normal operation. When the property management personnel perform data-related online management operations abnormally, the difference detection request can be triggered through the difference detection button. For example, when an error is reported when exporting property management fee data, or when a prompt message is sent to the resident account and it is prompted that the corresponding resident information cannot be found, the difference detection request can be used to check the data abnormality. At this time, the property management APP can access the database management platform through the bound account password and send a difference detection request.

[0062] It should be noted that after receiving the difference detection request, the database management platform does not directly perform the difference detection, but pushes multiple candidate objects to the management terminal. The property management APP is developed based on the data of the source database. When the property management APP calls data, it uses the data structure and object data of the source database as a benchmark. The target database is used to provide data support for the property management APP during operation. However, the database objects of the target database are not necessarily accurate and reliable, resulting in the management terminal being unable to select the correct target object for difference detection. The candidate objects of this embodiment come from the source database rather than the target database, ensuring that the candidate objects are accurate and reliable.

[0063] For example, an error occurs when exporting the property management fees of the residents of Building X in Community A. If the form of the residents of Building X is not synchronized from the source database to the target database during data synchronization, the management personnel will use the "data sheet of the residents of Building X" as the target object for difference detection under the relevant error prompt. If the target database is used as the basis for pushing the candidate object, the management terminal will not have the option of "data sheet of the residents of Building X", resulting in the inability to perform subsequent difference detection. If the source database is used as the basis for pushing the candidate object, the object "data sheet of the residents of Building X" can be displayed normally, and subsequent difference detection can be performed.

[0064] It should be noted that the candidate objects can be various database objects of the source database, such as Figure 1 As shown, the candidate objects include table structure, table data, index information, permission information, stored procedures and triggers, etc. Those skilled in the art are familiar with the definitions of various database objects and will not be elaborated here.

[0065] For example, continuing to refer to the example of property management fees, when an error occurs in exporting the property management fees of the residents of Building X, although the property management personnel may not have professional database knowledge, they can understand the table structure through text descriptions to determine whether the data table exists, and the table data can determine whether the data is wrong or missing. Therefore, the table structure and table data can be selected as the target objects of difference detection, which not only reduces the knowledge threshold of difference detection, but also enables flexible object configuration.

[0066] It should be noted that since the selection of the target object is performed in the management terminal and the difference detection is performed in the database management platform, this embodiment uses the detection configuration table as a recording carrier of the target object, so that the management terminal can send the target object to the database management platform in the form of a form, and the database management platform can also save the detection configuration table as a data basis for subsequent operations.

[0067] It should be noted that the exception description information can be a description of the reason for initiating the difference detection. The property management APP of this embodiment is used by property management personnel, so the exception description information can be a spoken description information in the field of property management, such as the above example of "there is an error in the property management fee of the residents of Building X". When the difference detection record is created later, the difference detection record with the difference description information saved will be used. When the property management personnel view the difference detection record, they can know the reason for initiating the difference detection, thereby lowering the threshold for using the database management platform. Figure 3 As shown, the difference description information can be provided in the form of an input box set in the visual interface, filled in synchronously when the target object is selected, and fed back to the database management platform at the same time as the detection configuration table.

[0068] It should be noted that after determining the target object, a corresponding target query statement is constructed according to the target object type, and information query is performed on the specified target object through the target query statement. For example, the form where the target object is located is selected through the common SELECT keyword, and the target object is specified through the WHERE keyword, etc. Those skilled in the art are familiar with the query statements of various database objects, and the functions of various keywords are not elaborated here.

[0069] It should be noted that after constructing the target query statement, the database management object simultaneously initiates queries to the source database and the target database, obtains the first object information from the source database, and obtains the second object information from the target database. If the target objects of the target database and the source database are the same, then the first object information and the second object information must also be the same, and the difference objects can be determined by information comparison.

[0070] For example, Figure 1As shown, the target object includes table structure, table data and index information. A target query statement 1 can be created for the table structure, a target query statement 2 can be constructed for the table data, and a target query statement 3 can be constructed for the index information. The target query statement 1 is used to obtain the table name, column information, data type, constraint and other information of the same database table in the source database and the target database for comparison to determine that the table structures are the same; the same is true for the table data and index information, which will not be elaborated here.

[0071] It should be noted that after determining the difference object, the target database needs to be updated for the difference object. This embodiment first constructs a reference style statement based on the difference detection result and the difference object, and then fills it in according to the first object information from the source database to obtain the target update statement. After determining the difference detection result, the root cause of the difference between the target database and the source database can be determined, such as data loss in the target database, table structure error, etc. When the root cause is determined, the statement required to update the content of the target database to be consistent with the source database can be determined. For example, when a table or data is lost, the reference style statement can use the CREATE keyword to create the table or data, or use the INSERT keyword to insert data; for example, when the data is wrong, the reference style statement can use the UPDATE keyword to update the data.

[0072] It should be noted that when the difference objects are different, the keywords that can be used are not necessarily the same. For example, when the difference objects are table structures and permission information, the commonly used keywords for table structures include the above-mentioned CREATE and ALTER, etc., while the commonly used keyword for permission information is GRANT. Therefore, after determining the difference detection results, this embodiment needs to further determine the available keywords in combination with the difference objects, so as to construct a reference style statement that conforms to the difference objects.

[0073] It should be noted that the reference style statement of this embodiment includes keywords and difference objects, which can represent the object and specific operation of the synchronization operation, and the content of the specific operation needs to be obtained from the first object information and filled into the reference style statement to obtain the target update statement. For example, the reference style statement is used to modify data B in data table A. The specific value C is obtained from the first object information and filled into the reference style statement, so that the target update statement can modify data B in data table A of the target database to value C.

[0074] It should be noted that after the target update statement is sent to the target database, the specific execution process will not be described in detail here. After completing the update of the target database, this embodiment creates a difference detection record based on the exception description information and the detection configuration table. Since the detection configuration table records the target object involved in this operation, and the exception description information is used to characterize the reason for initiating this operation, the difference detection record can record the property management personnel's oral description of the data anomaly, and records the target object involved in the database synchronization. When the same problem occurs again in the future, the property management personnel can query whether there is a reference operation method based on the difference detection record, which further reduces the requirements for database knowledge and improves the convenience and flexibility of the database management platform.

[0075] Through the technical solution of this embodiment, Figure 1 As shown, after the management terminal 20 sends a difference detection request to the database management platform 10, the database management platform 10 pushes multiple candidate objects to the management terminal 20. After the management terminal 20 selects the target object, it feeds back a detection configuration table. The database management platform 10 automatically constructs a target query statement based on the detection configuration table, obtains the first object information from the source database 31 according to the target query statement, obtains the second object information from the target database 32, determines the difference object and the difference detection result through difference detection, constructs a target update statement and sends it to the target database 32 for database update, which can realize flexible configuration of the target object and automatically update the target database 32, and reduces the amount of data for related processing, thereby improving the data processing efficiency of the database and thus improving the efficiency of repairing data anomalies.

[0076] In addition, in one embodiment, before pushing multiple candidate objects to the management terminal in step S10, the method further includes but is not limited to the following steps:

[0077] S11, pushing a database list to the management terminal, wherein the database list includes multiple business databases, each of which belongs to a different business system;

[0078] S12, obtaining a target database selected by the management terminal from the database list, and determining a source database associated with the target database;

[0079] S13, sending a preset reference query statement to the source database and the target database, and obtaining candidate objects of the source database when first reference information fed back by the source database and second reference information fed back by the target database are obtained at the same time;

[0080] S14, sending first prompt information to the management terminal so that the management terminal builds a visualization interface, wherein the first prompt information is used to indicate that the connection check between the source database and the target database has passed, and the visualization interface is used to display candidate objects and input abnormal description information.

[0081] It should be noted that after the management terminal initiates a difference detection request, since the property management system can include multiple business systems, that is, the database group described in the above example, this embodiment pushes a database list to the management terminal, and the database list only records each business database as a target database. For example, in the property field, the first target database corresponds to community A, the second target database corresponds to community B, etc. When the property management personnel encounter an abnormality when operating the data of community A, they can select the first target database from the database list as the target database for this difference detection. Of course, in order to facilitate the selection of property management personnel who do not have database knowledge, each business database in the database list can be customized, such as "community A" in the above example, etc., which will not be elaborated here.

[0082] It should be noted that after selecting the target database, the database management platform can automatically determine the corresponding source database. Furthermore, this embodiment performs connection verification on the source database and the target database through a reference query statement. The reference query statement can be used to perform simple SQL queries on the source database and the target database, such as querying the system table name or the database version. When the first reference information and the second reference information fed back are the same, it can be determined that the communication between the database management platform and the source database and the target database is correct.

[0083] It should be noted that after completing the connection verification, the database management platform sends a first prompt message to the management terminal. The management terminal determines based on the first prompt message that the source database and the target database have been determined and the query is available, and constructs a query result. Figure 3 The visual interface shown is used to select the target object and enter the exception description information.

[0084] In addition, in one embodiment, in step S10, multiple candidate objects are pushed to the management terminal, and a detection configuration table fed back by the management terminal is obtained, which specifically includes but is not limited to the following steps:

[0085] S15, constructing an object tree based on the multiple candidate objects, wherein the candidate object is a root node of the object tree;

[0086] S16, when the candidate object includes multiple optional fields, determining the optional fields as child nodes of the corresponding candidate object;

[0087] S17, pushing the object tree to the management terminal so that the management terminal displays the object tree on a visual interface;

[0088] S18, obtaining a detection configuration table fed back by the management terminal, wherein when the selected candidate object does not include a child node, the candidate object is determined as a target object, or when the selected candidate object includes a child node, a target object is constructed based on the candidate object and the selected child node.

[0089] It should be noted that, according to the description of the above embodiment, each candidate object corresponds to a type of database object, and some candidate objects may include multiple sub-nodes. For candidate objects with sub-nodes, this embodiment constructs an object tree so that a hierarchical display can be achieved in the visual interface of the management terminal, further refining the construction granularity of the target object and reducing the amount of unnecessary data.

[0090] It should be noted that for a candidate object without a child node, the candidate object is directly determined as the target object, and a global detection is performed on the candidate object when performing difference detection; and when a child node of the candidate object is selected, the selected child node of the candidate object is used as the target object, and there is no need to perform a global detection on the candidate object, thereby reducing the amount of data for difference detection.

[0091] For example, taking the candidate object as table data, the optional fields include X building property management fee, Y building property management fee, etc. The anomaly detection is initiated based on the anomaly of X building property management fee. Then the optional field of X building property management fee can be selected as the child node of this anomaly detection. The constructed target object is X building property management fee in the table data. When performing difference detection, there is no need to consider other table data, which effectively reduces the amount of data processing. Of course, you can also select multiple optional fields, which will not be elaborated here.

[0092] In addition, in one embodiment, in step S20, a target query statement for each target object is generated based on the detection configuration table, which specifically includes but is not limited to the following steps:

[0093] S21, when the object type of the target object is a table structure or index information, determining a system table of the source database or the target database as a target query table of the target query statement, and determining the table structure or index information as a query object of the target query statement;

[0094] S22, when the object type of the target object is table data, determining the database table to which the table data belongs as the target query table, and determining the primary key or code value corresponding to the table data as the query object of the target query statement;

[0095] S23, when the object type of the target object is permission information, a system table or permission table of the source database or the target database is determined as a target query table, and the user permissions recorded in the target query table are determined as a query object of the target query statement;

[0096] S24: When the object type of the target object is a stored procedure or a trigger, the definition statement of the target object is determined as the query object of the target query statement.

[0097] It should be noted that when the object type of the target object is a table structure or index information, the object information is recorded in the system table of the database (such as INFORMATION_SCHEMA.TABLES), so the query table of the target query statement is the system table, and the query object is the table structure or index information. For example, when comparing table structures, it is necessary to obtain the table information of the source database and the target database from the system table. The table information can be the table name, column name, data type, constraint, etc., and compare them one by one; for another example, when comparing index information, the table creation statements of each database table are obtained from the system tables of the source database and the target database, and the index information is determined from the table creation statements through keyword recognition, and subsequent comparison is performed after the index information is obtained.

[0098] It should be noted that when the object type of the target object is table data, each table data is stored in the corresponding database table. By using it as the target query table, the consistency of the data can be determined by comparing the primary key and the encoding value. For example, the data in the database table is extracted and concatenated, and then MD5 encoded. If the MD5 value obtained based on the source database is the same as the MD5 value of the target database, it can be determined that the internal table data is the same.

[0099] It should be noted that when the object type of the target object is permission information, the permission information is the permission required to perform data operations in the database. The permission required for each data operation can be determined by querying the system table or permission table, thereby determining whether the user permissions of the source database and the target database are consistent.

[0100] It should be noted that when the object type of the target object is a stored procedure or a trigger, whether the objects are the same mainly depends on the description of the definition information. Therefore, the query object of the target query statement is the corresponding definition statement. The comparison of the definition statements is used to determine whether the stored procedures or triggers in the source database and the target database are the same.

[0101] In addition, in one embodiment, in step S20, a reference style statement is constructed based on the difference detection result and the difference object, and the reference style statement is filled based on the first object information to obtain a target update statement, which specifically includes but is not limited to the following steps:

[0102] S25, determining a target keyword from an update keyword library of the difference object according to the difference detection result, wherein each candidate object is preset with an update keyword library, the update keyword library includes a plurality of available operation keywords, and the available operation keywords are used to indicate adding, deleting, modifying or authorizing;

[0103] S26, determining a target data table for recording the difference object, and constructing a reference style statement according to the target data table and the target keyword, wherein the reference style statement includes a data bit, a table unit, and a field bit, the data bit and the field bit are empty, and the table unit records the target data table;

[0104] S27, determining the difference data and the difference field based on the first object information of the difference object, filling the difference data into the data bit of the reference style statement, filling the difference field into the field bit of the reference style statement, and determining the filled reference style statement as the target update statement.

[0105] It should be noted that for different target objects, the target update statements constructed may be different. For example, for table data, a data manipulation statement (Data Manipulation Language, DML) needs to be constructed, and for other objects, a data definition statement (Data Definition Language, DDL) needs to be constructed. Those skilled in the art are familiar with the difference between the two statements, which will not be repeated here.

[0106] It should be noted that the present embodiment pre-sets an update keyword library, establishes an association relationship between difference objects and available operation keywords through the update keyword library, and after determining the difference detection result, selects a target keyword from the update keyword library based on the difference detection result, thereby constructing a reference style statement. For example, the available operation keywords corresponding to the table structure include ALTER, CREATE, INSERT, etc. When the difference detection result is used to indicate that a data table is missing, CREATE is used as the target keyword to create the missing data table. The available operation keywords of other object types are not given one by one here.

[0107] It should be noted that after determining the target keyword, the target data table of the difference object corresponding to B is further determined, such as the system table, permission table, etc. described in the above embodiment. After determining the target data table and the target keyword, the corresponding reference style statement is automatically constructed, and the data bit, table unit and field bit are left blank, that is, the reference style statement of this embodiment is not a complete executable database statement, but a structure statement with several blank bits. After obtaining the difference data and difference field from the first object information according to the difference object, the corresponding position of the reference style statement is filled in to obtain the target update statement, thereby realizing the automatic construction of the target update statement.

[0108] For example, referring to the example of the property management fee of Building X in Community A above, when the difference detection result is missing data, the target keyword is INSERT, which is used to insert new records, and the target query table is the data table corresponding to "Property Management Fee of Building X"; the household information of each household in Building X is obtained from the first object information as the difference field, and the property management fee of each household is used as the difference data, which is filled into the reference style statement to obtain the final target update statement.

[0109] In addition, in one embodiment, after executing step S40, the following steps are also included but not limited to:

[0110] S51, when a new difference detection request is obtained, a historical record set is pushed to a management terminal, wherein the historical record set includes at least one previously generated difference detection record;

[0111] S52, when the management terminal selects a target detection record from the historical record set, a difference detection is re-run based on the detection configuration table recorded in the target detection record;

[0112] S53: When the management terminal does not select the target detection record, the candidate object is pushed to the management terminal.

[0113] It should be noted that after completing the difference detection, this embodiment constructs and saves the difference detection record. After obtaining a new difference detection request, the historical record set is pushed to the management terminal as a reference. The property management personnel can compare the actual problems encountered based on the difference description information of the previous difference detection record. If a similar difference detection has been performed before, the target detection record can be directly selected for repeated execution. In this way, the developer can configure the difference detection record in advance for different problems encountered in property management. After delivering it to the property management personnel who have no database experience, the property management personnel can make a selection based on the difference description information of the difference detection record, thereby initiating the correct difference detection without development knowledge. If there is no selection from the historical record set, the data anomaly encountered this time is not in the historical record, and the candidate object needs to be pushed and the detection configuration table needs to be rebuilt according to the scheme of the above embodiment.

[0114] For example, Figure 3As shown, when responding to the difference detection request 1, the target object includes the table structure, table data and index information, and the corresponding exception description information is the property management fee data exception. The difference detection record is saved accordingly and displayed with the exception description information in the historical record collection; when the property management personnel encounters the property management fee data exception, the difference detection request 2 is initiated through the management terminal 20 and the database management platform is connected. The database management platform pushes the historical record collection to the management terminal 20. After the property management personnel selects "Property Management Fee Data Abnormality" through the historical record collection, the corresponding detection configuration table is automatically selected for difference detection. The target object involved in this difference detection is the previously used table structure, table data and index information, which effectively reduces the knowledge threshold of difference detection and improves the selection efficiency and accuracy of the target object.

[0115] In addition, in one embodiment, after executing step S40, the following steps are also included but not limited to:

[0116] S61, sending the difference detection record to the management terminal, so that the management terminal creates a detection configuration interface, wherein the detection configuration interface is used to configure associated operations of the difference detection record;

[0117] S62, when the timing configuration information of the management terminal is obtained, performing difference detection based on the timing configuration information and the detection configuration table;

[0118] S63, when the record association information of the management terminal is obtained, a plurality of associated difference detection records are determined based on the record association information, and the plurality of associated difference detection records are combined into a combined detection record.

[0119] It should be noted that, according to the description of the above embodiment, the database management platform can record the difference detection records of historical construction. This embodiment can create a detection configuration interface in the management terminal, and apply the difference detection records in the detection configuration interface to improve the flexibility of difference detection.

[0120] It should be noted that, in this embodiment, different difference detection records can be configured on a time basis in the detection configuration interface, so that a difference detection is automatically performed on a time basis according to the detection configuration table of the difference detection record, thereby ensuring timely synchronization of data.

[0121] For example, Figure 4 As shown, in order to ensure the accuracy of property management fees, you can set timing configuration information for the difference detection record with the exception description information "property management fee data anomaly". For example, the timing configuration information is set to XX day XX time of each month to ensure that a difference detection can be performed when the property management fees are calculated each month to ensure the accuracy of the property management fees.

[0122] It should be noted that, in addition to performing timing configuration, this embodiment can also associate multiple difference detection records to obtain a combined detection record, that is, merge the detection configuration tables recorded in the difference detection records to improve the configuration flexibility of the difference detection.

[0123] For example, Figure 4 As shown, based on the difference detection record with the exception description information of "property management fee data anomaly", the difference detection record with the exception description information of "query data prompts permission error" is further selected, and the target object of the record is permission information. The merged detection configuration table records the table structure, table data, index information and permission information, ensuring that after the difference detection based on the combined detection record, there will be no difference between the target database and the source database in the table structure, table data, index information and permission information dimensions.

[0124] like Figure 5 As shown, Figure 5 : is a structural diagram of a database synchronization device based on difference detection provided by an embodiment of the present invention. The present invention also provides a database synchronization device based on difference detection, including:

[0125] The processor 501 may be implemented by a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;

[0126] The memory 502 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 502 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 502, and the processor 501 calls and executes the database synchronization method based on difference detection in the embodiment of this application;

[0127] Input / output interface 503, used to implement information input and output;

[0128] Communication interface 504, used to realize communication interaction between the device and other devices, which can be realized through wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);

[0129] A bus 505 that transmits information between various components of the device (e.g., the processor 501, the memory 502, the input / output interface 503, and the communication interface 505);

[0130] The processor 501 , the memory 502 , the input / output interface 503 and the communication interface 504 are connected to each other in communication within the device via the bus 505 .

[0131] An embodiment of the present application also provides an electronic device, including the database synchronization device based on difference detection as described above.

[0132] An embodiment of the present application further provides a storage medium, which is a computer-readable storage medium and stores a computer program. When the computer program is executed by a processor, the above-mentioned database synchronization method based on difference detection is implemented.

[0133] As a non-transient computer-readable storage medium, the memory can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage devices. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. The device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and are implemented to be located in one place, or may also be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.

[0134] It will be appreciated by those skilled in the art that all or some of the steps and systems in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or transient medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically include computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

[0135] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the above-mentioned implementation mode. Technical personnel familiar with the field can also make various equivalent deformations or substitutions under the shared conditions without violating the spirit of the present invention. These equivalent deformations or substitutions are all included in the scope defined by the claims of the present invention.

Claims

1. A database synchronization method based on difference detection, characterized in that: Applied to a database management platform, the database management platform is in communication connection with a source database, a target database, and a management terminal, the method comprising: When a difference detection request sent by the management terminal is obtained, multiple candidate objects are pushed to the management terminal, and a detection configuration table and abnormal description information fed back by the management terminal are obtained, wherein the candidate objects are database objects of the source database, the object types of the candidate objects are different from each other, and the detection configuration table records at least one target object selected by the management terminal; Generate a target query statement for each target object based on the detection configuration table, obtain first object information from the source database according to the target query statement, obtain second object information from the target database, and determine a difference detection result according to the first object information and the second object information, wherein the first object information and the second object information are used to indicate a data structure, object data or object definition of the target object; When at least one difference object is determined based on the difference detection result, a reference style statement is constructed based on the difference detection result and the difference object, and a target update statement is obtained by filling the reference style statement based on the first object information; Sending the target update statement to the target database for execution, and creating a difference detection record based on the exception description information and the detection configuration table; Before pushing the multiple candidate objects to the management terminal, the method further includes: Pushing a database list to the management terminal, wherein the database list includes multiple business databases, each of which belongs to a different business system; Acquire the target database selected by the management terminal from the database list, and determine the source database associated with the target database; Sending a preset reference query statement to the source database and the target database, and acquiring the candidate object of the source database when the first reference information fed back by the source database and the second reference information fed back by the target database are simultaneously acquired; Sending first prompt information to the management terminal so that the management terminal builds a visualization interface, wherein the first prompt information is used to indicate that the connection check between the source database and the target database has passed, and the visualization interface is used to display the candidate object and input the exception description information; After creating the difference detection record based on the abnormal description information and the detection configuration table, the method further includes: When a new difference detection request is obtained, a historical record set is pushed to the management terminal, wherein the historical record set includes at least one previously generated difference detection record; When the management terminal selects a target detection record from the historical record set, a difference detection is re-run based on the detection configuration table recorded in the target detection record; When the management terminal does not select the target detection record, pushing the candidate object to the management terminal; After creating the difference detection record based on the abnormal description information and the detection configuration table, the method further includes: Sending the difference detection record to the management terminal so that the management terminal creates a detection configuration interface, wherein the detection configuration interface is used to configure associated operations of the difference detection record; When the timing configuration information of the management terminal is obtained, performing difference detection based on the timing configuration information and the detection configuration table; Alternatively, when the record association information of the management terminal is acquired, a plurality of associated difference detection records are determined based on the record association information, and the plurality of associated difference detection records are combined into a combined detection record.

2. The database synchronization method based on difference detection according to claim 1, characterized in that: The pushing of multiple candidate objects to the management terminal and obtaining the detection configuration table fed back by the management terminal includes: Building an object tree based on the multiple candidate objects, wherein the candidate objects are root nodes of the object tree; When the candidate object includes multiple optional fields, determining the optional fields as child nodes of the corresponding candidate object; Pushing the object tree to the management terminal so that the management terminal displays the object tree on the visualization interface; The detection configuration table fed back by the management terminal is obtained, wherein, when the selected candidate object does not include the sub-node, the candidate object is determined as the target object, or, when the selected candidate object includes the sub-node, the target object is constructed based on the candidate object and the selected sub-node.

3. The database synchronization method based on difference detection according to claim 2, characterized in that: The generating of target query statements for each target object based on the detection configuration table includes: When the object type of the target object is a table structure or index information, determining the system table of the source database or the target database as a target query table of the target query statement, and determining the table structure or the index information as a query object of the target query statement; Alternatively, when the object type of the target object is table data, the database table to which the table data belongs is determined as the target query table, and the primary key or code value corresponding to the table data is determined as the query object of the target query statement; Alternatively, when the object type of the target object is permission information, the system table or permission table of the source database or the target database is determined as the target query table, and the user permissions recorded in the target query table are determined as the query object of the target query statement; Alternatively, when the object type of the target object is a stored procedure or a trigger, the definition statement of the target object is determined as the query object of the target query statement.

4. The database synchronization method based on difference detection according to claim 1, characterized in that: The constructing a reference style statement based on the difference detection result and the difference object, and filling the reference style statement based on the first object information to obtain a target update statement includes: According to the difference detection result, determining a target keyword from an update keyword library of the difference object, wherein each candidate object is preset with the update keyword library, the update keyword library includes a plurality of available operation keywords, and the available operation keywords are used to indicate adding, deleting, modifying or authorizing; Determine a target data table for recording the difference object, and construct the reference style statement according to the target data table and the target keyword, wherein the reference style statement includes a data bit, a table unit, and a field bit, the data bit and the field bit are empty, and the table unit records the target data table; Determine difference data and difference fields based on the first object information of the difference object, fill the difference data into the data bits of the reference style statement, fill the difference fields into the field bits of the reference style statement, and determine the filled reference style statement as the target update statement.

5. A database synchronization device based on difference detection, characterized in that: It includes at least one control processor and a memory for communicating with the at least one control processor; the memory stores instructions that can be executed by the at least one control processor, and the instructions are executed by the at least one control processor to enable the at least one control processor to execute the database synchronization method based on difference detection as described in any one of claims 1 to 4.

6. An electronic device, characterized in that: Including the database synchronization device based on difference detection as described in claim 5.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the database synchronization method based on difference detection as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Visual database change statement generation method and device and storage medium

    CN111274263A

  • Hierarchical data synchronization method and device, electronic equipment and readable medium

    CN115577040A

  • Resource data updating method and device and electronic equipment

    CN117609254A