[go: up one dir, main page]

CN116910021B - Database replacement method, device, computer equipment and storage medium - Google Patents

Database replacement method, device, computer equipment and storage medium

Info

Publication number
CN116910021B
CN116910021B CN202310718565.2A CN202310718565A CN116910021B CN 116910021 B CN116910021 B CN 116910021B CN 202310718565 A CN202310718565 A CN 202310718565A CN 116910021 B CN116910021 B CN 116910021B
Authority
CN
China
Prior art keywords
data
target
replacement
database
state
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310718565.2A
Other languages
Chinese (zh)
Other versions
CN116910021A (en
Inventor
王英杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202310718565.2A priority Critical patent/CN116910021B/en
Publication of CN116910021A publication Critical patent/CN116910021A/en
Application granted granted Critical
Publication of CN116910021B publication Critical patent/CN116910021B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/214Database migration support
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to the technical field of data processing and provides a database replacement method, a device, computer equipment and a storage medium, which comprise the steps of obtaining an original database and determining a data replacement stage corresponding to the original database; the method comprises the steps of determining whether to call a target component package according to a data replacement stage, determining target data replacement configuration information and target replacement monitoring configuration information in the target component package when the target component package is determined to be called according to the data replacement stage, replacing an original database with the target database according to the target data replacement configuration information, monitoring whether first data in the original database are consistent with second data in the target database according to the target replacement monitoring configuration information, and determining that the database replacement is completed when the monitoring result is that the first data are consistent with the second data. According to the method, the original database and the target database are subjected to data processing, so that the efficiency of database replacement can be improved, and the rapid development of smart cities is promoted.

Description

Database replacement method, device, computer equipment and storage medium
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a database replacing method, a database replacing device, a computer device, and a storage medium.
Background
Databases are the primary tools for data storage, are widely used in various industries, are one of the infrastructures in the field of data information, and particularly in the medical field, can be used for storing data such as personal health records, prescriptions, inspection reports and the like. The mainstream databases currently used are mostly databases developed by foreign companies, such as MySQL, SQLserver. With the advance of autonomous and controllable and domestic substitution, databases serving as infrastructure in the information field are gradually replaced with domestic databases. Because the data in the database is stored in a specific format, the format of the data needs to be adjusted when the data is migrated between databases of different standards.
In the process of realizing the method, the applicant finds that the prior art has the following problems that the prior database replacement method processes the data to be migrated in the service by using codes and then stores the processed data into the database, but the service code quantity is larger, the logic is complex and the database replacement efficiency is low.
Therefore, it is necessary to provide a database replacement method capable of improving the efficiency of database replacement.
Disclosure of Invention
In view of the foregoing, there is a need for a database replacement method, a database replacement apparatus, a computer device, and a storage medium that can improve the efficiency of database replacement.
An embodiment of the present application provides a database replacement method, where the database replacement method includes:
Acquiring an original database and determining a data replacement stage corresponding to the original database;
Determining whether to call a target component package according to the data replacement stage;
When the target component package is determined to be called according to the data replacement stage, determining target data replacement configuration information and target replacement monitoring configuration information in the target component package;
Replacing the original database with a target database according to the target data replacement configuration information;
monitoring whether the first data in the original database is consistent with the second data in the target database according to the target replacement monitoring configuration information;
And when the monitoring result is that the first data is consistent with the second data, determining that the database replacement is completed.
Further, in the above database replacement method provided by the embodiment of the present application, the determining a data replacement stage corresponding to the original database includes:
Acquiring a database read-write path;
Analyzing the database read-write path to obtain a first writing state and a first reading state of the original database, and a second writing state and a second reading state of the target database;
combining the first writing state and the first reading state to obtain a first target data reading and writing state;
Combining the second writing state and the second reading state to obtain a second target data reading and writing state;
And traversing the mapping relation between the preset target data read-write state and the data replacement stage to obtain the data replacement stage corresponding to the first target data read-write state and the second target data read-write state.
Further, in the above database replacing method provided by the embodiment of the present application, traversing the mapping relationship between the preset target data read-write state and the data replacing stage to obtain a data replacing stage corresponding to the first target data read-write state and the second target data read-write state, where the data replacing stage includes:
when the first writing state and the first reading state in the first target data reading and writing state are both non-empty and the second writing state and the second reading state in the second target data reading and writing state are both empty, determining that the original database is in a first data replacement stage;
When the first writing state and the first reading state in the first target data reading and writing state are both non-empty, and the second writing state in the second target data reading and writing state is non-empty, and the second reading state is empty, determining that the original database is in a second data replacement stage;
when the first writing state in the first target data reading and writing state is non-empty, the first reading state is empty, and the second writing state and the second reading state in the second target data reading and writing state are both non-empty, determining that the original database is in a third data replacement stage;
And when the first writing state and the first reading state in the first target data reading and writing state are empty and the second writing state and the second reading state in the second target data reading and writing state are non-empty, determining that the original database is in a fourth data replacement stage.
Further, in the above database replacing method provided by the embodiment of the present application, the determining whether to call the target component package according to the data replacing stage includes:
determining a target data replacement stage corresponding to the target component package;
Detecting whether a data replacement stage of the original database is the target data replacement stage;
when the data replacement stage of the original database is the target data replacement stage, determining to call the target component package;
And when the data replacement stage of the original database is not the target data replacement stage, determining not to call the target component package.
Further, in the above database replacement method provided by the embodiment of the present application, the determining the target data replacement configuration information and the target replacement monitoring configuration information in the target component package includes:
Acquiring a preset data replacement configuration keyword and a preset replacement monitoring configuration keyword in the target component package;
obtaining target data replacement configuration information according to the preset data replacement configuration keywords and a first preset data format of the data replacement configuration information;
and obtaining target replacement monitoring configuration information according to the preset replacement monitoring configuration keywords and a second preset data format of the replacement monitoring configuration information.
Further, in the above database replacement method provided by the embodiment of the present application, the replacing the original database with the target database according to the target data replacement configuration information includes:
acquiring a plurality of first data items corresponding to the original database;
determining that each of the first data items corresponds to a second data item within the target database;
analyzing the target data replacement configuration information to obtain a first data item format corresponding to the first data item and a second data item format corresponding to the second data item;
replacing the first data item format with the second data item format to effect replacement of the original database with the target database.
Further, in the above database replacement method provided by the embodiment of the present application, the monitoring, according to the target replacement monitoring configuration information, whether the first data in the original database is consistent with the second data in the target database includes:
Extracting first data from the original database and extracting second data from the target database according to the target replacement monitoring configuration information;
Respectively adjusting the first data and the second data into a target data format to obtain target first data and target second data;
detecting whether the target first data is consistent with the target second data;
when the target first data is consistent with the target second data, determining that the first data in the original database is consistent with the second data in the target database;
And when the target first data is inconsistent with the target second data, determining that the first data in the original database is inconsistent with the second data in the target database.
The second aspect of the embodiment of the present application further provides a database replacing apparatus, where the database replacing apparatus includes:
the phase determining module is used for acquiring an original database and determining a data replacement phase corresponding to the original database;
The call determining module is used for determining whether to call a target component package according to the data replacement stage;
the information determining module is used for determining target data replacement configuration information and target replacement monitoring configuration information in the target component package when the target component package is determined to be called according to the data replacement stage;
the database replacement module is used for replacing the original database with a target database according to the target data replacement configuration information;
The replacement monitoring module is used for monitoring whether the first data in the original database are consistent with the second data in the target database according to the target replacement monitoring configuration information;
And the replacement completion module is used for determining that the database replacement is completed when the monitoring result is that the first data is consistent with the second data.
A third aspect of the embodiment of the present application further provides a computer device, the computer device including a processor configured to implement a database replacement method as described in any one of the above when executing a computer program stored in a memory.
The fourth aspect of the embodiment of the present application further provides a computer readable storage medium, where a computer program is stored, where the computer program is executed by a processor to implement any one of the database replacing methods described above.
According to the database replacement method, the database replacement device, the computer equipment and the computer readable storage medium, whether the target component package is called is determined according to the data replacement stage of the original database, invalid calling of the target component package can be avoided by distinguishing the replacement stage from the original database, and further data migration efficiency is improved. The intelligent city intelligent management system can be applied to various functional modules of intelligent cities such as intelligent government affairs, intelligent transportation, intelligent medical treatment and the like, such as a database replacement module of intelligent medical treatment and the like, and can promote the rapid development of the intelligent cities.
Drawings
FIG. 1 is a flow chart of a database replacement method according to an embodiment of the present application.
FIG. 2 is a flow chart of a data replacement phase determination provided by an embodiment of the present application.
FIG. 3 is a flow chart illustrating the determination of a target package according to one embodiment of the present application.
Fig. 4 is a flowchart illustrating configuration information determination according to an embodiment of the present application.
FIG. 5 is a flow chart of a database replacement determination provided by an embodiment of the present application.
Fig. 6 is a block diagram of a database replacing apparatus according to an embodiment of the present application.
Fig. 7 is a schematic structural diagram of a computer device according to an embodiment of the present application.
The application will be further described in the following detailed description in conjunction with the above-described figures.
Detailed Description
In order that the above-recited objects, features and advantages of the present application will be more clearly understood, a more particular description of the application will be rendered by reference to specific embodiments thereof which are illustrated in the appended drawings. It should be noted that, without conflict, the embodiments of the present application and features in the embodiments may be combined with each other.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application, the described embodiments are examples of some, but not all, embodiments of the application.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein in the description of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application.
The embodiment of the application can acquire and process the related data based on the artificial intelligence technology. Wherein artificial intelligence (ARTIFICIAL INTELLIGENCE, AI) is the theory, method, technique, and application system that uses a digital computer or a digital computer-controlled machine to simulate, extend, and expand human intelligence, sense the environment, acquire knowledge, and use knowledge to obtain optimal results.
Artificial intelligence infrastructure technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and other directions.
The database replacement method provided by the embodiment of the application is executed by the computer equipment, and correspondingly, the database replacement device is operated in the computer equipment. FIG. 1 is a flow chart of a database replacement method according to an embodiment of the present application. As shown in fig. 1, the database replacement method may include the following steps, the order of the steps in the flowchart may be changed according to different needs, and some may be omitted.
S11, acquiring an original database, and determining a data replacement stage corresponding to the original database.
In at least one embodiment of the present application, the primary database refers to a preset database for storing a large amount of data, and the type of the primary database is not limited, for example, the primary database may be an Oracle database. With the advance of autonomous and controllable and domestic substitution, databases serving as infrastructure in the information field are gradually replaced with domestic databases. The data replacement stage refers to a stage of migrating data in the original database to a target database, where the target database may be a custom domestic database, and is not limited herein. In one embodiment, the data replacement phase may be divided into 4 phases, where there are cases where the target component package need not be invoked. According to the embodiment of the application, whether the target component package is called is determined according to the data replacement stage where the original database is located, and invalid calling of the target component package can be avoided by distinguishing the replacement stage from the original database, so that the efficiency of data migration is improved.
In one possible implementation, the data stored in the primary database and the target database is medical data, such as personal health records, prescriptions, exam reports, and the like.
The data replacement phase determination flow provided by the embodiment of the present application is described with reference to fig. 2. Optionally, the determining a data replacement stage corresponding to the original database includes:
S111, acquiring a database read-write path.
In an embodiment, the database read-write path refers to a read path and a write path of data in the original database and the target database, respectively. The database read-write paths may include paths for reading data and writing data in the original database and paths for reading data and writing data in the target database. The database read-write path can be obtained by presetting a read-write path monitoring process, for example, a read-write path monitoring process is created in advance, and the read-write path monitoring process is called to monitor the write path of new data and the read path of data.
S112, analyzing the database read-write path to obtain a first writing state and a first reading state of the original database, and a second writing state and a second reading state of the target database.
In an embodiment, the first writing state refers to a state of writing new data into the original database, and the first reading state refers to a state of reading data in the original database. The first writing state can comprise a null state and a non-null state, when the first writing state is null, new data is determined not to be written into the original database, and when the first writing state is non-null, new data is determined to be written into the original database. The first reading state can comprise a null state and a non-null state, when the first reading state is null, the data in the original database is determined not to be read, and when the first reading state is non-null, the data in the original database is determined to be read.
In an embodiment, the second writing state refers to a state of writing new data into the target database, and the second reading state refers to a state of reading data in the target database. The second writing state can comprise a null state and a non-null state, when the second writing state is null, new data is determined not to be written into the target database, and when the second writing state is non-null, new data is determined to be written into the target database. The second read state may include a null state and a non-null state, and when the second read state is null, it is determined that the data in the target database is not read, and when the second read state is non-null, it is determined that the data in the target database is read.
S113, combining the first writing state and the first reading state to obtain a first target data reading and writing state.
In an embodiment, the first writing state and the first reading state are combined according to a specific data format to obtain a first target data reading and writing state. The specific data format may be set according to actual requirements, and is not limited herein.
S114, combining the second writing state and the second reading state to obtain a second target data reading and writing state.
In an embodiment, the second writing state and the second reading state are combined according to a specific data format to obtain a second target data reading and writing state. The specific data format may be set according to actual requirements, and is not limited herein.
And S115, traversing the mapping relation between the preset target data read-write state and the data replacement stage to obtain the data replacement stage corresponding to the first target data read-write state and the second target data read-write state. In an embodiment, the target data read-write state includes a first target data read-write state and a second target data read-write state, and a mapping relationship between the target data read-write state and a data replacement stage is preset, so that the data replacement stage can be obtained.
Optionally, traversing the mapping relationship between the preset target data read-write state and the data replacement stage to obtain a data replacement stage corresponding to the first target data read-write state and the second target data read-write state, where the data replacement stage includes:
S1131, when the first writing state and the first reading state in the first target data reading and writing state are both non-empty, and the second writing state and the second reading state in the second target data reading and writing state are both empty, determining that the original database is in a first data replacement stage.
In an embodiment, the first data replacement phase indicates that migration of data within the original database into the target database has not been initiated.
S1132, when the first writing state and the first reading state in the first target data reading and writing state are both non-empty, and the second writing state in the second target data reading and writing state is non-empty, and the second reading state is empty, determining that the original database is in a second data replacement stage.
In an embodiment, the second data replacement stage indicates that migration of the data in the original database into the target database is currently started, and at this time, the data in the original database and the data in the target database need to be compared to ensure consistency of the data.
S1133, when the first writing state is not empty in the first target data reading and writing state, the first reading state is empty, and the second writing state and the second reading state in the second target data reading and writing state are both not empty, determining that the original database is in a third data replacement stage.
In an embodiment, the third data replacement stage indicates that the data in the original database has been completely migrated into the target database, where the original database is only used as a safe backup of the data, and when the performance or reliability of the target database does not reach the standard, the data is guaranteed not to be lost to the greatest extent.
S1134, when the first writing state and the first reading state in the first target data reading and writing state are both empty, and the second writing state and the second reading state in the second target data reading and writing state are both non-empty, determining that the original database is in a fourth data replacement stage.
In an embodiment, the fourth data replacement phase indicates that the original database is not already needed to run at this time.
S12, determining whether to call a target component package according to the data replacement stage.
In at least one embodiment of the present application, the target component package is a preset common component package for performing data migration and monitoring on the original database and the target database. It can be appreciated that the target component package need not be invoked when the data replacement phase is a first data replacement phase and a fourth data replacement phase, and the target component package need be invoked when the data replacement phase is a second data replacement phase and a third data replacement phase. In an embodiment, a target component package may be set for the second data replacement stage and the third data replacement stage, where the contents of the target component package may be the same or different. In another embodiment, a unified targeted component package is provided for the second data replacement stage and the third data replacement stage. The embodiment of the application is illustrated by taking the example that different data replacement stages share a unified target component package.
In some embodiments, when it is determined that the target component package does not need to be called, the method further comprises determining a data replacement stage corresponding to the current moment, returning to step S11 until the target component package needs to be called when the data replacement stage is a first data replacement stage, and finishing the current flow when the data replacement stage is a fourth data replacement stage and completing database replacement without running the original database.
The determination flow of the target component package provided by the embodiment of the application is described with reference to fig. 3. Optionally, the determining whether to call the target component package according to the data replacement stage includes:
S121, determining to call a target data replacement stage corresponding to the target component package.
In an embodiment, the target data replacement stage is a second data replacement stage and a third data replacement stage.
S122, detecting whether the data replacement stage of the original database is the target data replacement stage.
S123, when the data replacement stage of the original database is the target data replacement stage, determining to call the target component package.
S124, when the data replacement stage of the original database is not the target data replacement stage, determining not to call the target component package.
And S13, when the target component package is determined to be called according to the data replacement stage, determining target data replacement configuration information and target replacement monitoring configuration information in the target component package.
In at least one embodiment of the present application, the target component package includes target data replacement configuration information and target replacement monitoring configuration information. The target data replacement configuration information is used for migrating the data in the original database into the target database. In an embodiment, the target replacement monitoring configuration information is used to monitor whether the data in the original database is consistent with the data in the target database. In other embodiments, the target replacement monitoring configuration information is further used to monitor whether an abnormality exists in the operation of the target database in the data migration process.
The determination flow of the configuration information provided by the embodiment of the present application is described with reference to fig. 4. Optionally, the determining the target data replacement configuration information and the target replacement monitoring configuration information in the target component package includes:
S131, obtaining preset data replacement configuration keywords and preset replacement monitoring configuration keywords in the target component package.
In an embodiment, the preset data replacement configuration keyword is preset for identifying the target data replacement configuration information, and the preset replacement monitoring configuration keyword is preset for identifying the target replacement configuration information.
S132, obtaining target data replacement configuration information according to the preset data replacement configuration keywords and the first preset data format of the data replacement configuration information.
In an embodiment, the first preset data format is a preset data format of the preset data replacement configuration keyword and the target data replacement configuration information, for example, the first preset data format may be { preset data replacement configuration keyword, data replacement configuration information }.
S133, obtaining target replacement monitoring configuration information according to the preset replacement monitoring configuration keywords and a second preset data format of the replacement monitoring configuration information.
In an embodiment, the second preset data format is a preset data format of the preset replacement monitoring configuration keyword and the replacement monitoring configuration information, for example, the first preset data format may be { preset replacement monitoring configuration keyword, replacement monitoring configuration information }.
S14, replacing the original database with the target database according to the target data replacement configuration information.
In at least one embodiment of the present application, the data in the original database and the target database are stored in a specific format, so that the format of the data needs to be adjusted when data migration is performed between the original database and the target database in different formats. The target data replacement configuration information comprises a plurality of first data items in the original database, a first data item format corresponding to each first data item, a plurality of second data items in the target database, a second data item format corresponding to each second data item and a replacement code for replacing the first data item format with the second data item format. The first data items may include data items such as a mobile phone number, a certificate number, a home address, a bank card, and the like of the user, and for each first data item in the original database, a second data item corresponding to the first data item is present in the target database.
A flowchart for determining database replacement provided by an embodiment of the present application is described in conjunction with fig. 5. Optionally, the replacing the original database with the target database according to the target data replacement configuration information includes:
S141, acquiring a plurality of first data items corresponding to the original database.
In an embodiment, the original database includes a plurality of first data items, each of the first data items has a corresponding first data item keyword, and the plurality of first data items corresponding to the original database can be obtained by querying the first data item keyword.
S142, determining that each first data item corresponds to a second data item in the target database.
In an embodiment, the target database includes a plurality of second data items, each of the second data items has a corresponding relationship with the first data item, and the second data item in the target database corresponding to each of the first data items can be obtained by querying the corresponding relationship. The correspondence may be stored at a target node in the blockchain in view of reliability and privacy of data storage.
S143, analyzing the target data replacement configuration information to obtain a first data item format corresponding to the first data item and a second data item format corresponding to the second data item.
In an embodiment, the target data replacement configuration information includes a first data item format corresponding to the first data item, a second data item format corresponding to the second data item, and a replacement code for replacing the first data item format with the second data item format.
S144, replacing the first data item format with the second data item format to realize replacement of the original database with the target database.
In an embodiment, the replacement of the first data item format with the second data item format according to the replacement code is performed to effect the replacement of the original database with the target database.
And S15, monitoring whether the first data in the original database is consistent with the second data in the target database according to the target replacement monitoring configuration information.
In at least one embodiment of the present application, during the data replacement process of the original database and the target database, the data replacement process needs to be monitored to ensure the accuracy of data replacement. In an embodiment, the target replacement monitoring configuration information is used to monitor whether the data in the original database is consistent with the data in the target database.
Optionally, the monitoring whether the first data in the original database is consistent with the second data in the target database according to the target replacement monitoring configuration information includes:
And S151, respectively extracting first data from the original database and second data from the target database according to the target replacement monitoring configuration information.
In an embodiment, the target replacement monitoring configuration information includes a data consistency detection algorithm, where the data consistency detection algorithm is configured to detect whether first data extracted from the original database is consistent with second data extracted from the target database, determine that data replacement is normal when the first data is consistent with the second data, and complete when the first data is inconsistent with the second data, and determine that data replacement is abnormal. In an embodiment, the selection manner of the first data and the second data may be random selection, or may be selection according to a preset data interval, which is not limited herein.
S152, respectively adjusting the first data and the second data into a target data format to obtain target first data and target second data.
In an embodiment, the first data is stored according to a specific data item format in the original database, the second data is stored according to a specific data format in the target database, and the first data and the second data can be adjusted to the target data format when the first data and the second data are subjected to data coincidence detection.
S153, detecting whether the target first data is consistent with the target second data.
And S154, when the target first data is consistent with the target second data, determining that the first data in the original database is consistent with the second data in the target database.
Illustratively, when the first data is 2022, 10 month, 01 and the second data is 2022/10/01, it is known that the target first data is consistent with the target second data by converting the data into the target data format 20221001.
And S155, when the target first data is inconsistent with the target second data, determining that the first data in the original database is inconsistent with the second data in the target database.
Illustratively, when the first data is 2022, 10 month 01 and the second data is 2022/10/02, the data is converted into a target data format, the target first data is 20221001, the target second data is 20221002, and the target first data is inconsistent with the target second data.
In other embodiments, the target replacement monitoring configuration information is further used to monitor whether an abnormality exists in the operation of the target database in the data replacement process. The target replacement monitoring configuration information comprises a target database operation detection algorithm, and the target database operation detection algorithm can be set according to actual service requirements without limitation. For example, the target database operation detection algorithm is configured to detect whether the data response time of the target database is a preset time response threshold, and determine that an abnormality exists in operation of the target database when the data response time of the target database exceeds the preset time response threshold. The preset time response threshold is a preset time value.
And S16, when the monitoring result is that the first data is consistent with the second data, determining that the database replacement is completed.
In at least one embodiment of the present application, when the monitoring result is that the first data is consistent with the second data, it is determined that the database replacement is completed. When the monitoring result is that the first data is inconsistent with the second data, determining that the database replacement is abnormal, and analyzing the abnormal replacement.
According to the database replacement method provided by the embodiment of the application, whether the target component package is called is determined according to the data replacement stage of the original database, invalid calling of the target component package can be avoided by distinguishing the replacement stage from the original database, and further the data migration efficiency is improved. The intelligent city intelligent management system can be applied to various functional modules of intelligent cities such as intelligent government affairs, intelligent traffic and the like, such as a database replacement module of the intelligent city and the like, and can promote the rapid development of the intelligent city.
Referring to fig. 6, fig. 6 is a block diagram of a database replacing apparatus according to an embodiment of the application.
In some embodiments, the database replacement apparatus 20 may include a plurality of functional modules comprised of computer program segments. The computer program of the individual program segments in the database replacing means 20 may be stored in a memory of a computer device and executed by at least one processor to perform (see fig. 1 for details) the functions of database replacement.
In this embodiment, the database replacing apparatus 20 may be divided into a plurality of functional modules according to the functions performed by the database replacing apparatus. The functional modules may include a phase determination module 201, a call determination module 202, an information determination module 203, a database replacement module 204, a replacement monitoring module 205, and a replacement completion module 206. The module referred to in the present application refers to a series of computer program segments capable of being executed by at least one processor and of performing a fixed function, stored in a memory. In the present embodiment, the functions of the respective modules will be described in detail in the following embodiments.
The stage determining module 201 may be configured to obtain an original database and determine a data replacement stage corresponding to the original database.
The call determination module 202 may be configured to determine whether to call a target component package based on the data replacement phase.
The information determining module 203 may be configured to determine target data replacement configuration information and target replacement monitoring configuration information in the target component package when determining to invoke the target component package according to the data replacement phase.
The database replacement module 204 may be configured to replace the original database with a target database according to the target data replacement configuration information.
The replacement monitoring module 205 may be configured to monitor whether the first data in the original database is consistent with the second data in the target database according to the target replacement monitoring configuration information.
The replacement completion module 206 may be configured to determine that the database replacement is complete when the monitoring result indicates that the first data is consistent with the second data.
In at least one embodiment of the present application, the stage determining module 201 may be further configured to obtain a database read-write path, analyze the database read-write path to obtain a first writing state and a first reading state of the original database, and a second writing state and a second reading state of the target database, combine the first writing state and the first reading state to obtain a first target data read-write state, combine the second writing state and the second reading state to obtain a second target data read-write state, and traverse a mapping relationship between a preset target data read-write state and a data replacement stage to obtain a data replacement stage corresponding to the first target data read-write state and the second target data read-write state.
In at least one embodiment of the present application, the stage determining module 201 may be further configured to determine that the original database is in a first data replacement stage when the first writing state and the first reading state in the first target data writing state are both non-empty and the second writing state and the second reading state in the second target data writing state are both empty, determine that the original database is in a second data replacement stage when the first writing state and the first reading state in the first target data writing state are both non-empty and the second writing state in the second target data writing state are both non-empty and the second reading state is both empty and determine that the original database is in the second data replacement stage when the first writing state and the first reading state in the first target data writing state are both non-empty and the second reading state are both non-empty, and determine that the first writing state and the second reading state in the second target data writing state are both non-empty and the first reading state and the second reading state are both non-empty.
In at least one embodiment of the present application, the call determining module 202 may be further configured to determine to call a target data replacement stage corresponding to the target component package, detect whether the data replacement stage of the original database is the target data replacement stage, determine to call the target component package when the detection result is that the data replacement stage of the original database is the target data replacement stage, and determine not to call the target component package when the detection result is that the data replacement stage of the original database is not the target data replacement stage.
In at least one embodiment of the present application, the information determining module 203 may be further configured to obtain a preset data replacement configuration keyword and a preset replacement monitoring configuration keyword in the target component package, obtain target data replacement configuration information according to a preset first preset data format of the preset data replacement configuration keyword and the data replacement configuration information, and obtain target replacement monitoring configuration information according to a preset second preset data format of the preset replacement monitoring configuration keyword and the replacement monitoring configuration information.
In at least one embodiment of the present application, the database replacing module 204 may be further configured to obtain a plurality of first data items corresponding to the original database, determine that each first data item corresponds to a second data item in the target database, parse the target data replacement configuration information to obtain a first data item format corresponding to the first data item and a second data item format corresponding to the second data item, and replace the first data item format with the second data item format to replace the original database with the target database.
In at least one embodiment of the present application, the replacement monitoring module 205 may be further configured to extract first data from the original database and extract second data from the target database according to the target replacement monitoring configuration information, respectively, adjust the first data and the second data to target data formats to obtain target first data and target second data, detect whether the target first data and the target second data are consistent, determine that the first data in the original database is consistent with the second data in the target database when the target first data and the target second data are consistent, and determine that the first data in the original database is inconsistent with the second data in the target database when the target first data and the target second data are inconsistent.
Fig. 7 is a schematic structural diagram of a computer device according to an embodiment of the application. In the preferred embodiment of the present application, the computer device 3 includes a memory 31, at least one processor 32, at least one communication bus 33, and a transceiver 34.
It will be appreciated by those skilled in the art that the configuration of the computer device shown in fig. 7 is not limiting of the embodiments of the present application, and that either a bus-type configuration or a star-type configuration is possible, and that the computer device 3 may include more or less other hardware or software than that shown, or a different arrangement of components.
In some embodiments, the computer device 3 is a device capable of automatically performing numerical calculation and/or information processing according to preset or stored instructions, and its hardware includes, but is not limited to, a microprocessor, an application specific integrated circuit, a programmable gate array, a digital processor, an embedded device, and the like. The computer device 3 may also include a client device, which includes, but is not limited to, any electronic product that can interact with a client by way of a keyboard, mouse, remote control, touch pad, or voice control device, such as a personal computer, tablet, smart phone, digital camera, etc.
It should be noted that the computer device 3 is only used as an example, and other electronic products that may be present in the present application or may be present in the future are also included in the scope of the present application by way of reference.
In some embodiments, the memory 31 has stored therein a computer program which, when executed by the at least one processor 32, performs all or part of the steps of the database replacement method as described. The Memory 31 includes Read-Only Memory (ROM), programmable Read-Only Memory (Programmable Read-Only Memory, PROM), erasable programmable Read-Only Memory (Erasable Programmable Read-Only Memory, EPROM), one-time programmable Read-Only Memory (OTPROM), electrically erasable rewritable Read-Only Memory (EEPROM), compact disc Read-Only Memory (Compact Disc Read-Only Memory, CD-ROM) or other optical disc Memory, magnetic tape Memory, or any other medium that can be used for carrying or storing data.
Further, the computer readable storage medium may mainly include a storage program area, which may store an operating system, an application program required for at least one function, and the like, and a storage data area, which may store data created according to the use of the blockchain node, and the like.
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm and the like. The blockchain (Blockchain), essentially a de-centralized database, is a string of data blocks that are generated in association using cryptographic methods, each of which contains information from a batch of network transactions for verifying the validity (anti-counterfeit) of its information and generating the next block. The blockchain may include a blockchain underlying platform, a platform product services layer, an application services layer, and the like.
In some embodiments, the at least one processor 32 is a Control Unit (Control Unit) of the computer device 3, connects the various components of the entire computer device 3 using various interfaces and lines, and performs various functions and processes of the computer device 3 by running or executing programs or modules stored in the memory 31, and invoking data stored in the memory 31. For example, the at least one processor 32, when executing the computer program stored in the memory, implements all or part of the steps of the database replacement method described in embodiments of the present application, or implements all or part of the functions of the database replacement apparatus. The at least one processor 32 may be comprised of integrated circuits, such as a single packaged integrated circuit, or may be comprised of multiple integrated circuits packaged with the same or different functionality, including one or more central processing units (Central Processing unit, CPU), microprocessors, digital processing chips, graphics processors, combinations of various control chips, and the like.
In some embodiments, the at least one communication bus 33 is arranged to enable connected communication between the memory 31 and the at least one processor 32 or the like.
Although not shown, the computer device 3 may further comprise a power source (such as a battery) for powering the various components, preferably the power source is logically connected to the at least one processor 32 via a power management means, whereby the functions of managing charging, discharging, and power consumption are performed by the power management means. The power supply may also include one or more of any of a direct current or alternating current power supply, recharging device, power failure detection circuit, power converter or inverter, power status indicator, etc. The computer device 3 may further include various sensors, bluetooth modules, wi-Fi modules, etc., which will not be described in detail herein.
The integrated units implemented in the form of software functional modules described above may be stored in a computer readable storage medium. The software functional modules described above are stored in a storage medium and include instructions for causing a computer device (which may be a personal computer, a computer device, or a network device, etc.) or processor (processor) to perform portions of the methods described in the various embodiments of the application.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical function division, and there may be other manners of division when actually implemented.
The modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical units, may be located in one place, or may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional module in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units can be realized in a form of hardware or a form of hardware and a form of software functional modules.
It will be evident to those skilled in the art that the application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential characteristics thereof. The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it will be obvious that the term "comprising" does not exclude other elements or that the singular does not exclude a plurality. Several of the elements or devices recited in the specification may be embodied by one and the same item of software or hardware. The terms first, second, etc. are used to denote a name, but not any particular order.
Finally, it should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the present application and not for limiting the same, and although the present application has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications and equivalents may be made to the technical solution of the present application without departing from the spirit and scope of the technical solution of the present application.

Claims (9)

1. A database replacement method, the database replacement method comprising:
The method comprises the steps of obtaining an original database, determining a data replacement stage corresponding to the original database, obtaining a database read-write path, analyzing the database read-write path to obtain a first writing state and a first reading state of the original database, and a second writing state and a second reading state of a target database, combining the first writing state and the first reading state to obtain a first target data read-write state, combining the second writing state and the second reading state to obtain a second target data read-write state, traversing a mapping relation between a preset target data read-write state and a data replacement stage to obtain a data replacement stage corresponding to the first target data read-write state and the second target data read-write state;
Determining whether to call a target component package according to the data replacement stage;
When the target component package is determined to be called according to the data replacement stage, determining target data replacement configuration information and target replacement monitoring configuration information in the target component package;
Replacing the original database with the target database according to the target data replacement configuration information;
monitoring whether the first data in the original database is consistent with the second data in the target database according to the target replacement monitoring configuration information;
And when the monitoring result is that the first data is consistent with the second data, determining that the database replacement is completed.
2. The database replacing method according to claim 1, wherein traversing the mapping relationship between the preset target data read-write state and the data replacing stage to obtain the data replacing stage corresponding to the first target data read-write state and the second target data read-write state includes:
when the first writing state and the first reading state in the first target data reading and writing state are both non-empty and the second writing state and the second reading state in the second target data reading and writing state are both empty, determining that the original database is in a first data replacement stage;
When the first writing state and the first reading state in the first target data reading and writing state are both non-empty, and the second writing state in the second target data reading and writing state is non-empty, and the second reading state is empty, determining that the original database is in a second data replacement stage;
when the first writing state in the first target data reading and writing state is non-empty, the first reading state is empty, and the second writing state and the second reading state in the second target data reading and writing state are both non-empty, determining that the original database is in a third data replacement stage;
And when the first writing state and the first reading state in the first target data reading and writing state are empty and the second writing state and the second reading state in the second target data reading and writing state are non-empty, determining that the original database is in a fourth data replacement stage.
3. The database replacement method according to claim 1, wherein the determining whether to invoke the target component package according to the data replacement phase comprises:
determining a target data replacement stage corresponding to the target component package;
Detecting whether a data replacement stage of the original database is a target data replacement stage;
when the data replacement stage of the original database is the target data replacement stage, determining to call the target component package;
And when the data replacement stage of the original database is not the target data replacement stage, determining not to call the target component package.
4. The database replacement method according to claim 1, wherein determining target data replacement configuration information and target replacement monitoring configuration information in the target component package comprises:
Acquiring a preset data replacement configuration keyword and a preset replacement monitoring configuration keyword in the target component package;
obtaining target data replacement configuration information according to the preset data replacement configuration keywords and a first preset data format of the data replacement configuration information;
and obtaining target replacement monitoring configuration information according to the preset replacement monitoring configuration keywords and a second preset data format of the replacement monitoring configuration information.
5. The database replacement method according to claim 1, wherein the replacing the original database with the target database according to the target data replacement configuration information comprises:
acquiring a plurality of first data items corresponding to the original database;
determining that each of the first data items corresponds to a second data item within the target database;
analyzing the target data replacement configuration information to obtain a first data item format corresponding to the first data item and a second data item format corresponding to the second data item;
replacing the first data item format with the second data item format to effect replacement of the original database with the target database.
6. The database replacement method according to claim 1, wherein the monitoring whether the first data in the original database and the second data in the target database are consistent according to the target replacement monitoring configuration information comprises:
Extracting first data from the original database and extracting second data from the target database according to the target replacement monitoring configuration information;
Respectively adjusting the first data and the second data into a target data format to obtain target first data and target second data;
detecting whether the target first data is consistent with the target second data;
when the target first data is consistent with the target second data, determining that the first data in the original database is consistent with the second data in the target database;
And when the target first data is inconsistent with the target second data, determining that the first data in the original database is inconsistent with the second data in the target database.
7. A database replacement apparatus for performing the database replacement method according to any one of claims 1 to 6, characterized in that the database replacement apparatus comprises:
the phase determining module is used for acquiring an original database and determining a data replacement phase corresponding to the original database;
The call determining module is used for determining whether to call a target component package according to the data replacement stage;
the information determining module is used for determining target data replacement configuration information and target replacement monitoring configuration information in the target component package when the target component package is determined to be called according to the data replacement stage;
the database replacement module is used for replacing the original database with a target database according to the target data replacement configuration information;
The replacement monitoring module is used for monitoring whether the first data in the original database are consistent with the second data in the target database according to the target replacement monitoring configuration information;
And the replacement completion module is used for determining that the database replacement is completed when the monitoring result is that the first data is consistent with the second data.
8. A computer device, characterized in that it comprises a processor for implementing the database replacement method according to any of claims 1 to 6 when executing a computer program stored in a memory.
9. A computer readable storage medium having stored thereon a computer program, which when executed by a processor implements a database replacement method according to any of claims 1 to 6.
CN202310718565.2A 2023-06-15 2023-06-15 Database replacement method, device, computer equipment and storage medium Active CN116910021B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310718565.2A CN116910021B (en) 2023-06-15 2023-06-15 Database replacement method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310718565.2A CN116910021B (en) 2023-06-15 2023-06-15 Database replacement method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN116910021A CN116910021A (en) 2023-10-20
CN116910021B true CN116910021B (en) 2025-09-16

Family

ID=88363779

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310718565.2A Active CN116910021B (en) 2023-06-15 2023-06-15 Database replacement method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116910021B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107133244A (en) * 2016-02-29 2017-09-05 阿里巴巴集团控股有限公司 The method of testing and device of a kind of database migration
CN112948529A (en) * 2021-03-31 2021-06-11 中国建设银行股份有限公司 Dynamic text reading and writing method and device, electronic equipment and medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10210232B2 (en) * 2014-10-01 2019-02-19 SkyKick, Inc. Automated staged data migration
US9927992B2 (en) * 2016-08-19 2018-03-27 Sap Se Segmented database migration
US11042517B2 (en) * 2019-06-07 2021-06-22 Sap Se Online migration of database systems
CN112860666B (en) * 2021-02-08 2024-06-18 土巴兔集团股份有限公司 Data migration method, device, computer equipment and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107133244A (en) * 2016-02-29 2017-09-05 阿里巴巴集团控股有限公司 The method of testing and device of a kind of database migration
CN112948529A (en) * 2021-03-31 2021-06-11 中国建设银行股份有限公司 Dynamic text reading and writing method and device, electronic equipment and medium

Also Published As

Publication number Publication date
CN116910021A (en) 2023-10-20

Similar Documents

Publication Publication Date Title
CA3046247C (en) Data platform for automated data extraction, transformation, and/or loading
US20130262140A1 (en) Patient cohort matching
CN112559535B (en) Multithreading-based asynchronous task processing method, device, equipment and medium
CN111651452B (en) Data storage method, device, computer equipment and storage medium
CN115061895B (en) Business process arrangement method, device, electronic device and storage medium
CN114969261B (en) Data query method and device based on artificial intelligence, electronic equipment and medium
CN116755987A (en) Buried point index processing method, buried point index processing device, computer equipment and storage medium
Chen An empirical study of a hybrid imbalanced-class DT-RST classification procedure to elucidate therapeutic effects in uremia patients
CN114881616A (en) Business process execution method and device, electronic equipment and storage medium
CN113870974A (en) Risk prediction method and device based on artificial intelligence, electronic equipment and medium
CN117194382A (en) Middle-stage data processing method and device, electronic equipment and storage medium
CN114220541B (en) Disease prediction method, device, electronic device and storage medium
CN114201212B (en) Configuration file processing method, device, computer equipment and storage medium
CN112948480B (en) Data extraction method, device, electronic equipment and storage medium
CN116910021B (en) Database replacement method, device, computer equipment and storage medium
CN114547696A (en) File desensitization method and device, electronic equipment and storage medium
CN114239538B (en) Assertion processing method, device, computer equipment and storage medium
CN116976896A (en) Transaction order restoration method, device, computer equipment and storage medium
CN114416695B (en) Data splicing function migration method, device, computer equipment and storage medium
CN114119203B (en) Resource management and control method and device based on artificial intelligence, electronic equipment and medium
CN115146078A (en) Index data processing method, device, computer equipment and storage medium
CN115101152A (en) Sample priority switching method, device, equipment and medium
CN114090324A (en) Virtual desktop performance detection method and device, electronic equipment and storage medium
CN114664458A (en) Patient classification device, computer equipment and storage medium
CN117034302A (en) Data encryption method, device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant