Methods, devices, equipment, and storage media for converting SQL command statements.

CN117271566BActive Publication Date: 2026-08-14BEIJING VRV SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-01
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

[0002]目前,Mariadb数据库的SQL命令语句不能直接应用于其它国产数据库,并且不能反向转化于其他国产数据库,从而不能横向拓展而满足不同数据库模型的需求

Benefits of technology

[0042]本公开实施例提供的一种SQL命令语句的转化方法,通过获取Mariadb数据库的项目配置文件中的实例配置信息;获取Mariadb数据库中与所述实例配置信息相对应的源数据信息;基于至少一个目标转化数据库的解析器解析所述源数据,得到所述至少一个目标转化数据库的SQL命令语句。本公开实施例能够基于Mariadb数据库转换得到多种不同类型的目标转化数据库的SQL命令语句,具有较强的兼容性,降低开发、测试和人员的维护成本及开发周期,从而提高了SQL命令语句的转化效率及性能。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117271566B_ABST
    Figure CN117271566B_ABST
Patent Text Reader

Abstract

This embodiment discloses a method, apparatus, device, and storage medium for converting SQL command statements. The method includes: obtaining instance configuration information from a project configuration file in a MariaDB database; obtaining source data in the MariaDB database corresponding to the instance configuration information; and parsing the source data using a parser for at least one target conversion database to obtain SQL command statements for at least one target conversion database. This method can convert SQL command statements from various types of target conversion databases based on a MariaDB database, exhibiting strong compatibility, reducing development, testing, and maintenance costs and development cycles, thereby improving the conversion efficiency and performance of SQL command statements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of communication technology, and in particular to a method, apparatus, device, and storage medium for converting SQL command statements. Background Technology

[0002] Currently, the SQL commands in the MariaDB database cannot be directly applied to other domestic databases, nor can they be reverse-engineered to other domestic databases, thus preventing horizontal expansion to meet the needs of different database models.

[0003] In related technologies, the conversion methods for SQL command statements are often incompatible with each other in terms of SQL command statements, sequence support, and field attributes of different databases. Users must manually mark, compare, and convert these statements, resulting in poor compatibility, a large proportion of project development personnel involved, high development, testing, and maintenance costs, and long development cycles. Summary of the Invention

[0004] In view of this, the present disclosure provides a method, apparatus, device and storage medium for converting SQL command statements, which can convert SQL command statements of various types of target databases based on MariaDB databases. It has strong compatibility, reduces development, testing and maintenance costs and development cycle, thereby improving the conversion efficiency and performance of SQL command statements.

[0005] Firstly, this disclosure provides a method for converting SQL command statements, employing the following technical solution:

[0006] Retrieve instance configuration information from the project configuration file of the MariaDB database;

[0007] Retrieve the source data from the MariaDB database that corresponds to the instance configuration information;

[0008] The source data is parsed by a parser based on at least one target transformation database to obtain the SQL command statements for the at least one target transformation database.

[0009] In some embodiments, the source data is parsed by a parser based on at least one target conversion database to obtain SQL command statements for the at least one target conversion database, including:

[0010] Target configuration information for constructing the at least one target transformation database;

[0011] Based on the target configuration information, an abstract factory is used to generate SQL command statements for the at least one target transformation database.

[0012] In some embodiments, the target configuration information for constructing the at least one target conversion database includes at least one of the following:

[0013] Construct the basic table structure information, field attributes, length information, primary key information, index information, and composite index information of the at least one target transformation database; wherein, the basic table structure information includes at least the basic model framework of the DROP delete command and the CREATE create command;

[0014] Construct a SEQUENCE sequence for the at least one target conversion database, and set a preset initial value for the SEQUENCE sequence;

[0015] Construct INSERT statements for the built-in data of the at least one target transformation database.

[0016] In some embodiments, based on the target configuration information, an abstract factory is used to generate SQL command statements for the at least one target transformation database, including:

[0017] Based on the target configuration information, construct the source data model for the at least one target transformation database;

[0018] The abstract factory is used to distribute the model data in the source data model to the scheduler and generate distribution events;

