Methods, devices, equipment, and storage media for converting table structures between databases
By acquiring and utilizing database configuration information and conversion functions, efficient conversion of table structures between different databases was achieved, solving the problems of cumbersome and error-prone conversion processes and improving conversion accuracy and efficiency.
Patent Information
- Application Number
- CN202311093175.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-29
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2043-08-29
AI Technical Summary
In existing technologies, the process of converting table structures between different databases is cumbersome, error-prone, and inefficient, resulting in high labor costs and high error rates.
By obtaining the configuration information of the source database and the target database, the system connects to the source database, determines the transformation function, and uses the transformation function to convert the table structure to be transformed into the target table structure corresponding to the target database.
It improves the accuracy and efficiency of table structure conversion between databases, reduces the error rate of manual processing, and is suitable for database migration scenarios.
Smart Images

Figure CN117131051B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the fields of computer technology, financial technology, or other related fields, and in particular to a method, apparatus, device, medium, and program product for converting table structures between databases. Background Technology
[0002] With the increasingly widespread application of big data, interactions between different databases, whether used for scheduling or business purposes, are becoming more frequent. Furthermore, the need for table joins and synchronization between different databases is also growing.
[0003] However, in related technologies, the conversion of table structures between different databases is cumbersome, error-prone, and inefficient. Summary of the Invention
[0004] In view of the above problems, this disclosure provides a method, apparatus, device, medium and program product for converting table structures between databases.
[0005] According to the first aspect of this disclosure, a method for converting table structures between databases is provided, comprising:
[0006] Retrieve the configuration information corresponding to the source and target databases;
[0007] According to the connection method of the source database in the above configuration information, connect to the source database to obtain the table structure to be converted from the source database;
[0008] Based on the source database type and target database type specified in the above configuration information, determine the conversion function; and
[0009] Using the above conversion function, the above table structure to be converted is transformed to obtain the target table structure corresponding to the above target database.
[0010] According to embodiments of this disclosure, there are multiple table structures to be converted. The conversion function is used to convert these table structures to obtain a target table structure corresponding to the target database, including:
[0011] If target configuration information exists in the above configuration information, for each target table structure to be converted, the conversion rule corresponding to the target table structure to be converted is determined according to the above target configuration information, wherein the target table structure to be converted is determined from multiple above table structures to be converted.
[0012] Based on the target configuration information above, the first target conversion information and the second target conversion information are determined from the target conversion table structure above, wherein the first target conversion information corresponds to the target configuration information above, and the second target conversion information corresponds to the conversion function above;
[0013] According to the conversion rules corresponding to the target table structure, the first target information to be converted in the target table structure is converted to obtain the initial table structure.
[0014] According to the above conversion function, the second target information to be converted in the above initial table structure is converted to obtain the above target table structure.
[0015] According to embodiments of this disclosure, the above-described method for converting table structures between databases further includes:
[0016] If the target configuration information is not present in the above configuration information, the target information to be converted in the target conversion table structure is converted according to the above conversion function to obtain the target table structure.
[0017] According to embodiments of this disclosure, the target table structure to be converted is determined from a plurality of the aforementioned table structures to be converted, including:
[0018] When the conversion method in the above configuration information represents the user level, the target conversion table structure corresponding to each user is determined from the above multiple conversion table structures, wherein the target conversion table structure includes at least one of the above conversion table structures.
[0019] According to embodiments of this disclosure, the above-described method for converting table structures between databases further includes:
[0020] When the conversion method in the above configuration information represents the table level, the target table structure to be converted corresponding to each table is determined from the above multiple table structures to be converted, wherein the target table structure to be converted represents the above table structure to be converted.
[0021] According to embodiments of this disclosure, the above-described method for converting table structures between databases further includes:
[0022] If the above configuration information includes the connection method for the target database, then the target database is connected according to that connection method, and tables are created in the target database according to the target table structure; and
[0023] If the connection method to the target database is not specified in the above configuration information, generate text information corresponding to the target table structure.
[0024] According to embodiments of this disclosure, determining the conversion function based on the type of the source database and the type of the target database in the configuration information includes:
[0025] Based on the types of the source database and the target database, the table structure mapping relationship between the source database and the target database is obtained; and
[0026] Based on the mapping relationship of the above table structure, determine the above conversion function.
[0027] A second aspect of this disclosure provides a database table structure conversion apparatus, comprising: a first acquisition module, a second acquisition module, a determination module, and a conversion module. The first acquisition module is used to acquire configuration information corresponding to a source database and a target database. The second acquisition module is used to connect to the source database according to the connection method of the source database in the configuration information, so as to obtain the table structure to be converted from the source database. The determination module is used to determine a conversion function based on the type of the source database and the type of the target database in the configuration information. The conversion module is used to convert the table structure to be converted using the conversion function to obtain a target table structure corresponding to the target database.
[0028] A third aspect of this disclosure provides an electronic device, comprising: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors perform the method described above.
[0029] A fourth aspect of this disclosure also provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the methods described above.
[0030] The fifth aspect of this disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.
[0031] According to the database table structure conversion method, apparatus, device, medium, and program products provided in this disclosure, configuration information corresponding to the source database and the target database is obtained. Based on the connection method of the source database in the configuration information, the source database is connected to obtain the table structure to be converted. Then, based on the type of the source database and the type of the target database in the configuration information, a conversion function is determined. This conversion function can then be used to convert the table structure to be converted, resulting in a target table structure corresponding to the target database. Converting the table structure to be converted into a target table structure that conforms to the target database using a conversion function not only improves the accuracy and efficiency of table structure conversion between databases but can also be applied to database migration scenarios to solve the problem of high error rates caused by manual database migration. Attached Figure Description
[0032] The foregoing contents, as well as other objects, features, and advantages of this disclosure, will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0033] Figure 1 This diagram illustrates an application scenario of a database table structure conversion method according to an embodiment of the present disclosure.
[0034] Figure 2 A flowchart illustrating a method for converting table structures between databases according to an embodiment of the present disclosure is shown schematically.
[0035] Figure 3 This illustration schematically shows a system diagram for inter-database table structure conversion according to an embodiment of the present disclosure;
[0036] Figure 4 A flowchart illustrating the process of obtaining the target table structure according to an embodiment of the present disclosure is shown schematically;
[0037] Figure 5 A schematic diagram of the conversion processing subsystem according to an embodiment of the present disclosure is shown.
[0038] Figure 6 A flowchart illustrating the implementation of table structure conversion between databases according to an embodiment of the present disclosure is shown schematically.
[0039] Figure 7 A schematic diagram illustrating a structural block diagram of a database table structure conversion apparatus according to an embodiment of the present disclosure; and
[0040] Figure 8 A block diagram schematically illustrates an electronic device suitable for implementing a method for converting table structures between databases according to an embodiment of the present disclosure. Detailed Implementation
[0041] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.
[0042] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0043] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0044] When using expressions such as "at least one of A, B, and C", they should generally be interpreted in accordance with the meaning that is commonly understood by a person skilled in the art (e.g., "a system having at least one of A, B, and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B, and C, etc.).
[0045] In the technical solution of this invention, the user information (including but not limited to user personal information, user image information, user device information, such as location information) and data (including but not limited to data used for analysis, stored data, and displayed data) involved are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of related data all comply with the relevant laws, regulations, and standards of the relevant countries and regions, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entry points for users to choose to authorize or refuse.
[0046] In the process of implementing this disclosure, it was found that data migration between databases relies heavily on manual steps, resulting in a large number of complicated and repetitive manual conversion operations, which requires a lot of labor costs. In addition, the error rate of manual processing is also relatively high. Therefore, in related technologies, the conversion of table structures between different databases has the problems of cumbersome conversion process, easy error and low conversion efficiency. Therefore, there is an urgent need for a method that can adapt to the conversion between various database table structures.
[0047] Therefore, embodiments of this disclosure provide a method for converting table structures between databases, which involves obtaining configuration information corresponding to a source database and a target database; connecting to the source database according to the connection method of the source database in the configuration information to obtain the table structure to be converted from the source database; determining a conversion function according to the type of the source database and the type of the target database in the configuration information; and using the conversion function to convert the table structure to be converted to obtain the target table structure corresponding to the target database.
[0048] Figure 1 The diagram illustrates an application scenario of a database table structure conversion method according to an embodiment of the present disclosure.
[0049] like Figure 1 As shown, application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 serves as a medium for providing a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0050] Users can interact with server 105 via network 104 using at least one of the first terminal device 101, second terminal device 102, and third terminal device 103 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, second terminal device 102, and third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0051] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0052] Server 105 can be a server that provides various services, such as a backend management server that supports websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103 (this is just an example). The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.
[0053] For example, configuration information corresponding to the source database and the target database can be obtained through server 105. Then, according to the connection method of the source database in the configuration information, the source database is connected to obtain the table structure to be converted from the source database. Based on the type of the source database and the type of the target database in the configuration information, the conversion function is determined. Finally, the conversion function is used to convert the table structure to be converted to obtain the target table structure corresponding to the target database.
[0054] It should be noted that the database table structure conversion method provided in this embodiment can generally be executed by server 105. Correspondingly, the database table structure conversion device provided in this embodiment can generally be located in server 105. The database table structure conversion method provided in this embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105. Correspondingly, the database table structure conversion device provided in this embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105.
[0055] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0056] The following will be based on Figure 1 The described scene, through Figures 2-6 The method for converting table structures between databases according to the disclosed embodiments is described in detail.
[0057] Figure 2 A flowchart illustrating a method for converting table structures between databases according to an embodiment of the present disclosure is shown schematically.
[0058] like Figure 2 As shown, the method 200 includes operations S210 to S240.
[0059] In operation S210, configuration information corresponding to the source database and the target database is obtained.
[0060] According to embodiments of this disclosure, both the source database and the target database may include databases of types such as Hadoop, GaussDB, MySQL, Oracle, and SQL Server, wherein the database types of the source database and the target database are different.
[0061] According to embodiments of this disclosure, the configuration information may include basic configuration information and target configuration information. The target configuration information may represent special configuration information and may include special conversion rules. The target configuration information is optional; that is, the configuration information may or may not contain target configuration information. The basic configuration information and target configuration information can be configured via file configuration.
[0062] According to embodiments of this disclosure, basic configuration information may include source database type, target database type, source database connection method, and conversion method. The conversion method may include two types: table-level and user-level. Table-level conversion can represent conversion of a single table, while user-level conversion can represent conversion of all tables under a single user.
[0063] According to embodiments of this disclosure, for some databases, there may be situations where data information is stored in other databases instead of the database itself; that is, data information is stored using another database. Therefore, the database storing the data information can serve as the source database, and the connection method is also the connection method of the database storing the data information.
[0064] For example, if the data information of database A is stored in database B, then database B can be used as the source database, and the connection method of the source database can characterize the connection method of database B.
[0065] According to embodiments of this disclosure, the target configuration information may include whether field names remain consistent, whether there are special requirements for field information, and whether existing constraints and index information need to be maintained. The conversion method is specific to the target configuration information, i.e., whether the conversion is performed at the table level or the user level.
[0066] For example, a special requirement might be that the character type in the source database is char, while the character type in the target database needs to be varchar. In this case, a rule would be configured to convert the character type char to varchar.
[0067] During operation S220, the source database is connected according to the connection method of the source database in the configuration information in order to obtain the table structure to be converted from the source database.
[0068] According to embodiments of this disclosure, the connection method of the source database can be obtained by reading configuration information, and the source database can be connected to obtain the table structure to be converted. The table structure can represent attribute information such as fields, types, primary keys, foreign keys, indexes, and constraints of a table.
[0069] In operation S230, the conversion function is determined based on the type of the source database and the type of the target database in the configuration information.
[0070] According to embodiments of this disclosure, based on the types of the source database and the target database, it is possible to determine which two types of databases are undergoing table structure conversion, thereby determining the corresponding conversion function. The conversion function characterizes the conversion rules for transforming the table structure to be converted in the source database into a table structure conforming to the format of the target database.
[0071] For example, the conversion between a source database and a target database can include conversion from Oracle to MySQL, from Oracle to MPP, and from MPP to Hadoop. The corresponding conversion function can be determined based on the different types of databases being converted.
[0072] In operation S240, the transformation function is used to transform the table structure to be transformed, so as to obtain the target table structure corresponding to the target database.
[0073] According to embodiments of this disclosure, a conversion function can be used to convert the table structure to be converted in order to obtain a target table structure corresponding to the target database.
[0074] According to embodiments of this disclosure, configuration information corresponding to the source database and the target database is obtained. Based on the connection method of the source database in the configuration information, the source database is connected to obtain the table structure to be converted from the source database. Then, based on the type of the source database and the type of the target database in the configuration information, a conversion function is determined. This conversion function can then be used to convert the table structure to be converted, resulting in a target table structure corresponding to the target database. Converting the table structure to be converted into a target table structure that conforms to the target database using a conversion function not only improves the accuracy and efficiency of table structure conversion between databases but can also be applied to database migration scenarios to solve the problem of high error rates caused by manual database migration.
[0075] Figure 3 The illustration shows a schematic diagram of a system for inter-database table structure conversion according to an embodiment of the present disclosure.
[0076] like Figure 3 As shown, the system 300 includes an acquisition subsystem 310, a table structure acquisition subsystem 320, and a conversion processing subsystem 330.
[0077] According to embodiments of this disclosure, the acquisition subsystem 310 can be used to perform the above-described operation S210 to obtain the configured configuration information corresponding to the source database and the target database. The table structure acquisition subsystem 320 can be used to perform the above-described operation S220 to obtain the table structure to be converted from the source database. The conversion processing subsystem 330 can be used to perform the above-described operations S230 and S240 to obtain the target table structure 340 corresponding to the target database.
[0078] Figure 4 A flowchart illustrating the process of obtaining the target table structure according to an embodiment of the present disclosure is shown.
[0079] like Figure 4 As shown, the method 400 includes operations S410 to S440.
[0080] When operating S410, if target configuration information exists in the configuration information, for each target table structure to be converted, the conversion rule corresponding to the target table structure to be converted is determined according to the target configuration information.
[0081] According to embodiments of this disclosure, the target table structure to be transformed is determined from a plurality of table structures to be transformed. The target configuration information can characterize the transformation rules set for field names, field types, constraint rules, etc.
[0082] According to embodiments of this disclosure, when target configuration information exists in the configuration information, the target table structure to be converted can be determined from multiple table structures to be converted based on the conversion method in the configuration information. The target table structure to be converted may include at least one table result to be converted.
[0083] According to embodiments of this disclosure, for each target table structure to be transformed, a transformation rule corresponding to the target table structure can be determined from the target configuration information. The transformation rule may include rules for transforming field information, field types, and constraints.
[0084] For example, a conversion rule could be to convert field A in Table 1 into field B.
[0085] In operation S420, based on the target configuration information, the first target to be converted information and the second target to be converted information are determined from the target to be converted table structure.
[0086] According to embodiments of this disclosure, the first target information to be converted corresponds to the target configuration information, and the second target information to be converted corresponds to the conversion function.
[0087] According to embodiments of this disclosure, the first target information to be converted in the target conversion table structure that needs to be converted according to the conversion rules corresponding to the target configuration information can be determined based on the target configuration information. The remaining information to be converted in the target conversion table structure can be determined as the second target information to be converted according to the conversion function.
[0088] In operation S430, the first target information to be converted in the target table structure is converted according to the conversion rules corresponding to the target table structure to be converted, so as to obtain the initial table structure.
[0089] According to embodiments of this disclosure, the first target information to be converted in the target table structure can be converted according to the conversion rules corresponding to the target table structure to obtain an initial table structure.
[0090] In operation S440, the second target information to be converted in the initial table structure is converted according to the conversion function to obtain the target table structure.
[0091] According to embodiments of this disclosure, the second target information to be converted in the initial table structure can be converted using a conversion function to obtain the target table structure. The second target information to be converted in the initial table structure is consistent with the second target information to be converted in the target table structure.
[0092] For example, given two table structures, A and B, to be converted, based on the target configuration information, it can be determined that field a in table structure A needs to be converted to field b. Based on the conversion function, it can be determined that field c in table structure A needs to be converted to field d. Therefore, field a in table structure A can be converted to field b first based on the target configuration information, and then field c in both table structures A and B can be converted to field d based on the conversion function.
[0093] According to embodiments of this disclosure, the conversion function can characterize the same conversion rule for all table structures to be converted, while the target configuration information can include conversion rules for specific information in a particular table structure to be converted. Therefore, based on user-level and table-level conversion methods, specific information in a particular table structure to be converted can be converted according to the target configuration information. Since the conversion function uses the same conversion rule for all table structures to be converted, the conversion of the table structure to be converted is unaffected regardless of whether a user-level or table-level conversion method is used. Therefore, when target configuration information exists in the configuration information, the target table structure to be converted can be converted sequentially using the conversion function based on a conversion method consistent with the target configuration information.
[0094] According to embodiments of this disclosure, when target configuration information exists in the configuration information, after the conversion rules corresponding to the target configuration information are used to convert the corresponding information to be converted in all the tables to be converted, the conversion function is used to convert the information to be converted in all the tables to be converted that has not been converted.
[0095] According to embodiments of this disclosure, when target configuration information exists in the configuration information, the first target information to be converted in the target table structure to be converted can be converted first according to the target configuration information, and then the second target information to be converted in the target table structure to be converted can be converted according to the conversion function, thereby obtaining the target table structure. This allows the conversion between different databases to be satisfied through the conversion function and the target configuration information, while also meeting different development needs.
[0096] According to embodiments of this disclosure, the above-mentioned method for converting table structures between databases further includes: when there is no target configuration information in the configuration information, converting the target information to be converted in the target table structure to be converted according to a conversion function to obtain the target table structure.
[0097] According to embodiments of this disclosure, when target configuration information exists in the configuration information, the target information to be converted in the target conversion table structure can be divided into first target information to be converted and second target information to be converted. The first target information to be converted corresponds to the target configuration information, and the second target information to be converted corresponds to the conversion function. The first target information to be converted can be converted according to the conversion rules in the target configuration information, and the second target information to be converted can be converted according to the conversion function.
[0098] According to embodiments of this disclosure, when there is no target configuration information in the configuration information, all target information to be converted in the target conversion table structure is converted according to the conversion function to obtain the target table structure.
[0099] According to embodiments of this disclosure, when target configuration information is not present in the configuration information, the target information to be converted in the target table structure can be converted according to a conversion function to obtain the target table structure.
[0100] Figure 5 A schematic diagram of the conversion processing subsystem according to an embodiment of the present disclosure is shown.
[0101] like Figure 5 As shown, Figure 3 A flowchart of the intermediate conversion processing subsystem 330.
[0102] According to embodiments of this disclosure, the target configuration information 530 is optional. When the target configuration information 530 exists, in the conversion processing subsystem 330, a conversion function 540 can be determined based on the types of the source database and the target database in the basic configuration information 510. Then, based on the conversion function 540 and the target configuration information 530, the aforementioned operations S410 to S440 are performed on the table structure 520 to be converted to obtain the target table structure 580.
[0103] According to the embodiments of this disclosure, the target configuration information 530 can be used first to convert the corresponding information to be converted in the conversion table structure 520, and then the conversion function 540 can be used to convert the unconverted information to be converted in the conversion table structure 520 to obtain the target table structure 580.
[0104] Among them, field information conversion 550, field type conversion 560 and constraint conditions 570 can be obtained based on the target configuration information 530.
[0105] According to embodiments of this disclosure, the target table structure to be converted is determined from a plurality of table structures to be converted, including: when the conversion method in the configuration information represents the user level, determining the target table structure to be converted corresponding to each user from the plurality of table structures to be converted.
[0106] According to embodiments of this disclosure, the target table structure to be converted may include at least one table structure to be converted. When the conversion method can characterize the user level, multiple table structures to be converted can be divided according to users, thereby determining the target table structure to be converted corresponding to each user.
[0107] According to embodiments of this disclosure, conversion rules corresponding to all table structures to be converted under each user can be determined based on target configuration information, wherein the conversion rules corresponding to all table structures to be converted under each user may be inconsistent.
[0108] For example, regarding the table structures to be converted for users A and B respectively, based on the target configuration information, it can be determined that field 'a' in all the table structures to be converted under user A needs to be converted into field 'b'; based on the target configuration information, it can be determined that field 'a' in all the table structures to be converted under user B does not need to be converted, or it can be determined that field 'a' should be converted into field 'c'.
[0109] According to embodiments of this disclosure, the transformation of the table structure to be transformed is based on the user level, which is applicable to the migration between databases, can reduce the manual steps of migration, and reduce the error rate of manual processing.
[0110] According to embodiments of this disclosure, the above-described method for converting table structures between databases further includes: when the conversion method in the configuration information represents the table level, determining the target table structure to be converted from multiple table structures to be converted, corresponding to each table.
[0111] According to embodiments of this disclosure, the target table structure to be transformed can characterize the table structure to be transformed. When the transformation method can characterize the table level, the table structure to be transformed for each table can be determined as the target table structure to be transformed.
[0112] According to embodiments of this disclosure, a conversion rule corresponding to the table structure to be converted for each table can be determined based on target configuration information, wherein the conversion rule corresponding to the table structure to be converted for each table may be inconsistent.
[0113] For example, regarding the table structures to be converted in both Table A and Table B, based on the target configuration information, it can be determined that field 'a' in the table structure to be converted in Table A needs to be converted into field 'b'; based on the target configuration information, it can be determined that field 'a' in the table structure to be converted in Table B does not need to be converted, or it can be determined that field 'a' should be converted into field 'c'.
[0114] According to embodiments of this disclosure, the transformation of the table structure to be transformed is based on the table level, which can be applied to the development process of daily projects such as relational queries between different databases, thereby reducing development costs and improving the reliability of the development process.
[0115] According to embodiments of this disclosure, the above-mentioned method for converting table structures between databases further includes: if the configuration information contains a connection method for the target database, connecting to the target database according to the connection method of the target database, and creating a table in the target database according to the target table structure; if the configuration information does not contain a connection method for the target database, generating text information corresponding to the target table structure.
[0116] According to embodiments of this disclosure, the connection method of the target database in the basic configuration information is optional; that is, the basic configuration information may or may not include the connection method of the target database.
[0117] According to embodiments of this disclosure, the requirement to configure the target database connection method in the basic configuration information can be determined based on the output method of the target table structure. If the output method indicates that a table is created in the target database, the target database connection method needs to be configured in the basic configuration information; if the output method indicates that a table is not created in the target database, the target database connection method does not need to be configured in the basic configuration information.
[0118] According to embodiments of this disclosure, if the configuration information includes a connection method for the target database, the output method can indicate that a table is created in the target database. Therefore, the target database can be connected according to the connection method, and a table can be created in the target database according to the target table structure. If the configuration information does not include a connection method for the target database, the output method can indicate direct text output, i.e., no table is created in the target database. In this case, text information corresponding to the target table structure can be generated.
[0119] According to embodiments of this disclosure, the corresponding output method can be selected based on whether the target database connection method exists in the configuration information, so as to output the target table structure according to the corresponding output method.
[0120] According to embodiments of this disclosure, determining a conversion function based on the type of the source database and the type of the target database in the configuration information includes: obtaining a table structure mapping relationship between the source database and the target database based on the type of the source database and the type of the target database; and determining a conversion function based on the table structure mapping relationship.
[0121] According to embodiments of this disclosure, the table structure mapping relationship between the source database and the target database can be determined based on their types. This table structure mapping relationship can include the mapping relationship between different parts of the table structure between the source database and the target database.
[0122] According to embodiments of this disclosure, a suitable conversion function for table structure conversion between the source database and the target database can be determined based on the table structure mapping relationship, so as to use the conversion function to convert the result of the table to be converted into the target table structure.
[0123] Figure 6 A flowchart illustrating the implementation of table structure conversion between databases according to an embodiment of the present disclosure is shown.
[0124] like Figure 6 As shown, the method includes operations S610 to S670.
[0125] When operating the S610, obtain basic configuration information.
[0126] According to an embodiment of this disclosure, operation S610 is consistent with operation S210 described above.
[0127] During operation of S620, obtain the structure of the table to be converted.
[0128] According to an embodiment of this disclosure, operation S620 is consistent with operation S220 described above.
[0129] In operation S630, determine the conversion function.
[0130] According to an embodiment of this disclosure, operation S630 is consistent with operation S230 described above.
[0131] By operating S640, the target table structure is obtained.
[0132] According to an embodiment of this disclosure, operation S640 is consistent with operation S240 described above.
[0133] According to embodiments of this disclosure, when target configuration information exists, the table structure to be converted can be converted according to the conversion function and the target configuration information to obtain the target table structure; when target configuration information does not exist, the table structure to be converted can be directly converted according to the conversion function to obtain the target table structure.
[0134] When operating S650, determine whether to create a table in the target database.
[0135] According to embodiments of this disclosure, if it is necessary to create a table in the target database, operation S660 is performed; if it is not necessary to create a table in the target database, operation S670 is performed.
[0136] When operating the S660, connect to the target database and create tables.
[0137] According to embodiments of this disclosure, when it is necessary to create tables in a target database, the target database can be connected according to the connection method of the target database in the basic configuration information, so as to create tables in the target database according to the target table structure.
[0138] When operating the S670, text information is generated.
[0139] According to embodiments of this disclosure, text information corresponding to the target table structure can be directly generated without needing to create a table in the target database.
[0140] Based on the above-described method for converting table structures between databases, this disclosure also provides a device for converting table structures between databases. The following will be combined with... Figure 7 The device is described in detail.
[0141] Figure 7 A schematic block diagram of a database table structure conversion apparatus according to an embodiment of the present disclosure is shown.
[0142] like Figure 7 As shown, the database table structure conversion device 700 of this embodiment includes a first acquisition module 710, a second acquisition module 720, a determination module 730 and a conversion module 740.
[0143] The first acquisition module 710 is used to configure configuration information corresponding to the source database and the target database. In one embodiment, the first acquisition module 710 can be used to perform the operation S210 described above, which will not be repeated here.
[0144] The second acquisition module 720 is used to connect to the source database according to the connection method of the source database in the configuration information, so as to obtain the table structure to be converted from the source database. In one embodiment, the second acquisition module 720 can be used to perform the operation S220 described above, which will not be repeated here.
[0145] The determining module 730 is used to determine the conversion function based on the type of the source database and the type of the target database in the configuration information. In one embodiment, the determining module 730 can be used to perform the operation S230 described above, which will not be repeated here.
[0146] The conversion module 740 is used to convert the table structure to be converted using a conversion function to obtain the target table structure corresponding to the target database. In one embodiment, the conversion module 740 can be used to perform the operation S240 described above, which will not be repeated here.
[0147] According to embodiments of this disclosure, the conversion module 740 includes a first determining unit, a second determining unit, a first conversion unit, and a second conversion unit.
[0148] The first determining unit is used to determine the conversion rule corresponding to each target table structure to be converted, based on the target configuration information, when the target configuration information exists in the configuration information. The target table structure to be converted is determined from multiple table structures to be converted.
[0149] The second determining unit is used to determine the first target to be converted information and the second target to be converted information from the target to be converted table structure according to the target configuration information, wherein the first target to be converted information corresponds to the target configuration information and the second target to be converted information corresponds to the conversion function.
[0150] The first conversion unit is used to convert the first target information to be converted in the target table structure according to the conversion rules corresponding to the target table structure to be converted, so as to obtain the initial table structure.
[0151] The second conversion unit is used to convert the second target information to be converted in the initial table structure according to the conversion function to obtain the target table structure.
[0152] According to embodiments of this disclosure, the conversion module 740 further includes a third conversion unit.
[0153] The third conversion unit is used to convert the target information to be converted in the target information to be converted table structure according to the conversion function when the target information is not present in the configuration information, so as to obtain the target table structure.
[0154] According to embodiments of this disclosure, the first determining unit includes a first determining subunit.
[0155] The first determining subunit is used to determine the target table structure corresponding to each user from multiple table structures to be converted, when the conversion method in the configuration information represents the user level. The target table structure to be converted includes at least one table structure to be converted.
[0156] According to embodiments of this disclosure, the first determining unit further includes a second determining subunit.
[0157] The second determining subunit is used to determine the target table structure to be converted for each table from multiple table structures to be converted, given that the conversion method in the configuration information represents the table level. The target table structure to be converted represents the table structure to be converted.
[0158] According to embodiments of this disclosure, the database table structure conversion device 700 further includes a connection module and a generation module.
[0159] The connection module is used to connect to the target database according to the connection method specified in the configuration information, so as to create tables in the target database according to the target table structure.
[0160] The generation module is used to generate text information corresponding to the target table structure when the connection method of the target database is not specified in the configuration information.
[0161] According to embodiments of this disclosure, the determining module 730 includes an obtaining unit and a third determining unit.
[0162] The obtaining unit is used to obtain the table structure mapping relationship between the source database and the target database based on the type of the source database and the type of the target database.
[0163] The third determining unit is used to determine the transformation function based on the table structure mapping relationship.
[0164] According to embodiments of this disclosure, any plurality of modules among the first acquisition module 710, the second acquisition module 720, the determination module 730, and the conversion module 740 may be combined into one module, or any one of these modules may be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of other modules and implemented in one module. According to embodiments of this disclosure, at least one of the first acquisition module 710, the second acquisition module 720, the determination module 730, and the conversion module 740 may be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging the circuitry, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in a suitable combination of any of these. Alternatively, at least one of the first acquisition module 710, the second acquisition module 720, the determination module 730, and the conversion module 740 may be implemented at least partially as a computer program module, which can perform corresponding functions when the computer program module is run.
[0165] Figure 8 A block diagram schematically illustrates an electronic device suitable for implementing a method for converting table structures between databases according to an embodiment of the present disclosure.
[0166] like Figure 8 As shown, an electronic device 800 according to an embodiment of this disclosure includes a processor 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage portion 808 into a random access memory (RAM) 803. The processor 801 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 801 may also include onboard memory for caching purposes. The processor 801 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of this disclosure.
[0167] RAM 803 stores various programs and data required for the operation of electronic device 800. Processor 801, ROM 802, and RAM 803 are interconnected via bus 804. Processor 801 performs various operations of the method flow according to embodiments of the present disclosure by executing programs in ROM 802 and / or RAM 803. It should be noted that the programs may also be stored in one or more memories other than ROM 802 and RAM 803. Processor 801 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in said one or more memories.
[0168] According to embodiments of this disclosure, the electronic device 800 may further include an input / output (I / O) interface 805, which is also connected to a bus 804. The electronic device 800 may also include one or more of the following components connected to the input / output (I / O) interface 805: an input section 806 including a keyboard, mouse, etc.; an output section 807 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the input / output (I / O) interface 805 as needed. A removable medium 811, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 810 as needed so that computer programs read from it can be installed into the storage section 808 as needed.
[0169] This disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs that, when executed, implement the method according to the embodiments of this disclosure.
[0170] According to embodiments of this disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, such as including, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this disclosure, the computer-readable storage medium may include ROM 802 and / or RAM 803 and / or one or more memories other than ROM 802 and RAM 803 described above.
[0171] Embodiments of this disclosure also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code is used to cause the computer system to implement the item recommendation method provided in the embodiments of this disclosure.
[0172] When the computer program is executed by the processor 801, it performs the functions defined in the system / apparatus of this disclosure embodiments. According to embodiments of this disclosure, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0173] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and may be downloaded and installed via the communication section 809, and / or installed from a removable medium 811. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0174] In such an embodiment, the computer program can be downloaded and installed from a network via communication section 809, and / or installed from removable medium 811. When the computer program is executed by processor 801, it performs the functions defined in the system of this disclosure embodiment. According to embodiments of this disclosure, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0175] According to embodiments of this disclosure, program code for executing the computer programs provided in embodiments of this disclosure can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can execute entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0176] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0177] Those skilled in the art will understand that the features described in the various embodiments and / or claims of this disclosure can be combined or combined in various ways, even if such combinations or combinations are not explicitly described in this disclosure. In particular, the features described in the various embodiments and / or claims of this disclosure can be combined or combined in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or combinations fall within the scope of this disclosure.
[0178] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. The scope of this disclosure is defined by the appended claims and their equivalents. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.
Claims
1. A method for converting table structures between databases, comprising: Retrieve the configuration information corresponding to the source and target databases; According to the connection method of the source database in the configuration information, connect to the source database to obtain the table structure to be converted from the source database; The conversion function is determined based on the type of the source database and the type of the target database as described in the configuration information; as well as The conversion function is used to convert the table structure to be converted, thereby obtaining the target table structure corresponding to the target database. The table structure to be converted is multiple, and the conversion function is used to convert the table structure to obtain the target table structure corresponding to the target database, including: If target configuration information exists in the configuration information, for each target table structure to be converted, a conversion rule corresponding to the target table structure to be converted is determined according to the target configuration information, wherein the target table structure to be converted is determined from multiple table structures to be converted; Based on the target configuration information, a first target conversion information and a second target conversion information are determined from the target conversion table structure, wherein the first target conversion information corresponds to the target configuration information and the second target conversion information corresponds to the conversion function; According to the conversion rules corresponding to the target table structure to be converted, the first target information to be converted in the target table structure to be converted is converted to obtain the initial table structure; The second target information to be converted in the initial table structure is converted according to the conversion function to obtain the target table structure.
2. The method according to claim 1, further comprising: If the target configuration information is not present in the configuration information, the target information to be converted in the target table structure is converted according to the conversion function to obtain the target table structure.
3. The method according to claim 1, wherein, The target table structure to be converted is determined from a plurality of table structures to be converted, including: When the conversion method in the configuration information represents the user level, a target conversion table structure corresponding to each user is determined from the plurality of conversion table structures, wherein the target conversion table structure includes at least one of the conversion table structures.
4. The method according to claim 3, further comprising: When the conversion method in the configuration information represents the table level, a target table structure corresponding to each table is determined from the plurality of table structures to be converted, wherein the target table structure represents the table structure to be converted.
5. The method according to claim 1, further comprising: If the connection method of the target database is present in the configuration information, the target database is connected according to the connection method of the target database, and a table is created in the target database according to the target table structure; as well as If the connection method of the target database is not specified in the configuration information, text information corresponding to the target table structure is generated.
6. The method according to claim 1, wherein, The step of determining the conversion function based on the type of the source database and the type of the target database in the configuration information includes: Based on the type of the source database and the type of the target database, the table structure mapping relationship between the source database and the target database is obtained; and The transformation function is determined based on the mapping relationship of the table structure.
7. A device for converting table structures between databases, comprising: The first acquisition module is used to acquire configuration information corresponding to the source database and the target database; The second acquisition module is used to connect to the source database according to the connection method of the source database in the configuration information, so as to obtain the table structure to be converted from the source database; The determination module is used to determine the conversion function based on the type of the source database and the type of the target database in the configuration information; as well as The conversion module is used to convert the table structure to be converted using the conversion function to obtain the target table structure corresponding to the target database; The table to be converted has multiple structures, and the conversion module includes a first determining unit, a second determining unit, a first conversion unit, and a second conversion unit. The first determining unit is configured to, when target configuration information exists in the configuration information, determine, for each target table structure to be converted, a conversion rule corresponding to the target table structure to be converted based on the target configuration information, wherein the target table structure to be converted is determined from a plurality of table structures to be converted; The second determining unit is configured to determine, based on the target configuration information, first target conversion information and second target conversion information from the target conversion table structure, wherein the first target conversion information corresponds to the target configuration information and the second target conversion information corresponds to the conversion function. The first conversion unit is used to convert the first target information to be converted in the target table structure according to the conversion rules corresponding to the target table structure to be converted, so as to obtain an initial table structure. The second conversion unit is used to convert the second target information to be converted in the initial table structure according to the conversion function to obtain the target table structure.
8. An electronic device, comprising: One or more processors; Storage device for storing one or more programs. Wherein, when the one or more programs are executed by the one or more processors, the one or more processors perform the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the method according to any one of claims 1 to 6.
10. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Table creation method, device and equipment, and storage medium
CN111291049A