CN112559444A - SQL (structured query language) file migration method and device, storage medium and equipment - Google Patents

SQL (structured query language) file migration method and device, storage medium and equipment Download PDF

Info

Publication number
CN112559444A
CN112559444A CN201910913195.1A CN201910913195A CN112559444A CN 112559444 A CN112559444 A CN 112559444A CN 201910913195 A CN201910913195 A CN 201910913195A CN 112559444 A CN112559444 A CN 112559444A
Authority
CN
China
Prior art keywords
file
information
sql file
sql
target
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.)
Pending
Application number
CN201910913195.1A
Other languages
Chinese (zh)
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.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum Technology 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 Beijing Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201910913195.1A priority Critical patent/CN112559444A/en
Publication of CN112559444A publication Critical patent/CN112559444A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/119Details of migration of file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/14Details of searching files based on file metadata
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems

Landscapes

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

Abstract

The disclosure relates to a method, a device, a storage medium and equipment for migrating an SQL file, wherein the method comprises the following steps: receiving a migration instruction input by a user; acquiring 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 an SQL file storage library, and the file name information of the target SQL file comprises database information to which the target SQL file is to be migrated; if the migration condition is met, the target SQL file is migrated to the database corresponding to the database information, 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, the SQL files in different databases can be updated, the problem that the SQL files in a plurality of databases are time-consuming to update is solved, and the efficiency is greatly improved.

Description