[0019] The distribution event is transmitted to the at least one target conversion database;

[0020] The model data from the distribution event is used to generate SQL command statements for the at least one target transformation database.

[0021] In some embodiments, the at least one target conversion database includes a DM database, and the SQL command statements for generating the at least one target conversion database are generated using model data from the distribution event, including:

[0022] When the conversion mode of the SEQUENCE sequence in the DM database is set to "Enable Sequence", construct the SQL statement for the sequence model;

[0023] Based on the SQL statements of the sequence model, the SQL command statements of the DM database are generated using the model data; or,

[0024] When the conversion method of the SEQUENCE sequence in the DM database is "sequence not enabled", construct the SQL statement for the non-sequence model;

[0025] Based on the SQL statements of the non-sequence model, the SQL command statements of the DM database are generated using the model data.

[0026] In some embodiments, the method further includes:

[0027] Assemble the source data models corresponding to each model data;

[0028] Based on the source data model, SQL command files are generated for each of the target transformation databases.

[0029] Secondly, this disclosure also provides an SQL command statement conversion device, which adopts the following technical solution:

[0030] The configuration information acquisition unit is configured to acquire instance configuration information from the project configuration file of the MariaDB database.

[0031] The source data information acquisition unit is configured to acquire source data in the MariaDB database that corresponds to the instance configuration information.

[0032] The SQL command statement conversion unit is configured to parse the source data based on a parser of at least one target conversion database to obtain the SQL command statements of the at least one target conversion database.

[0033] In some embodiments, the SQL command statement conversion unit includes:

[0034] The building module is configured to build the target configuration information of the at least one target transformation database;

[0035] The SQL command statement conversion module is configured to generate SQL command statements for the at least one target conversion database based on the target configuration information using an abstract factory.

[0036] Thirdly, this disclosure also provides an electronic device that adopts the following technical solution:

[0037] The electronic device includes:

[0038] At least one processor; and,

[0039] A memory communicatively connected to the at least one processor; wherein,

[0040] The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform any of the above-described SQL command statement conversion methods.

[0041] Fourthly, embodiments of this disclosure also provide a computer-readable storage medium storing computer instructions for causing a computer to execute any of the above-described methods for converting SQL command statements.

[0042] This disclosure provides a method for converting SQL command statements. The method involves obtaining instance configuration information from a project configuration file in a MariaDB database; obtaining source data information in the MariaDB database corresponding to the instance configuration information; and parsing the source data using a parser for at least one target conversion database to obtain SQL command statements for that target database. This disclosure enables the conversion of SQL command statements from a MariaDB database to various types of target databases, exhibiting strong compatibility and reducing development, testing, and maintenance costs and development cycles, thereby improving the efficiency and performance of SQL command statement conversion.

[0043] The above description is merely an overview of the technical solution disclosed herein. In order to better understand the technical means of this disclosure and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0044] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0045] Figure 1 A schematic flowchart illustrating a method for converting SQL command statements according to an embodiment of this disclosure;

[0046] Figure 2 A schematic flowchart illustrating another method for converting SQL command statements provided in this embodiment of the disclosure;

[0047] Figure 3 A schematic flowchart illustrating another method for converting SQL command statements provided in this embodiment of the disclosure;

[0048] Figure 4 A schematic diagram of the structure of an SQL command statement conversion device provided in an embodiment of this disclosure;

[0049] Figure 5 A schematic diagram of the structure of another SQL command statement conversion device provided in an embodiment of this disclosure;

[0050] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation

[0051] The embodiments of this disclosure will now be described in detail with reference to the accompanying drawings.

[0052] It should be understood that the following specific examples illustrate the implementation of this disclosure, and those skilled in the art can easily understand other advantages and effects of this disclosure from the content disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. This disclosure can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this disclosure. It should be noted that, in the absence of conflict, the following embodiments and features in the embodiments can be combined with each other. Based on the embodiments in this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.

[0053] It should be noted that various aspects of embodiments within the scope of the appended claims are described below. It will be apparent that the aspects described herein can be embodied in a wide variety of forms, and any particular structure and / or function described herein is merely illustrative. Based on this disclosure, those skilled in the art will understand that one aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects set forth herein can be used to implement the device and / or practice the method. Additionally, this device and / or method can be implemented using structures and / or functionalities other than one or more of the aspects set forth herein.

