SQL file migration method, device, storage medium and equipment
By receiving migration instructions input by the user and obtaining file name information of the target SQL file, the file is migrated to the corresponding database based on the database information in the file name, solving the problem of time-consuming update of multiple database SQL files and achieving efficient SQL File update.
Patent Information
- Application Number
- CN201910913195.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-25
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2039-09-25
AI Technical Summary
During product development, the SQL file update process of multiple databases is cumbersome and takes a long time, which requires developers to invest a lot of energy and time.
Provides a SQL file migration method, which obtains the target SQL file and its file name information by receiving migration instructions input by the user, and migrates the file to the corresponding database according to the database information in the file name, so as to realize SQL file updates between different databases.
This greatly improves the efficiency of SQL file updates, solves the problem of time-consuming updates of multiple databases, and realizes efficient updates of SQL files in different databases.
Smart Images

Figure CN112559444B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a SQL file migration method, device, storage medium and equipment. Background Art
[0002] During product development and release, due to changes in product business requirements and other reasons, the product development process often involves changes in structured query language (SQL) files such as changes in table structure, adding new tables, and correcting data. Especially when multiple databases are involved, it is necessary to update the SQL files in multiple databases, which is very cumbersome and requires developers to invest a lot of energy and time, and is relatively time-consuming. Summary of the invention
[0003] The purpose of the present disclosure is to provide a SQL file migration method, apparatus, storage medium and device to solve the problem of time-consuming updating of SQL files in multiple databases.
[0004] In order to solve the above problem, the present disclosure provides a SQL file migration method in a first aspect, including:
[0005] Receive migration instructions input by the user;
[0006] According to the migration instruction, a target SQL file to be migrated and file name information of the target SQL file are obtained, wherein the target SQL file is any SQL file stored in the SQL file repository, and the file name information of the target SQL file includes database information to which the target SQL file is to be migrated;
[0007] If it is determined that the migration condition is met, the target SQL file is migrated to the database corresponding to the database information.
[0008] Optionally, the method further includes:
[0009] Receive the SQL file to be stored and the database information to which the SQL file to be stored is to be migrated, which is input by the user;
[0010] Generate identification information and timestamp information of the SQL file to be stored;
[0011] Generate file name information of the SQL file to be stored according to the identification information, the timestamp information and the database information, wherein the file name information of the SQL file to be stored includes the identification information, the timestamp information and the database information;
[0012] The SQL file to be stored and the corresponding file name information are stored in the SQL file storage repository.
[0013] Optionally, the migration instruction includes file type information and time information; the file name information of the SQL file stored in the SQL file repository includes at least timestamp information of the SQL file;
[0014] The step of obtaining the target SQL file to be migrated and the file name information of the target SQL file according to the migration instruction includes:
[0015] The SQL file repository is queried according to the time information and the file type information to obtain the target SQL file and the file name information of the target SQL file, wherein the timestamp information included in the file name information of the target SQL file matches the time information, and the file type of the target SQL file matches the file type information.
[0016] Optionally, the method further includes:
[0017] According to the file name information of the target SQL file, query whether the target SQL file exists in the database;
[0018] If the target SQL file does not exist in the database, or if the target SQL file exists in the database but the migration status information of the target SQL file indicates that the migration has failed, it is determined that the migration condition is met.
[0019] Optionally, the method further includes:
[0020] Execute the target SQL file;
[0021] Verify the file name information of the target SQL file;
[0022] If the target SQL file is successfully executed and the file name information of the target SQL file passes the verification, it is determined that the migration condition is met.
[0023] A second aspect of the present disclosure provides a SQL file migration device, comprising:
[0024] A migration instruction unit, used for receiving a migration instruction input by a user;
[0025] An SQL file acquisition unit, configured to acquire a target SQL file to be migrated and file name information of the target SQL file according to the migration instruction, wherein the target SQL file is any SQL file stored in the SQL file repository, and the file name information of the target SQL file includes database information to which the target SQL file is to be migrated;
[0026] The SQL file migration unit is used to migrate the target SQL file to the database corresponding to the database information if it is determined that the migration condition is met.
[0027] Optionally, the device further comprises:
[0028] An SQL file receiving unit, configured to receive an SQL file to be stored input by a user and database information to which the SQL file to be stored is to be migrated;
[0029] An identification information generating unit, used to generate identification information and timestamp information of the SQL file to be stored;
[0030] a file name information generating unit, configured to generate the file name information of the SQL file to be stored according to the identification information, the timestamp information and the database information, wherein the file name information of the SQL file to be stored includes the identification information, the timestamp information and the database information;
[0031] The SQL file storage unit is used to store the SQL file to be stored and the corresponding file name information in the SQL file storage repository.
[0032] Optionally, the migration instruction includes file type information and time information; the file name information of the SQL file stored in the SQL file repository includes at least timestamp information of the SQL file;
[0033] The SQL file acquisition unit is used for:
[0034] The SQL file repository is queried according to the time information and the file type information to obtain the target SQL file and the file name information of the target SQL file, wherein the timestamp information included in the file name information of the target SQL file matches the time information, and the file type of the target SQL file matches the file type information.
[0035] Optionally, the device further comprises:
[0036] An SQL file query unit, configured to query whether the target SQL file exists in the database according to the file name information of the target SQL file;
[0037] The SQL file migration unit is configured to determine that a migration condition is met if the target SQL file does not exist in the database, or if the target SQL file exists in the database but the migration status information of the target SQL file indicates that the migration has failed.
[0038] Optionally, the device further comprises:
[0039] An SQL file execution unit, used for executing the target SQL file;
[0040] A file name information verification unit, used to verify the file name information of the target SQL file;
[0041] The SQL file migration unit is used to determine that a migration condition is met if the target SQL file is successfully executed and the file name information of the target SQL file passes verification.
[0042] A third aspect of the present disclosure provides a storage medium having a program stored thereon, and the program, when executed by a processor, performs the steps of any one of the methods described in the first aspect.
[0043] A fourth aspect of the present disclosure provides a device, the device comprising:
[0044] At least one processor, and at least one memory and bus connected to the processor;
[0045] Wherein, the processor and the memory communicate with each other through the bus;
[0046] The processor is used to call the program instructions in the memory to execute the steps of any one of the methods described in the first aspect.
[0047] Through the above technical solution, when it is determined that the migration conditions are met, the target SQL file can be migrated to the database corresponding to the database information according to the database information in the file name information of the target SQL file. When the database information in the file name information of the target SQL file corresponds to different databases, the target SQL file can be migrated to different databases and the SQL files in different databases can be updated, which solves the problem of time-consuming updating of SQL files in multiple databases and greatly improves efficiency.
[0048] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:
[0050] Figure 1 It is a flowchart of a SQL file migration method according to an embodiment of the present disclosure;
[0051] Figure 2 It is a flowchart of another SQL file migration method according to an embodiment of the present disclosure;
[0052] Figure 3 A block diagram of an SQL file migration device according to an embodiment of the present disclosure;
[0053] Figure 4 is a block diagram of another SQL file migration device according to an embodiment of the present disclosure;
[0054] Figure 5 The present invention is a block diagram of a device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0055] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described here is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.
[0056] Figure 1 FIG. 1 is a flow chart of a SQL file migration method according to an embodiment of the present disclosure. Figure 1 As shown, the method includes:
[0057] S101, receiving a migration instruction input by a user;
[0058] Optionally, the migration instruction input by the user includes file type information and time information of the SQL file to be migrated.
[0059] S102. According to the migration instruction, obtain a target SQL file to be migrated and file name information of the target SQL file, wherein the target SQL file is any SQL file stored in the SQL file repository, and the file name information of the target SQL file includes database information to which the target SQL file is to be migrated.
[0060] In this embodiment, the SQL file repository stores multiple SQL files to be migrated, and the file name information of each SQL file includes the database information to which the SQL file is to be migrated and timestamp information. The database information can be the name or code of the database, and the timestamp information can be the development cycle of the SQL file, that is, the start time of the iteration cycle of the SQL file.
[0061] After receiving the migration instruction input by the user, the SQL file repository can be queried according to the time information and file type information included in the migration instruction to obtain the target SQL file and the file name information of the target SQL file, wherein the timestamp information included in the file name information of the target SQL file matches the time information, and the file type of the target SQL file matches the file type information.
[0062] Exemplarily, if the timestamp information included in the file name information of the target SQL file is the same as the time information included in the migration instruction, then the timestamp information matches the time information included in the migration instruction; if the file type of the target SQL file is the same as the file type represented by the file type information included in the migration instruction, then the file type matches the file type information.
[0063] For example, the migration instruction input by the user is rel_20190823, where rel is the file type information, indicating that the file type of the target SQL file to be migrated is a test type. 20190823 is the time information of the migration instruction, indicating that the timestamp information of the target SQL file to be migrated is 20190823.
[0064] Further, according to the migration instruction, the SQL file repository is queried to obtain a target SQL file whose file name information in the SQL file repository includes timestamp information of 20190823 and whose file type is a test type. The database corresponding to the database information in the file name information of the target SQL file can be database 1 with a database name of A, database 2 with a database name of B, or database 3 with a database name of C, which is not limited in this embodiment.
[0065] S103: If it is determined that the migration condition is met, the target SQL file is migrated to the database corresponding to the database information.
[0066] After obtaining the target SQL file whose timestamp information included in the file name information in the SQL file repository is 20190823 and whose file type is a test type, if it is determined that the migration conditions are met, the target SQL file corresponding to the file name information corresponding to different database information is migrated to the database corresponding to the database information. For example, when the database name in the file name information of the target SQL file is A, the target SQL file is migrated to database 1 to update the SQL file in database 1. When the database name in the file name information of the target SQL file is B, the target SQL file is migrated to database 2 to update the SQL file in database 2. When the database name in the file name information of the target SQL file is C, the target SQL file is migrated to database 3 to update the SQL file in database 3. When the database information in the file name information of the target SQL file corresponds to different databases, the target SQL file is migrated to different databases, and the SQL files in different databases are updated.
[0067] By adopting the above scheme, when it is determined that the migration conditions are met, the target SQL file can be migrated to the database corresponding to the database information according to the database information in the file name information of the target SQL file. When the database information in the file name information of the target SQL file corresponds to different databases, the target SQL file can be migrated to different databases and the SQL files in different databases can be updated, which solves the problem of time-consuming updating of SQL files in multiple databases and greatly improves efficiency.
[0068] Combine the following Figure 2 The SQL file migration method provided by the present disclosure is further described in detail in the embodiment.
[0069] Figure 2 Based on Figure 1 The flowchart of another SQL file migration method shown in the embodiment. Figure 2 As shown, the method includes:
[0070] S201, receiving the SQL file to be stored and the database information to which the SQL file to be stored is to be migrated, which is input by the user;
[0071] In this embodiment, the file type of the SQL file to be stored input by the user includes a test type and a production type, wherein the SQL file with the test type is applied to the test environment, and the SQL file with the production type is applied to the production environment.
[0072] In this embodiment, the database information input by the user may be a database name, for example, database name A of database 1, database name B of database 2, or database name C of database 3, which is not limited in this embodiment.
[0073] S202: Generate identification information and timestamp information of the SQL file to be stored.
[0074] Further, after receiving the SQL file to be stored input by the user, the identification information and timestamp information of the SQL file to be stored are generated. The timestamp information can be the development cycle of the SQL file, that is, the start time of the iteration cycle of the SQL file. The identification information can be the serial number of the SQL file to be stored, which is used to identify the SQL file to be stored.
[0075] In this embodiment, the serial number of the SQL file can be generated from Redis through a Python script. Redis is a high-performance distributed storage system that supports the storage of more types of data and more operations on the data.
[0076] In this embodiment, after receiving the SQL file to be stored input by the user, other description information of the SQL file to be stored may also be generated, such as the function, purpose and creator information of the SQL file to be stored.
[0077] S203. Generate file name information of the SQL file to be stored according to the identification information, the timestamp information and the database information, wherein the file name information of the SQL file to be stored includes the identification information, the timestamp information and the database information.
[0078] In one embodiment, the identification information, the timestamp information and the database information constitute the file name information of the SQL file to be stored. For example, in this embodiment, the format of the file name information of the SQL file to be stored is:
[0079] V[Iteration cycle start time]_[Serial number]__[Database name].sql
[0080] In addition, the identification information, the timestamp information and the database information also constitute the version information of the SQL file to be stored. For example, in this embodiment, the format of the version information of the SQL file to be stored is:
[0081] V[Iteration cycle start time]_[Sequence number]__[Database name]
[0082] In another embodiment, the identification information, the timestamp information, the database information and other descriptive information constitute the file name information of the SQL file to be stored. Among them, the identification information, the timestamp information and the database information constitute the version information of the SQL file to be stored. For example, in this embodiment, the format of the file name information of the SQL file to be stored is:
[0083] V[Iteration cycle start time]_[Serial number]__[Database name]_[Other description information].sql
[0084] The format of the version information of the SQL file to be stored is:
[0085] V[Iteration cycle start time]_[Sequence number]__[Database name]
[0086] Further, after the file name information of the SQL file to be stored is generated, the content and file name information of the SQL file are checked to see if they are standard. If it is determined that the content and file name information of the SQL file are both standard, S204 is executed.
[0087] In this embodiment, the Python script is used to check whether the content and file name information of the SQL file to be stored are standardized. Exemplarily, the Python script is used to check whether the SQL file to be stored has comment information to determine the standardization of the content of the SQL file. For example, if a statement in the SQL file to be stored is checked by the Python script and there is no corresponding comment information, then the statement is not standardized, and the user is prompted to add comment information for the statement.
[0088] Exemplarily, the Python script is used to check whether the file name information of the SQL file to be stored is complete to determine whether the file name information of the SQL file to be stored is standardized. For example, if the Python script checks that there is no database information in the file name information of the SQL file to be stored, the file name information of the SQL file is not standardized, and the user is prompted to enter the database information. The processing method for the non-standard file name information caused by other situations, such as the non-standard file name information caused by the absence of timestamp information in the file name information, is similar to this, and this embodiment will not be repeated here.
[0089] If it is determined that the content and / or file name information of the SQL file to be stored is not standardized, the user is prompted to modify the content and / or file name information of the SQL file to be stored.
[0090] By generating the identification information and generating the version information in the file name information according to the identification information, the problem of version information conflict in the file name information of the SQL file can be avoided.
[0091] S204: Store the SQL file to be stored and the corresponding file name information in the SQL file storage repository.
[0092] Exemplarily, if it is determined that the content and file name information of the SQL file are standardized, the SQL file to be stored and the corresponding file name information are stored in the SQL file repository. Exemplarily, the SQL file repository can be a version management system, such as a distributed version management system Git. Git is an open source distributed version control system that can effectively and quickly process and manage SQL files.
[0093] S205, receiving a migration instruction input by a user;
[0094] S206. According to the migration instruction, obtain the target SQL file to be migrated and the file name information of the target SQL file, wherein the target SQL file is any SQL file stored in the SQL file repository, and the file name information of the target SQL file includes the database information to which the target SQL file is to be migrated.
[0095] S205 and S206 provided in this embodiment are Figure 1 S101 and S102 provided in the embodiment are similar and will not be described in detail in this embodiment.
[0096] S207, executing the target SQL file;
[0097] S208: Verify the file name information of the target SQL file.
[0098] In this embodiment, after obtaining the target SQL file to be migrated and the file name information of the target SQL file, the target SQL file is executed and the file name information of the target SQL file is verified. The target SQL file is executed to ensure that each SQL statement in the SQL file can be successfully executed, and the file name information is verified to ensure the standardization of the file name information.
[0099] S209: If the target SQL file is successfully executed and the file name information of the target SQL file passes verification, it is determined that the migration condition is met.
[0100] If it is determined that the target SQL file fails to execute and / or the file name information verification fails, it is determined that the migration condition is not met, and the user is prompted to modify the target SQL file and / or the file name information.
[0101] In this embodiment, the target SQL file can be executed by a Python script, and the file name information of the target SQL file can be verified. For example, when some statements of the target SQL file fail to be executed by a Python script, a prompt message indicating that the statement execution failed will be displayed, prompting the user to modify the statement.
[0102] For example, when the file name information of the target SQL file is verified through a Python script, if the database information in the file name information of the target SQL file is wrong and causes the file name information verification to fail, a prompt message of the database information error will be displayed to prompt the user to modify the database information. The processing method for the file name information verification failure caused by other situations, such as the file name information verification failure caused by the timestamp information, is similar to this, and this embodiment will not be repeated here.
[0103] S210: If it is determined that the migration condition is met, the target SQL file is migrated to the database corresponding to the database information.
[0104] In another embodiment, it is also possible to query whether the target SQL file exists in the database based on the file name information of the target SQL file; if the target SQL file does not exist in the database, or the target SQL file exists in the database but the migration status information of the target SQL file is migration failure, it is determined that the migration conditions are met, and the target SQL file is migrated to the database corresponding to the database information to update the SQL file of the database.
[0105] In another embodiment, if the target SQL file is successfully executed and the file name information of the target SQL file passes the verification, the database is queried based on the file name information of the target SQL file whether the target SQL file exists; if the target SQL file does not exist in the database, or the target SQL file exists in the database but the migration status information of the target SQL file is migration failure, it is determined that the migration conditions are met, and the target SQL file is migrated to the database corresponding to the database information to update the SQL file of the database.
[0106] In the present disclosure, the target SQL file can be migrated to the database corresponding to the database information, for example, by Flyway. Flyway is an open source database version management tool that can manage and track database changes independently of the application, and can achieve SQL file migration without complex configuration.
[0107] Exemplarily, when the user inputs database name A of database 1, file name information is generated according to database name A. If it is determined that the migration condition is met, the target SQL file is migrated to database 1 according to database name A in the file name information, and the SQL file in database 1 is updated; when the user inputs database name B of database 2, file name information is generated according to database name B. If it is determined that the migration condition is met, the target SQL file is migrated to database 2 according to database name B in the file name information, and the SQL file in database 2 is updated; when the user inputs database name C of database 3, file name information is generated according to database name C. If it is determined that the migration condition is met, the target SQL file is migrated to database 3 according to database name C in the file name information, and the SQL file in database 3 is updated. When the user inputs different database information, the target SQL file is migrated to the database corresponding to the different database information, and the SQL files in different databases are updated, which solves the problem of time-consuming updating of SQL files in multiple databases and greatly improves efficiency.
[0108] Furthermore, by querying whether the target SQL file exists in the database corresponding to the database information, repeated migration of SQL files and repeated updates of SQL files in the database can be avoided, further improving efficiency.
[0109] By adopting the above scheme, by generating the identification information and generating the version information in the file name information according to the identification information, the problem of version information conflict in the file name information of the SQL file can be avoided. In addition, the user can input different database information and generate the file name information according to the database information. When it is determined that the migration condition is met, the target SQL file is migrated to the database corresponding to the database information according to the database information in the file name information, so as to realize the migration of the target SQL file to different databases and update the SQL files in different databases, thus solving the problem of time-consuming updating of SQL files in multiple databases and greatly improving the efficiency.
[0110] Figure 3 FIG. 1 is a block diagram of a SQL file migration device according to an embodiment of the present disclosure. Figure 3 As shown, the device 30 includes:
[0111] The migration instruction receiving unit 301 is used to receive the migration instruction input by the user;
[0112] The SQL file acquisition unit 302 is used to acquire a target SQL file to be migrated and file name information of the target SQL file according to the migration instruction, wherein the target SQL file is any SQL file stored in the SQL file storage repository, and the file name information of the target SQL file includes database information to which the target SQL file is to be migrated;
[0113] The SQL file migration unit 303 is used to migrate the target SQL file to the database corresponding to the database information if it is determined that the migration condition is met.
[0114] Optionally, Figure 4 is based on Figure 3 The embodiment shown is a block diagram of a SQL file migration device, such as Figure 4 As shown, the device 30 also includes:
[0115] The SQL file receiving unit 304 is used to receive the SQL file to be stored and the database information to which the SQL file to be stored is to be migrated, which is input by the user;
[0116] An identification information generating unit 305 is used to generate identification information and timestamp information of the SQL file to be stored;
[0117] A file name information generating unit 306, configured to generate the file name information of the SQL file to be stored according to the identification information, the timestamp information and the database information, wherein the file name information of the SQL file to be stored includes the identification information, the timestamp information and the database information;
[0118] The SQL file storage unit 307 is used to store the SQL file to be stored and the corresponding file name information in the SQL file storage repository.
[0119] Optionally, the migration instruction includes file type information and time information; the file name information of the SQL file stored in the SQL file repository includes at least timestamp information of the SQL file;
[0120] Optionally, the SQL file acquisition unit 302 is used to:
[0121] The SQL file repository is queried according to the time information and the file type information to obtain the target SQL file and the file name information of the target SQL file, wherein the timestamp information included in the file name information of the target SQL file matches the time information, and the file type of the target SQL file matches the file type information.
[0122] Optionally, the device 30 further includes:
[0123] An SQL file query unit 308 is used to query whether the target SQL file exists in the database according to the file name information of the target SQL file;
[0124] The SQL file migration unit 303 is used to determine that the migration condition is met if the target SQL file does not exist in the database, or if the target SQL file exists in the database but the migration status information of the target SQL file indicates that the migration has failed.
[0125] Optionally, the device 30 further includes:
[0126] SQL file execution unit 309, used to execute the target SQL file;
[0127] A file name information verification unit 310, used to verify the file name information of the target SQL file;
[0128] The SQL file migration unit 303 is further configured to determine that the migration condition is met if the target SQL file is successfully executed and the file name information of the target SQL file passes verification.
[0129] By adopting the above scheme, by generating the identification information and generating the version information in the file name information according to the identification information, the problem of version information conflict in the file name information of the SQL file can be avoided. In addition, the user can input different database information and generate the file name information according to the database information. When it is determined that the migration condition is met, the target SQL file is migrated to the database corresponding to the database information according to the database information in the file name information, so as to realize the migration of the target SQL file to different databases and update the SQL files in different databases, thus solving the problem of time-consuming updating of SQL files in multiple databases and greatly improving the efficiency.
[0130] Regarding the device in the above embodiment, the specific manner in which each unit performs the operation has been described in detail in the embodiment of the method, and will not be elaborated here.
[0131] The SQL file migration device includes a processor and a memory. The above-mentioned migration instruction unit, SQL file acquisition unit, SQL file migration unit, SQL file receiving unit, identification information generation unit and file name information generation unit are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.
[0132] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and the SQL files can be migrated to different databases and the SQL files in different databases can be updated by adjusting the kernel parameters.
[0133] An embodiment of the present invention provides a storage medium having a program stored thereon, which is executed by a processor to implement Figure 1 and Figure 2 The SQL file migration method described in the embodiment.
[0134] An embodiment of the present invention provides a processor, the processor is used to run a program, wherein when the program is run, Figure 1 and Figure 2 The SQL file migration method described in the embodiment.
[0135] An embodiment of the present invention provides a device, such as Figure 5 As shown, Figure 5This is a block diagram of a device according to an embodiment of the present disclosure, wherein the device 50 includes at least one processor 501, at least one memory 502 and a bus 503 connected to the processor 501; wherein the processor 501 and the memory 502 communicate with each other through the bus 503; the processor 501 is used to call the program instructions in the memory 502 to execute the above-mentioned SQL file migration method. The device in this article can be a server, a PC, a PAD, a mobile phone, etc.
[0136] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program for initializing the following method steps:
[0137] Receive migration instructions input by the user;
[0138] According to the migration instruction, a target SQL file to be migrated and file name information of the target SQL file are obtained, wherein the target SQL file is any SQL file stored in the SQL file repository, and the file name information of the target SQL file includes database information to which the target SQL file is to be migrated;
[0139] If it is determined that the migration condition is met, the target SQL file is migrated to the database corresponding to the database information.
[0140] Optionally, the method further includes:
[0141] Receive the SQL file to be stored and the database information to which the SQL file to be stored is to be migrated, which is input by the user;
[0142] Generate identification information and timestamp information of the SQL file to be stored;
[0143] Generate file name information of the SQL file to be stored according to the identification information, the timestamp information and the database information, wherein the file name information of the SQL file to be stored includes the identification information, the timestamp information and the database information;
[0144] The SQL file to be stored and the corresponding file name information are stored in the SQL file storage repository.
[0145] Optionally, the migration instruction includes file type information and time information; the file name information of the SQL file stored in the SQL file repository includes at least timestamp information of the SQL file;
[0146] The step of obtaining the target SQL file to be migrated and the file name information of the target SQL file according to the migration instruction includes:
[0147] The SQL file repository is queried according to the time information and the file type information to obtain the target SQL file and the file name information of the target SQL file, wherein the timestamp information included in the file name information of the target SQL file matches the time information, and the file type of the target SQL file matches the file type information.
[0148] Optionally, the method further includes:
[0149] According to the file name information of the target SQL file, query whether the target SQL file exists in the database;
[0150] If the target SQL file does not exist in the database, or if the target SQL file exists in the database but the migration status information of the target SQL file indicates that the migration has failed, it is determined that the migration condition is met.
[0151] Optionally, the method further includes:
[0152] Execute the target SQL file;
[0153] Verify the file name information of the target SQL file;
[0154] If the target SQL file is successfully executed and the file name information of the target SQL file passes the verification, it is determined that the migration condition is met.
[0155] The present application is described with reference to the flowcharts and / or block diagrams of the methods, apparatuses, devices, and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0156] In a typical configuration, the device includes one or more processors (CPU), memory and bus. The device may also include input / output interface, network interface and the like.
[0157] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip. The memory is an example of a computer-readable medium.
[0158] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0159] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0160] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0161] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A SQL file migration method, characterized in that: include: Receive migration instructions input by the user; According to the migration instruction, a target SQL file to be migrated and file name information of the target SQL file are obtained, wherein the target SQL file is any SQL file stored in the SQL file repository, and the file name information of the target SQL file includes database information to which the target SQL file is to be migrated; The migration instruction includes file type information and time information; the file name information of the SQL file stored in the SQL file repository includes at least the timestamp information of the SQL file; The step of obtaining the target SQL file to be migrated and the file name information of the target SQL file according to the migration instruction includes: querying the SQL file repository according to the time information and the file type information to obtain the target SQL file and the file name information of the target SQL file, wherein the timestamp information included in the file name information of the target SQL file matches the time information, and the file type of the target SQL file matches the file type information; If it is determined that the migration condition is met, migrating the target SQL file to the database corresponding to the database information; The method further comprises: Execute the target SQL file; Verify the file name information of the target SQL file; If the target SQL file is successfully executed and the file name information of the target SQL file passes the verification, it is determined that the migration condition is met; If it is determined that the target SQL file fails to be executed and / or the file name information verification fails, it is determined that the migration condition is not met, and the user is prompted to modify the target SQL file and / or the file name information.
2. The method according to claim 1, characterized in that The method further comprises: Receive the SQL file to be stored and the database information to which the SQL file to be stored is to be migrated, which is input by the user; Generate identification information and timestamp information of the SQL file to be stored; Generate file name information of the SQL file to be stored according to the identification information, the timestamp information and the database information, wherein the file name information of the SQL file to be stored includes the identification information, the timestamp information and the database information; The SQL file to be stored and the corresponding file name information are stored in the SQL file storage repository.
3. The method according to claim 1, characterized in that The method further comprises: According to the file name information of the target SQL file, query whether the target SQL file exists in the database; If the target SQL file does not exist in the database, or if the target SQL file exists in the database but the migration status information of the target SQL file indicates that the migration has failed, it is determined that the migration condition is met.
4. A SQL file migration device, characterized in that: include: A migration instruction unit, used for receiving a migration instruction input by a user; A SQL file acquisition unit is used to acquire, according to the migration instruction, a target SQL file to be migrated and file name information of the target SQL file, wherein the target SQL file is any SQL file stored in the SQL file repository, and the file name information of the target SQL file includes database information to which the target SQL file is to be migrated; the migration instruction includes file type information and time information; the file name information of the SQL file stored in the SQL file repository includes at least timestamp information of the SQL file; the SQL file acquisition unit is used to: query the SQL file repository according to the time information and the file type information to obtain the target SQL file and file name information of the target SQL file, wherein the timestamp information included in the file name information of the target SQL file matches the time information, and the file type of the target SQL file matches the file type information; A SQL file migration unit, configured to migrate the target SQL file to a database corresponding to the database information if it is determined that the migration condition is met; An SQL file execution unit, used for executing the target SQL file; A file name information verification unit, used to verify the file name information of the target SQL file; The SQL file migration unit is further configured to determine that a migration condition is satisfied if the target SQL file is successfully executed and the file name information of the target SQL file passes verification; The file name information verification unit is further configured to determine that the migration condition is not met if it is determined that the target SQL file fails to be executed and / or the file name information verification fails, and prompt the user to modify the target SQL file and / or the file name information.
5. The device according to claim 4, characterized in that The device also includes: An SQL file receiving unit, configured to receive an SQL file to be stored input by a user and database information to which the SQL file to be stored is to be migrated; An identification information generating unit, used to generate identification information and timestamp information of the SQL file to be stored; a file name information generating unit, configured to generate the file name information of the SQL file to be stored according to the identification information, the timestamp information and the database information, wherein the file name information of the SQL file to be stored includes the identification information, the timestamp information and the database information; The SQL file storage unit is used to store the SQL file to be stored and the corresponding file name information in the SQL file storage repository.
6. The device according to claim 4, characterized in that The device also includes: An SQL file query unit, configured to query whether the target SQL file exists in the database according to the file name information of the target SQL file; The SQL file migration unit is configured to determine that a migration condition is met if the target SQL file does not exist in the database, or if the target SQL file exists in the database but the migration status information of the target SQL file indicates that the migration has failed.
7. A storage medium having a program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 3 are implemented.
8. A device, characterized in that The device comprises: At least one processor, and at least one memory and bus connected to the processor; Wherein, the processor and the memory communicate with each other through the bus; The processor is used to call the program instructions in the memory to execute the steps of the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Data migration method and device
CN106874389A
Information query method and device, computer equipment and storage medium
CN108829765A