SQL (structured query language) file migration method and device, storage medium and equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, a storage medium, and a device for migrating an SQL file.
Background
In the product development and product release processes, due to changes of product service requirements and other reasons, the product development process often involves changes of table structures, changes of newly added tables, changes of Structured Query Language (SQL) files such as corrected data and the like, and particularly when a plurality of databases are involved, SQL files in the plurality of databases need to be updated, which is very tedious, requires a developer to invest much effort and time, and is time-consuming.
Disclosure of Invention
The present disclosure aims to provide a method, an apparatus, a storage medium, and a device for migrating an SQL file, so as to solve the problem that time is consumed when the SQL file in a plurality of databases is updated.
In order to solve the above problem, a first aspect of the present disclosure provides an SQL file migration method, including:
receiving a migration instruction input by a user;
acquiring 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 an SQL file storage library, and the file name information of the target SQL file comprises database information to which the target SQL file is to be migrated;
and if the migration condition is determined to be met, migrating the target SQL file to a database corresponding to the database information.
Optionally, the method further includes:
receiving an SQL file to be stored and database information to which the SQL file to be stored is to be migrated, wherein the SQL file to be stored is input by a user;
generating identification information and timestamp information of the SQL file to be stored;
generating 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 comprises the identification information, the timestamp information and the database information;
and storing the SQL file to be stored and the corresponding file name information into the SQL file storage library.
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 at least comprises the timestamp information of the SQL file;
the acquiring the target SQL file to be migrated and the file name information of the target SQL file according to the migration instruction comprises the following steps:
and 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 is matched with the time information, and the file type of the target SQL file is matched with the file type information.
Optionally, the method further includes:
inquiring whether the target SQL file exists in the database or not according to the file name information of the target SQL file;
and if the target SQL file does not exist in the database, or the target SQL file exists in the database but the migration state information of the target SQL file is migration failure, determining that the migration condition is met.
Optionally, the method further includes:
executing the target SQL file;
checking the file name information of the target SQL file;
and if the target SQL file is successfully executed and the file name information of the target SQL file passes the verification, determining that the migration condition is met.
A second aspect of the present disclosure provides an SQL file migration apparatus, including:
the migration instruction unit is used for receiving a migration instruction input by a user;
the SQL file acquisition unit is used for acquiring 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 an SQL file storage library, and the file name information of the target SQL file comprises database information to which the target SQL file is to be migrated;
and the SQL file migration unit is used for migrating the target SQL file to a database corresponding to the database information if the migration condition is determined to be met.
Optionally, the apparatus further comprises:
the SQL file receiving unit is used for receiving an SQL file to be stored and database information to which the SQL file to be stored is to be migrated, which are input by a user;
the identification information generating unit is used for generating the identification information and the timestamp information of the SQL file to be stored;
a file name information generating unit, configured to generate file name information of the to-be-stored SQL file according to the identification information, the timestamp information, and the database information, where the file name information of the to-be-stored SQL file includes the identification information, the timestamp information, and the database information;
and the SQL file storage unit is used for storing the SQL file to be stored and the corresponding file name information into the SQL file storage library.
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 at least comprises the timestamp information of the SQL file;
the SQL file acquisition unit is used for:
and 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 is matched with the time information, and the file type of the target SQL file is matched with the file type information.
Optionally, the apparatus further comprises:
the SQL file query unit is used for querying whether the target SQL file exists in the database or not according to the file name information of the target SQL file;
the SQL file migration unit is used for determining that migration conditions are met if the target SQL file does not exist in the database or the target SQL file exists in the database but the migration state information of the target SQL file is migration failure.
Optionally, the apparatus further comprises:
the SQL file execution unit is used for executing the target SQL file;
the file name information checking unit is used for checking the file name information of the target SQL file;
the SQL file migration unit is used for determining 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 the verification.
A third aspect of the present disclosure provides a storage medium having stored thereon a program which, when executed by a processor, performs the steps of the method of any one of the first aspects.
A fourth aspect of the present disclosure provides an apparatus, comprising:
at least one processor, and at least one memory, bus connected with the processor;
the processor and the memory complete mutual communication through the bus;
the processor is configured to invoke program instructions in the memory to perform the steps of the method of any of the first aspects.
By the technical scheme, 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 migration condition is determined to be met, 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, the SQL files in different databases can be updated, the problem that the time consumption is long when the SQL files in a plurality of databases are updated is solved, and the efficiency is greatly improved.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure without limiting the disclosure. In the drawings:
FIG. 1 is a flow diagram illustrating a method of SQL file migration according to an embodiment of the disclosure;
FIG. 2 is a flow diagram illustrating another SQL file migration method according to an embodiment of the disclosure;
FIG. 3 is a block diagram illustrating an SQL file migration apparatus, according to an embodiment of the present disclosure;
FIG. 4 is a block diagram illustrating another SQL file migration apparatus, according to an embodiment of the present disclosure;
fig. 5 is a block diagram illustrating an apparatus according to an embodiment of the present disclosure.
Detailed Description
The following detailed description of specific embodiments of the present disclosure is provided in connection with the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present disclosure, are given by way of illustration and explanation only, not limitation.
Fig. 1 is a flowchart illustrating an SQL file migration method according to an embodiment of the present disclosure. As shown in fig. 1, the method includes:
s101, receiving a migration instruction input by a user;
optionally, the migration instruction input by the user includes file type information and time information of the SQL file to be migrated.
S102, according to the migration instruction, acquiring 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 an SQL file storage library, and the file name information of the target SQL file comprises database information to which the target SQL file is to be migrated.
In this embodiment, the SQL file repository stores a plurality of SQL files to be migrated, the filename information of each SQL file includes database information to be migrated to the SQL file and timestamp information, the database information may be a name or a code of the database, and the timestamp information may be a development cycle of the SQL file, that is, a start time of an iteration cycle of the SQL file.
After receiving a migration instruction input by a user, querying an SQL file repository according to time information and file type information included in the migration instruction to obtain the target SQL file and file name information of the target SQL file, where timestamp information included in the file name information of the target SQL file is matched with the time information, and a file type of the target SQL file is matched with the file type information.
Illustratively, 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, the timestamp information matches the time information included in the migration instruction; and if the file type of the target SQL file is the same as the file type represented by the file type information contained in the migration instruction, matching the file type with the file type information.
For example, the migration instruction input by the user is rel _20190823, rel is file type information, and indicates 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, and the timestamp information of the target SQL file to be migrated is 20190823.
Further, according to the migration instruction, the SQL file repository is queried, and the timestamp information included in the file name information in the SQL file repository is obtained as 20190823, and the file type is the target SQL file of the test type. The database corresponding to the database information in the file name information of the target SQL file may be the database 1 with the database name a, the database 2 with the database name B, or the database 3 with the database name C, which is not limited in this embodiment.
S103, if the migration condition is determined to be met, the target SQL file is migrated to a database corresponding to the database information.
After acquiring the target SQL file with the timestamp information of 20190823 and the test type of file name information included in the file name information of the SQL file repository, if it is determined that the migration condition is satisfied, migrating the target SQL file corresponding to the file name information corresponding to different database information 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 the database 1 to update the SQL file in the 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 the database 2 to update the SQL file in the 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 the database 3 to update the SQL file in the database 3. And when the database information in the file name information of the target SQL file corresponds to different databases, migrating the target SQL file to the different databases, and updating the SQL file in the different databases.
By adopting the scheme, 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 migration condition is determined to be met, 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, the SQL files in different databases can be updated, the problem that the time consumption is long when the SQL files in a plurality of databases are updated is solved, and the efficiency is greatly improved.
The SQL file migration method provided in the present disclosure is further described in detail below with reference to the embodiment of fig. 2.
FIG. 2 is a flowchart illustrating another SQL file migration method according to the embodiment of FIG. 1. As shown in fig. 2, the method includes:
s201, receiving an SQL file to be stored and database information to which the SQL file to be stored is to be migrated, wherein the SQL file to be stored is input by a user;
in this embodiment, the file type of the SQL file to be stored, which is input by the user, includes a test type and a production type. The SQL file with the file type as the test type is applied to the test environment, and the SQL file with the file type as the production type is applied to the production environment.
In this embodiment, the database information input by the user may be a database name, for example, a database name a of the database 1, a database name B of the database 2, or a database name C of the database 3, which is not limited in this embodiment.
S202, generating identification information and timestamp information of the SQL file to be stored.
Further, after receiving the SQL file to be stored input by the user, generating the identification information and the timestamp information of the SQL file to be stored. The timestamp information may be a development cycle of the SQL file, i.e., a start time of an iteration cycle of the SQL file. The identification information may be a serial number of the SQL file to be stored, and is used to identify the SQL file to be stored.
In this embodiment, the serial number of the SQL file may be generated from Redis by Python script. Redis is a high performance distributed storage system that supports the storage of more types of data, as well as richer operation on the data.
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 and the purpose of the SQL file to be stored, and creator information.
S203, generating 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 comprises the identification information, the timestamp information and the database information.
In one embodiment, the identification information, the timestamp information and the database information constitute 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 as follows:
v [ iteration cycle start time ] _ [ sequence number ] __ [ database name ]. sql
In addition, the identification information, the timestamp information and the database information are also configured as 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 as follows:
v [ iteration cycle start time ] _ [ sequence number ] __ [ database name ]
In another embodiment, the identification information, the timestamp information, the database information, and other description information constitute file name information of the SQL file to be stored. The identification information, the timestamp information and the database information constitute 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 as follows:
v [ iteration cycle start time ] _ [ sequence number ] __ [ database name ] _ [ other description information ]. sql
The format of the version information of the SQL file to be stored is as follows:
v [ iteration cycle start time ] _ [ sequence number ] __ [ database name ]
Further, after the file name information of the SQL file to be stored is generated, whether the content and the file name information of the SQL file are standard is checked. If the content and the file name information of the SQL file are determined to be both standard, S204 is executed.
In this embodiment, whether the content and the file name information of the SQL file to be stored are standard is checked through a Python script. Illustratively, the normalization of the content of the SQL file is determined by checking whether the SQL file to be stored has annotation information through a Python script. For example, the Python script checks that a certain statement of the SQL file to be stored does not have corresponding annotation information, and the statement is not standardized, and prompts the user to add annotation information of the statement.
Illustratively, whether the file name information of the SQL file to be stored is standard is determined by checking whether the file name information of the SQL file to be stored is complete through a Python script. For example, if the Python script checks that no database information exists 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 input the database information. The file name information caused by other situations is not standardized, for example, a processing method for file name information irregularity caused by absence of timestamp information in the file name information is similar to this, and this embodiment is not described herein again.
And if the content and/or the file name information of the SQL file to be stored is determined to be not standard, prompting a user to modify the content and/or the file name information of the SQL file to be stored.
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.
And S204, storing the SQL file to be stored and the corresponding file name information into an SQL file storage library.
Illustratively, if it is determined that the content and the file name information of the SQL file are both standard, the SQL file to be stored and the corresponding file name information are stored in the SQL file repository. Illustratively, the SQL file repository may be a version management system, such as a distributed version management system Git. Git is an open-source distributed version control system that can process and manage SQL files efficiently and at high speed.
S205, receiving a migration instruction input by a user;
s206, according to the migration instruction, acquiring 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 an SQL file storage library, and the file name information of the target SQL file comprises database information to which the target SQL file is to be migrated.
S205 and S206 provided in this embodiment are similar to S101 and S102 provided in the embodiment of fig. 1, and this embodiment is not described herein again.
S207, executing the target SQL file;
and S208, verifying the file name information of the target SQL file.
In this embodiment, after the target SQL file to be migrated and the file name information of the target SQL file are acquired, the target SQL file is executed and the file name information of the target SQL file is verified. And executing the target SQL file to ensure that each SQL statement in the SQL file can be successfully executed, and checking the file name information to ensure the normalization of the file name information.
S209, if the target SQL file is successfully executed and the file name information of the target SQL file passes the verification, determining that the migration condition is met.
And if the execution of the target SQL file fails and/or the file name information fails to be checked, determining that the migration condition is not met, and prompting a user to modify the target SQL file and/or the file name information.
In this embodiment, the target SQL file may be executed by a Python script, and the file name information of the target SQL file is checked. For example, when some statements of the target SQL file fail to be executed by the Python script, a prompt message indicating that the statements fail to be executed is displayed to prompt the user to modify the statements.
For example, when the file name information of the target SQL file is verified through the Python script, and a database information error in the file name information of the target SQL file causes a file name information verification failure, a prompt message of the database information error is displayed to prompt a user to modify the database information. The processing method of the file name information verification failure caused by other situations, for example, the file name information verification failure caused by the timestamp information, is similar to this, and is not described herein again in this embodiment.
And S210, if the migration condition is determined to be met, migrating the target SQL file to a database corresponding to the database information.
In another embodiment, whether the target SQL file exists in the database may be queried according to 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 state information of the target SQL file is migration failure, determining that the migration condition is met, and migrating the target SQL file to the database corresponding to the database information so as to update the SQL file of the database.
In another embodiment, if the target SQL file is executed successfully and the file name information of the target SQL file passes the check, querying whether the target SQL file exists in the database according to 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 state information of the target SQL file is migration failure, determining that the migration condition is met, and migrating the target SQL file to the database corresponding to the database information so as to update the SQL file of the database.
In the present disclosure, the target SQL file may be migrated to a database corresponding to the database information, for example, by Flyway. The Flyway is an open-source database version management tool, can manage and track the change of the database independently of the application, and can realize the migration of the SQL file without complex configuration.
Exemplarily, when the database information input by the user is the database name a of the database 1, file name information is generated according to the database name a, and if it is determined that the migration condition is satisfied, the target SQL file is migrated to the database 1 according to the database name a in the file name information, and the SQL file in the database 1 is updated; when the user inputs the database information as a database name B of the database 2, file name information is generated according to the database name B, if the migration condition is determined to be met, the target SQL file is migrated to the database 2 according to the database name B in the file name information, and the SQL file in the database 2 is updated; when the user inputs the database information as the database name C of the database 3, file name information is generated according to the database name C, and if it is determined that the migration condition is satisfied, the target SQL file is migrated to the database 3 according to the database name C in the file name information, and the SQL file in the database 3 is updated. When a 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 the different databases are updated, so that the problem that the time is consumed when the SQL files in the multiple databases are updated is solved, and the efficiency is greatly improved.
Further, whether the target SQL file exists in the database corresponding to the database information or not is inquired, so that repeated migration of the SQL file can be avoided, the SQL file in the database is repeatedly updated, and the efficiency is further improved.
By adopting the scheme, the problem of version information conflict in the file name information of the SQL file can be avoided by generating the identification information and generating the version information in the file name information according to the identification information. Different database information can be input by a user, file name information is generated according to the database information, when the migration condition is determined to be 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, the target SQL file is migrated to different databases, the SQL files in the different databases are updated, the problem that time is consumed when the SQL files in the multiple databases are updated is solved, and the efficiency is greatly improved.
Fig. 3 is a block diagram illustrating an SQL file migration apparatus according to an embodiment of the present disclosure. As shown in fig. 3, the apparatus 30 includes:
a migration instruction receiving unit 301, configured to receive a migration instruction input by a user;
an SQL file obtaining unit 302, configured to obtain, according to the migration instruction, a target SQL file to be migrated and file name information of the target SQL file, where the target SQL file is any SQL file stored in an SQL file storage library, and the file name information of the target SQL file includes database information to which the target SQL file is to be migrated;
and the SQL file migration unit 303 is configured to migrate the target SQL file to the database corresponding to the database information if it is determined that the migration condition is met.
Optionally, fig. 4 is a block diagram of an SQL file migration apparatus according to the embodiment shown in fig. 3, and as shown in fig. 4, the apparatus 30 further includes:
the SQL file receiving unit 304 is configured to receive an SQL file to be stored and database information to which the SQL file to be stored is to be migrated, which are input by a user;
an identification information generating unit 305 for generating identification information and timestamp information of the SQL file to be stored;
a file name information generating unit 306, configured to generate file name information of the to-be-stored SQL file according to the identification information, the timestamp information, and the database information, where the file name information of the to-be-stored SQL file includes the identification information, the timestamp information, and the database information;
the SQL file storage unit 307 is configured to store the SQL file to be stored and the corresponding file name information into the SQL file storage library.
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 at least comprises the timestamp information of the SQL file;
optionally, the SQL file obtaining unit 302 is configured to:
and 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 is matched with the time information, and the file type of the target SQL file is matched with the file type information.
Optionally, the apparatus 30 further comprises:
the SQL file query unit 308 is 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 303 is configured to determine that a migration condition is satisfied 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.
Optionally, the apparatus 30 further comprises:
an SQL file execution unit 309 configured to execute the target SQL file;
a file name information checking unit 310, configured to check file name information of the target SQL file;
the SQL file migration unit 303 is further configured to determine that the migration condition is satisfied if the target SQL file is successfully executed and the file name information of the target SQL file passes the check.
By adopting the scheme, the problem of version information conflict in the file name information of the SQL file can be avoided by generating the identification information and generating the version information in the file name information according to the identification information. Different database information can be input by a user, file name information is generated according to the database information, when the migration condition is determined to be 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, the target SQL file is migrated to different databases, the SQL files in the different databases are updated, the problem that time is consumed when the SQL files in the multiple databases are updated is solved, and the efficiency is greatly improved.
With regard to the apparatus in the above-described embodiment, the specific manner in which each unit performs the operation has been described in detail in the embodiment related to the method, and will not be described in detail here.
The SQL file migration device comprises a processor and a memory, wherein the migration instruction unit, the SQL file acquisition unit, the SQL file migration unit, the SQL file receiving unit, the identification information generation unit, the file name information generation unit and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set to be one or more, the SQL file is migrated to different databases by adjusting the kernel parameters, and the SQL file in different databases is updated.
An embodiment of the present invention provides a storage medium, on which a program is stored, and when the program is executed by a processor, the SQL file migration method described in the embodiments of fig. 1 and fig. 2 is implemented.
The embodiment of the invention provides a processor, wherein the processor is used for running a program, and the SQL file migration method described in the embodiments of FIG. 1 and FIG. 2 is executed when the program runs.
An apparatus is provided in an embodiment of the present invention, as shown in fig. 5, fig. 5 is a block diagram of an apparatus shown in an embodiment of the present disclosure, where the apparatus 50 includes at least one processor 501, and at least one memory 502 and a bus 503 connected to the processor 501; the processor 501 and the memory 502 complete communication with each other through the bus 503; the processor 501 is used to call program instructions in the memory 502 to execute the SQL file migration method described above. The device herein may be a server, a PC, a PAD, a mobile phone, etc.
The present application further provides a computer program product adapted to perform a program for initializing the following method steps when executed on a data processing device:
receiving a migration instruction input by a user;
acquiring 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 an SQL file storage library, and the file name information of the target SQL file comprises database information to which the target SQL file is to be migrated;
and if the migration condition is determined to be met, migrating the target SQL file to a database corresponding to the database information.
Optionally, the method further includes:
receiving an SQL file to be stored and database information to which the SQL file to be stored is to be migrated, wherein the SQL file to be stored is input by a user;
generating identification information and timestamp information of the SQL file to be stored;
generating 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 comprises the identification information, the timestamp information and the database information;
and storing the SQL file to be stored and the corresponding file name information into the SQL file storage library.
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 at least comprises the timestamp information of the SQL file;
the acquiring the target SQL file to be migrated and the file name information of the target SQL file according to the migration instruction comprises the following steps:
and 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 is matched with the time information, and the file type of the target SQL file is matched with the file type information.
Optionally, the method further includes:
inquiring whether the target SQL file exists in the database or not according to the file name information of the target SQL file;
and if the target SQL file does not exist in the database, or the target SQL file exists in the database but the migration state information of the target SQL file is migration failure, determining that the migration condition is met.
Optionally, the method further includes:
executing the target SQL file;
checking the file name information of the target SQL file;
and if the target SQL file is successfully executed and the file name information of the target SQL file passes the verification, determining that the migration condition is met.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus, devices, and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a device includes one or more processors (CPUs), memory, and a bus. The device may also include input/output interfaces, network interfaces, and the like.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip. The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, 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 disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (12)