[0054] It should also be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of this disclosure. The drawings only show the components related to this disclosure and are not drawn according to the number, shape and size of the components in actual implementation. In actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.

[0055] Furthermore, specific details are provided in the following description to facilitate a thorough understanding of the examples. However, those skilled in the art will understand that the described aspects can be practiced without these specific details.

[0056] Figure 1 This is a flowchart illustrating a method for converting SQL command statements according to an embodiment of the present disclosure. The method for converting SQL command statements according to an embodiment of the present disclosure includes the following steps:

[0057] S101. Obtain instance configuration information from the project configuration file of the MariaDB database.

[0058] Optionally, you can obtain configuration information from the project configuration file of the MariaDB database, and obtain instance configuration information from the configuration information.

[0059] S102. Obtain the source data in the MariaDB database that corresponds to the instance configuration information.

[0060] Optionally, the corresponding source data information can be obtained from the INFORMATION_SCHEMA database through the MariaDB database. The INFORMATION_SCHEMA database is a virtual database created after MySQL version 5.0 and does not exist physically.

[0061] S103. Based on the parser of at least one target transformation database, parse the source data to obtain the SQL command statement of at least one target transformation database.

[0062] The embodiments disclosed herein can convert SQL command statements for various target databases based on MariaDB databases, exhibiting strong compatibility, reducing development, testing, and maintenance costs and development cycles, thereby improving the conversion efficiency and performance of SQL command statements.

[0063] In some embodiments, the source data is parsed based on a parser of at least one target transformation database to obtain SQL command statements for at least one target transformation database, including:

[0064] Target configuration information for constructing at least one target transformation database;

[0065] Based on the target configuration information, use the abstract factory to generate at least one SQL command statement for the target transformation database.

[0066] Optionally, the target configuration information is typically some basic information about the table structure of the target transformation database.

[0067] In some embodiments, the target configuration information for constructing at least one target transformation database includes at least one of the following:

[0068] Construct at least one table structure basic information, field attributes, length information, primary key information, index information, and composite index information for the target transformation database; wherein, the table structure basic information should at least include the basic model framework of the DROP delete command and the CREATE create command;

[0069] Construct at least one SEQUENCE sequence for the target transformation database and set the preset initial value of the SEQUENCE sequence;

[0070] Construct at least one INSERT statement to convert the built-in data of the target database.

[0071] Optionally, users can set a preset initial value for the SEQUENCE sequence according to actual business needs, and this disclosure does not limit this.

[0072] Optionally, when the target conversion database is the DM database, the conversion method of the SEQUENCE sequence can support two conversion methods: sequence with enabled and sequence with disabled.

[0073] In some embodiments, based on target configuration information, an abstract factory is used to generate at least one SQL command statement for a target transformation database, including:

[0074] Based on the target configuration information, construct the source data model for at least one target transformation database;

[0075] The abstract factory is used to distribute model data from the source data model to the scheduler and generate distribution events.

[0076] Transmit the distribution event to at least one target conversion database;

[0077] Generate at least one SQL command statement for the target transformation database using the model data from the distribution event.

[0078] Optionally, embodiments of this disclosure can construct a source data model for at least one target transformation database based on a MariaDB database; utilize an abstract factory to distribute model data in the source data model to a scheduler and generate distribution events; transmit the data to four or more target transformation databases through the distribution events, and use the model data in the distribution events to generate SQL command statements for four or more target transformation databases, thereby achieving the transformation based on the MariaDB database to obtain four or more target transformation databases.

[0079] Optionally, the target conversion database may include domestic databases (e.g., DM Database, Kingbase Database, Highgo Database, Shenzhou General Database, etc.). This disclosure does not limit the type or number of target conversion databases; users can convert SQL command statements according to actual business needs.

[0080] In some embodiments, at least one target conversion database includes a DM database, and SQL command statements for at least one target conversion database are generated using model data from the distribution event, including:

[0081] When the conversion method of the SEQUENCE sequence in the DM database is to enable sequence, the SQL statement for constructing the sequence model is used.

[0082] SQL statements based on sequence models are used to generate SQL command statements for the DM database using model data; or,

[0083] When the conversion method of the SEQUENCE sequence in the DM database is "sequence not enabled", construct the SQL statement for the non-sequence model;

[0084] SQL statements based on non-sequence models are used to generate SQL command statements for the DM database using model data.

[0085] In some embodiments, the method further includes:

[0086] Assemble the source data models corresponding to each model data;

[0087] Based on the source data model, SQL command files are generated for each target transformation database.

[0088] Figure 2 This is a schematic diagram of another SQL command statement conversion method provided in an embodiment of this disclosure, such as... Figure 2 As shown, this embodiment of the disclosure incorporates the dialects of four different domestic databases (e.g., DM Database, Kingbase Database, Highgo Database, Shenzhou General Database, etc.) into the server program. It also includes rules for type conversion and special character matching for these four different domestic databases, supports an extended mode, and can horizontally expand the database. The server program, based on the instance configuration information of the source database and the target configuration information (i.e., parameter configuration information) of the target database to be converted, obtains the source data from the INFORMATION_SCHEMA database in the MariaDB database, and queries detailed information about all database table structures of that instance. Based on this detailed information, it constructs the corresponding database model, specifically including the following steps:

[0089] Step 1: Organize the basic information of the obtained database table structure, including table names, field names, field attributes, primary keys, foreign keys, index information, etc.

[0090] Step 2: Based on the parameter configuration information of the target conversion database (based on 4 different domestic databases, select the target conversion database), construct the basic template information of the table through the abstract factory class.

[0091] Step 2 specifically includes the following steps:

[0092] Step 21: Construct the drop table command;

[0093] Step 22: Construct the `create table` command;

[0094] Step 23: Assemble the data to be transformed into template data, and distribute the template data to the scheduler through the abstract factory.

[0095] Step 3: The scheduler sends task events to the corresponding processors through the parameter configuration information of the target transformation database. The processors then perform formatting operations on the basic table information and template data of the database table structure organized in Step 1 and Step 2 according to the dialect information of the corresponding built-in domestic database.

[0096] Step 3 specifically includes the following steps:

[0097] Step 31: Perform case-sensitive processing on table names and field names;

[0098] Step 32: Convert the field attributes;

[0099] Step 33: Perform matching processing on special fields;

[0100] Step 34: Apply single and double quotes to the fields.

[0101] Step 4: After the processor completes the formatting operation, it generates the corresponding SQL command statements for the database.

[0102] Step 4 specifically includes the following steps:

[0103] Step 41: Generate the basic general SQL commands for the corresponding database, such as the DROP delete command and the CREATE create command, and include primary key, foreign key, and index syntax commands;

[0104] Step 42: Generate INSERT statements for the table's built-in data;

[0105] If the target database for conversion is a DM database, and the DM database has sequence mode enabled, then sequence commands will be generated according to the DM sequence syntax.

[0106] Step 43: Generate the SQL command file for the corresponding database.

[0107] Figure 3 This is a schematic diagram of another SQL command statement conversion method provided by an embodiment of the present disclosure. The SQL command statement conversion from MariaDB database to DM database in this embodiment of the present disclosure mainly includes the following four stages:

[0108] Initialization phase: The main program starts and performs a self-check, checking whether the MariaDB database is normal, whether the program configuration is normal, whether the source SQL file to be converted and the parameter configuration information of the target conversion database (this parameter configuration information is the parameter configuration information of the target conversion database to be converted) exist, and checking the instance configuration information of the current MariaDB database.

[0109] Parsing phase: Obtain the parameter configuration information of the target database and parse out information such as table name, table body (fields, attribute length and type, primary key, foreign key, index (normal index, composite index), sequence, and whether it is built-in data) based on the SQL information of the source database.

[0110] Processing phase: Based on the parameter configuration information of the target transformation database in the parsing phase, the data is distributed to the corresponding processor. The processor processes the SQL information of the target transformation database according to its syntax and dialect to obtain the SQL command statement.