1. A SQL file migration method is characterized by comprising the following steps:
receiving a migration instruction input by a user;
acquiring a target Structured Query Language (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 an SQL file storage library, and the file name information of the target SQL file comprises database information to which the target SQL file is to be migrated;
and if the migration condition is determined to be met, migrating the target SQL file to a database corresponding to the database information.
2. The method of claim 1, further comprising:
receiving an SQL file to be stored and database information to which the SQL file to be stored is to be migrated, wherein the SQL file to be stored is input by a user;
generating identification information and timestamp information of the SQL file to be stored;
generating 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 comprises the identification information, the timestamp information and the database information;
and storing the SQL file to be stored and the corresponding file name information into the SQL file storage library.
3. The method of claim 1, wherein the migration instructions include file type information and time information; the file name information of the SQL file stored in the SQL file repository at least comprises the timestamp information of the SQL file;
the acquiring the target SQL file to be migrated and the file name information of the target SQL file according to the migration instruction comprises the following steps:
and 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 is matched with the time information, and the file type of the target SQL file is matched with the file type information.
4. The method of claim 1, further comprising:
inquiring whether the target SQL file exists in the database or not according to the file name information of the target SQL file;
and if the target SQL file does not exist in the database, or the target SQL file exists in the database but the migration state information of the target SQL file is migration failure, determining that the migration condition is met.
5. The method of claim 1, further comprising:
executing the target SQL file;
checking the file name information of the target SQL file;
and if the target SQL file is successfully executed and the file name information of the target SQL file passes the verification, determining that the migration condition is met.
6. An SQL file migration apparatus, comprising:
the migration instruction unit is used for receiving a migration instruction input by a user;
the SQL file acquisition unit is used for acquiring 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 an SQL file storage library, and the file name information of the target SQL file comprises database information to which the target SQL file is to be migrated;
and the SQL file migration unit is used for migrating the target SQL file to a database corresponding to the database information if the migration condition is determined to be met.
7. The apparatus of claim 6, further comprising:
the SQL file receiving unit is used for receiving an SQL file to be stored and database information to which the SQL file to be stored is to be migrated, which are input by a user;
the identification information generating unit is used for generating the identification information and the timestamp information of the SQL file to be stored;
a file name information generating unit, configured to generate file name information of the to-be-stored SQL file according to the identification information, the timestamp information, and the database information, where the file name information of the to-be-stored SQL file includes the identification information, the timestamp information, and the database information;
and the SQL file storage unit is used for storing the SQL file to be stored and the corresponding file name information into the SQL file storage library.
8. The apparatus of claim 6, wherein the migration instructions comprise file type information and time information; the file name information of the SQL file stored in the SQL file repository at least comprises the timestamp information of the SQL file;
the SQL file acquisition unit is used for:
and 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 is matched with the time information, and the file type of the target SQL file is matched with the file type information.
9. The apparatus of claim 6, further comprising:
the SQL file query unit is used for querying whether the target SQL file exists in the database or not according to the file name information of the target SQL file;
the SQL file migration unit is used for determining that migration conditions are met if the target SQL file does not exist in the database or the target SQL file exists in the database but the migration state information of the target SQL file is migration failure.
10. The apparatus of claim 6, further comprising:
the SQL file execution unit is used for executing the target SQL file;
the file name information checking unit is used for checking the file name information of the target SQL file;
the SQL file migration unit is used for determining that migration conditions are met if the target SQL file is successfully executed and the file name information of the target SQL file passes verification.
11. A storage medium having a program stored thereon, the program being characterized in that the program, when being executed by a processor, carries out the steps of the method as claimed in any one of the claims 1 to 5.
12. An apparatus, characterized in that the apparatus comprises:
at least one processor, and at least one memory, bus connected with the processor;
the processor and the memory complete mutual communication through the bus;
the processor is configured to call program instructions in the memory to perform the steps of the method of any of claims 1-5.
CN201910913195.1A 2019-09-25 2019-09-25 SQL (structured query language) file migration method and device, storage medium and equipment Pending CN112559444A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910913195.1A CN112559444A (en) 2019-09-25 2019-09-25 SQL (structured query language) file migration method and device, storage medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910913195.1A CN112559444A (en) 2019-09-25 2019-09-25 SQL (structured query language) file migration method and device, storage medium and equipment

Publications (1)

Publication Number Publication Date
CN112559444A true CN112559444A (en) 2021-03-26

Family

ID=75029421

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910913195.1A Pending CN112559444A (en) 2019-09-25 2019-09-25 SQL (structured query language) file migration method and device, storage medium and equipment

Country Status (1)

Country Link
CN (1) CN112559444A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115426290A (en) * 2022-09-23 2022-12-02 中国农业银行股份有限公司 Data migration and verification method and device, computer equipment and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7107589B1 (en) * 2001-09-28 2006-09-12 Siebel Systems, Inc. Infrastructure for the automation of the assembly of schema maintenance scripts
CN106874389A (en) * 2017-01-11 2017-06-20 腾讯科技(深圳)有限公司 The moving method and device of data
CN108073688A (en) * 2017-11-20 2018-05-25 苏宁云商集团股份有限公司 A kind of method and device of Data Migration
CN108829765A (en) * 2018-05-29 2018-11-16 平安科技(深圳)有限公司 A kind of information query method, device, computer equipment and storage medium
CN109491589A (en) * 2017-09-13 2019-03-19 北京易华录信息技术股份有限公司 A kind of delamination process and device based on file content
CN109558456A (en) * 2018-12-04 2019-04-02 郑州云海信息技术有限公司 A kind of file migration method, apparatus, equipment and readable storage medium storing program for executing
CN110222036A (en) * 2013-07-09 2019-09-10 甲骨文国际公司 Automated data library migrates framework

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7107589B1 (en) * 2001-09-28 2006-09-12 Siebel Systems, Inc. Infrastructure for the automation of the assembly of schema maintenance scripts
CN110222036A (en) * 2013-07-09 2019-09-10 甲骨文国际公司 Automated data library migrates framework
CN106874389A (en) * 2017-01-11 2017-06-20 腾讯科技(深圳)有限公司 The moving method and device of data
CN109491589A (en) * 2017-09-13 2019-03-19 北京易华录信息技术股份有限公司 A kind of delamination process and device based on file content
CN108073688A (en) * 2017-11-20 2018-05-25 苏宁云商集团股份有限公司 A kind of method and device of Data Migration
CN108829765A (en) * 2018-05-29 2018-11-16 平安科技(深圳)有限公司 A kind of information query method, device, computer equipment and storage medium
CN109558456A (en) * 2018-12-04 2019-04-02 郑州云海信息技术有限公司 A kind of file migration method, apparatus, equipment and readable storage medium storing program for executing

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115426290A (en) * 2022-09-23 2022-12-02 中国农业银行股份有限公司 Data migration and verification method and device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN106610853A (en) Application deployment method and device
US11169792B2 (en) Method and apparatus for generating patch
CN111158741B (en) Method and device for monitoring dependency relationship change of service module on third party class library
CN109032631B (en) Application program patch package obtaining method and device, computer equipment and storage medium
CN106897342B (en) Data verification method and equipment
CN110895544B (en) Interface data processing method, device, system and storage medium
CN110019111B (en) Data processing method, data processing device, storage medium and processor
CN107294750B (en) Cloud cluster energy self-identification distributed configuration management method and device
CN114780641B (en) Multi-library multi-table synchronization method, device, computer equipment and storage medium
US20120159515A1 (en) Sharing object representations
CN111966760A (en) Hive data warehouse-based test data generation method and device
CN109977317B (en) Data query method and device
CN112631763A (en) Program changing method and device of host program
CN112559444A (en) SQL (structured query language) file migration method and device, storage medium and equipment
CN117033492A (en) Data importing method and device, storage medium and electronic equipment
CN110928941A (en) Data fragment extraction method and device
CN116186050A (en) Data updating method and device based on hash algorithm
CN114791884A (en) Test environment construction method and device, storage medium and electronic equipment
CN114089965A (en) Program development project management method and device based on monolithic code warehouse Monorepo
CN111400243B (en) Development management system based on pipeline service and file storage method and device
CN111400245B (en) Art resource migration method and device
CN111400396A (en) Method and device for generating data synchronization script and computer readable storage medium
CN108062329B (en) Data import method and device
CN115858012B (en) Program variable configuration method, device, electronic equipment and storage medium
KR101506656B1 (en) System for quality management of application and method therefor

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