[0111] File generation stage: Assemble the SQL command statements of the target database and generate the SQL command file after the target database is transformed.

[0112] The specific implementation steps for the above four stages include:

[0113] (1) The server’s built-in program initialization phase obtains the configuration information of the database in the current environment; if the database configuration information is not obtained, the database connection information and SQL source file import information are configured, and the configuration information of the configured database is obtained again.

[0114] (2) Self-check whether the current environment database status, source database instance configuration information and target conversion database parameter configuration information are normal;

[0115] (3) After the program connects to the MariaDB database, it obtains the instance configuration information of the source database;

[0116] (4) The program obtains source data from the INFORMATION_SCHEMA database through the MariaDB database and constructs a basic general data template. The basic general data template includes a table header and a table body. The table header contains table name information, and the table body contains field names, field attributes, field lengths, default values, primary keys, foreign keys, indexes (normal indexes, composite indexes), sequences, etc.

[0117] (5) Based on the parameter configuration information of the target conversion database, the scheduler obtains the dialect information of the corresponding built-in domestic database and distributes it to the processor of the designated domestic database, for example, distributing it to... Figure 2 In the processor of the Zhongdameng database;

[0118] (6) The processor of the DM database generates the drop table and create table commands of DM data syntax by obtaining the data template and the built-in dialect;

[0119] (7) If the current DM database is in sequence mode, the initial value of the sequence of the table will be obtained, and then the DM drop sequence and create sequence commands will be constructed;

[0120] (8) If the sequence mode is not enabled in the current DM database, first determine whether there is built-in data in the current table. If there is built-in data, first construct the IDENTITY_INSERT (identify insertion) ON command.

[0121] (9) Generate INSERT command syntax data;

[0122] (10) Assemble database SQL command template statements according to the syntax of the DM database;

[0123] (11) Write the generated SQL command template statement into the SQL command file.

[0124] This disclosed embodiment can convert various types of target databases (domestic databases) based on MariaDB databases, making it easy to adapt to the source data models corresponding to different model data and meet the needs of different source data models; it can support sustainable automated deployment, reducing development, personnel, testing maintenance costs and development cycle; field matching for common special scenarios in different databases does not require manual intervention; it is compatible with multiple domestic databases, compresses the conversion time of SQL command statements, and improves the efficiency and performance of constructing SQL command statements.

[0125] Figure 4 This is a schematic diagram of the structure of an SQL command statement conversion device provided in an embodiment of this disclosure. The SQL command statement conversion device provided in an embodiment of this disclosure includes...

[0126] Configuration information acquisition unit 41 is configured to acquire instance configuration information from the project configuration file of the MariaDB database.

[0127] The source data information acquisition unit 42 is configured to acquire source data in the MariaDB database that corresponds to the instance configuration information.

[0128] The SQL command statement conversion unit 43 is configured to parse source data based on a parser of at least one target conversion database to obtain SQL command statements for the at least one target conversion database.

[0129] Figure 5 This is a schematic diagram of another SQL command statement conversion device provided in an embodiment of the present disclosure. In some embodiments, the SQL command statement conversion unit 43 includes:

[0130] Module 431 is configured to build at least one target transformation database based on target configuration information.

[0131] SQL command statement conversion module 432 is configured to generate at least one SQL command statement for a target conversion database based on target configuration information using an abstract factory.

[0132] An electronic device according to embodiments of the present disclosure includes a memory and a processor. The memory is used to store non-transitory computer-readable instructions. Specifically, the memory may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may, for example, include random access memory (RAM) and / or cache memory. The non-volatile memory may, for example, include read-only memory (ROM), a hard disk, flash memory, etc.

[0133] The processor may be a central processing unit (CPU) or other processing unit with data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions. In one embodiment of this disclosure, the processor is used to execute computer-readable instructions stored in the memory, causing the electronic device to perform all or part of the steps of a method for converting SQL command statements according to the foregoing embodiments of this disclosure.

[0134] Those skilled in the art will understand that, in order to solve the technical problem of how to achieve a good user experience, this embodiment may also include well-known structures such as communication buses and interfaces, and these well-known structures should also be included within the protection scope of this disclosure.

[0135] like Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. It illustrates a structural schematic diagram suitable for implementing the electronic device in the embodiment of the present disclosure. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0136] like Figure 6As shown, an electronic device may include a processor (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes based on a program stored in read-only memory (ROM) or a program loaded from a storage device into random access memory (RAM). The RAM also stores various programs and data required for the operation of the electronic device. The processor, ROM, and RAM are interconnected via a bus. Input / output (I / O) interfaces are also connected to the bus.

[0137] Typically, the following devices can be connected to the I / O interface: input devices, such as sensors or visual information acquisition devices; output devices, such as displays; storage devices, such as magnetic tapes or hard drives; and communication devices. Communication devices allow electronic devices to communicate wirelessly or wiredly with other devices (such as edge computing devices) to exchange data. Although Figure 6 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.

[0138] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from ROM. When the computer program is executed by a processor, all or part of the steps of a method for converting SQL command statements according to embodiments of this disclosure are performed.

[0139] For a detailed description of this embodiment, please refer to the corresponding descriptions in the foregoing embodiments, which will not be repeated here.

[0140] A computer-readable storage medium according to embodiments of the present disclosure stores non-transitory computer-readable instructions. When the non-transitory computer-readable instructions are executed by a processor, all or part of the steps of the SQL command statement conversion method described in the foregoing embodiments of the present disclosure are performed.

[0141] The aforementioned computer-readable storage media include, but are not limited to: optical storage media (e.g., CD-ROM and DVD), magneto-optical storage media (e.g., MO), magnetic storage media (e.g., magnetic tape or portable hard drive), media with built-in rewritable non-volatile memory (e.g., memory card), and media with built-in ROM (e.g., ROM cartridge).

[0142] For a detailed description of this embodiment, please refer to the corresponding descriptions in the foregoing embodiments, which will not be repeated here.

[0143] The basic principles of this disclosure have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.

[0144] In this disclosure, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. The block diagrams of devices, apparatuses, devices, and systems involved in this disclosure are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as "comprising," "including," "having," etc., are open-ended terms meaning "including but not limited to," and are used interchangeably with them. The terms "or" and "and" as used herein refer to the terms "and / or," and are used interchangeably with them unless the context clearly indicates otherwise. The term "such as" as used herein refers to the phrase "such as but not limited to," and is used interchangeably with it.

[0145] Additionally, as used herein, the “or” used in a list of items beginning with “at least one” indicates a separate list, such that a list of, for example, “at least one of A, B, or C” means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word “exemplary” does not imply that the described example is preferred or better than other examples.

[0146] It should also be noted that in the systems and methods of this disclosure, the components or steps can be decomposed and / or recombined. These decompositions and / or recombinations should be considered as equivalent solutions to this disclosure.

[0147] Various changes, substitutions, and modifications can be made to the technology described herein without departing from the teachings defined by the appended claims. Furthermore, the scope of the claims of this disclosure is not limited to the specific aspects of the processes, machines, manufactures, events, means, methods, and actions described above. Currently existing or later-developed processes, machines, manufactures, events, means, methods, or actions that perform substantially the same function or achieve substantially the same result as the corresponding aspects described herein can be utilized. Therefore, the appended claims include such processes, machines, manufactures, events, means, methods, or actions within their scope.

[0148] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of this disclosure. Therefore, this disclosure is not intended to be limited to the aspects shown herein, but rather to be carried out within the widest scope consistent with the principles and novel features disclosed herein.

[0149] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this disclosure to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations therein.

Claims

1. A method for converting SQL command statements, characterized in that, include: Retrieve instance configuration information from the project configuration file of the MariaDB database; Retrieve the source data from the MariaDB database that corresponds to the instance configuration information; The source data is parsed by a parser based on at least one target transformation database to obtain the SQL command statements for the at least one target transformation database; The source data is parsed by a parser based on at least one target transformation database to obtain SQL command statements for the at least one target transformation database, including: Based on the target configuration information, construct the source data model for the at least one target transformation database; The target configuration information is the basic information of the table structure of the target transformation database, and the source data model contains model data. The abstract factory is used to distribute the model data in the source data model to the scheduler and generate distribution events; When the abstract factory distributes the model data in the source data model to the scheduler, it assembles the data to be transformed into template data and distributes the template data to the scheduler through the abstract factory. The data to be transformed is the source data information of the MariaDB database. The distribution event is transmitted to the at least one target conversion database; Use the model data in the distribution event to generate SQL command statements for the at least one target transformation database; Specifically, when generating SQL command statements for at least one target conversion database using model data from the distribution event, the basic table information and template data of the database table structure are formatted according to the dialect information built into the target conversion database.

2. The method for converting SQL command statements according to claim 1, characterized in that, The source data is parsed using a parser based on at least one target transformation database to obtain SQL command statements for the at least one target transformation database, including: Target configuration information for constructing the at least one target transformation database; Based on the target configuration information, an abstract factory is used to generate SQL command statements for the at least one target transformation database.

3. The method for converting SQL command statements according to claim 2, characterized in that, The target configuration information for constructing the at least one target transformation database includes at least one of the following: Construct the basic information of the table structure, field attributes, length information, primary key information, index information, and composite index information of the at least one target transformation database; The basic information of the table structure includes at least the basic model framework of the DROP delete command and the CREATE create command; Construct a SEQUENCE sequence for the at least one target conversion database, and set a preset initial value for the SEQUENCE sequence; Construct INSERT statements for the built-in data of the at least one target transformation database.

4. The method for converting SQL command statements according to claim 3, characterized in that, The at least one target conversion database includes the DM database. SQL command statements for generating the at least one target conversion database are generated using model data from the distribution event, including: When the conversion mode of the SEQUENCE sequence in the DM database is set to "Enable Sequence", construct the SQL statement for the sequence model; Based on the SQL statements of the sequence model, the SQL command statements of the DM database are generated using the model data; or, When the conversion method of the SEQUENCE sequence in the DM database is "sequence not enabled", construct the SQL statement for the non-sequence model; Based on the SQL statements of the non-sequence model, the SQL command statements of the DM database are generated using the model data.

5. The method for converting SQL command statements according to claim 3, characterized in that, The method further includes: Assemble the source data models corresponding to each model data; Based on the source data model, SQL command files are generated for each of the target transformation databases.

6. A device for converting SQL command statements, characterized in that, include: The configuration information acquisition unit is configured to acquire instance configuration information from the project configuration file of the MariaDB database. The source data information acquisition unit is configured to acquire source data in the MariaDB database that corresponds to the instance configuration information. The SQL command statement conversion unit is configured to parse the source data based on a parser of at least one target conversion database to obtain the SQL command statements of the at least one target conversion database. The source data is parsed by a parser based on at least one target transformation database to obtain SQL command statements for the at least one target transformation database, including: Based on the target configuration information, construct the source data model for the at least one target transformation database; The target configuration information is the basic information of the table structure of the target transformation database, and the source data model contains model data. The abstract factory is used to distribute the model data in the source data model to the scheduler and generate distribution events; When the abstract factory distributes the model data in the source data model to the scheduler, it assembles the data to be transformed into template data and distributes the template data to the scheduler through the abstract factory. The data to be transformed is the source data information of the MariaDB database. The distribution event is transmitted to the at least one target conversion database; Use the model data in the distribution event to generate SQL command statements for the at least one target transformation database; Specifically, when generating SQL command statements for at least one target conversion database using model data from the distribution event, the basic table information and template data of the database table structure are formatted according to the dialect information built into the target conversion database.

7. The SQL command statement conversion device according to claim 6, characterized in that, The SQL command statement conversion unit includes: The building module is configured to build the target configuration information of the at least one target transformation database; The SQL command statement conversion module is configured to generate SQL command statements for the at least one target conversion database based on the target configuration information using an abstract factory.

8. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the SQL command statement conversion method according to any one of claims 1 to 5.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to execute the conversion method of SQL command statements as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Heterogeneous database conversion method, apparatus and device, and storage medium

    CN109992595A

  • Database migration method and system

    CN115934682A