CN114116877B - Data conversion method, device, computer equipment and medium - Google Patents

Data conversion method, device, computer equipment and medium Download PDF

Info

Publication number
CN114116877B
CN114116877B CN202210089097.2A CN202210089097A CN114116877B CN 114116877 B CN114116877 B CN 114116877B CN 202210089097 A CN202210089097 A CN 202210089097A CN 114116877 B CN114116877 B CN 114116877B
Authority
CN
China
Prior art keywords
data
converted
target
conversion
serialized
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210089097.2A
Other languages
Chinese (zh)
Other versions
CN114116877A (en
Inventor
崔光
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Weixun Information Technology Co ltd
Original Assignee
Shenzhen Weixun Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Weixun Information Technology Co ltd filed Critical Shenzhen Weixun Information Technology Co ltd
Priority to CN202210089097.2A priority Critical patent/CN114116877B/en
Publication of CN114116877A publication Critical patent/CN114116877A/en
Application granted granted Critical
Publication of CN114116877B publication Critical patent/CN114116877B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/258Data format conversion from or to a database

Abstract

The application provides a data conversion method, a data conversion device, computer equipment and a medium, wherein firstly, a data set to be converted is obtained from a data table of a database to be converted; then, determining data conversion grammar matched with the type of the target database from a preset data conversion grammar library according to the type of the target database; generating a target data set from the data set to be converted based on the data conversion grammar; and finally, storing the target data set to a target data table in the target database. The method comprises the steps of determining a data conversion grammar matched with the type of a target database from a preset data conversion grammar library based on the type of the target database, and generating a target data set from a data set to be converted by using the data conversion grammar.

Description

Data conversion method, device, computer equipment and medium
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a method and an apparatus for data conversion, a computer device, and a medium.
Background
With the rapid development of database technology, data such as social media, production equipment and products produced by the production equipment are increasing, the data are usually stored in various databases, some are stored in a traditional relational database, some are stored in a file system, and due to the requirements of system backup, upgrading, data exchange or data sharing, and due to different requirements and environments of users, the types and versions of databases used by the users are various, and sometimes data conversion between various databases is needed. However, the database conversion method in the prior art is relatively fixed and single, and the problem of incompatibility of data structures and data types is easily caused when the data conversion method in the prior art is used, and mutual switching of multiple types of databases cannot be realized, so how to realize flexible switching between different databases, and the problem of low conversion efficiency when data is converted between different types of databases in the prior art is solved.
Disclosure of Invention
In view of this, embodiments of the present application provide a method, an apparatus, a computer device, and a medium for data conversion, so as to solve the problem in the prior art that conversion efficiency is low when data is converted in different types of databases.
In a first aspect, an embodiment of the present application provides a method for data conversion, where the method includes:
acquiring a data set to be converted from a data table of a database to be converted;
determining data conversion grammar matched with the type of the target database from a preset data conversion grammar library according to the type of the target database;
generating a target data set from the data set to be converted based on the data conversion grammar;
storing the target data set to a target data table in the target database.
Optionally, the generating a target data set from the data set to be converted based on the data conversion syntax includes:
converting the format of the data set to be converted into a target format corresponding to the target data table;
analyzing the data set to be converted in the target format according to a preset analysis algorithm;
carrying out serialization processing on the analyzed data set to be converted to obtain a serialized object set;
generating a target data set from the set of serialized objects based on the data transformation syntax.
Optionally, the analyzed data set to be converted includes at least one object to be converted and a data subset to be converted corresponding to each object to be converted; the serializing the analyzed data set to be converted to obtain a serialized object set includes:
for each conversion data in the to-be-converted data subset corresponding to each to-be-converted object, performing serialization processing on each data item in the conversion data and a value matched with the data item to obtain a serialized object corresponding to the conversion data; the data subsets to be converted, which correspond to the objects to be converted respectively, comprise at least one piece of conversion data;
taking the serialized objects corresponding to all the conversion data in the to-be-converted data subset corresponding to each to-be-converted object as the serialized object subsets corresponding to the to-be-converted objects;
and taking the serialized object subsets corresponding to all the objects to be converted as serialized object sets.
Optionally, the generating a target data set from the serialized object set based on the data conversion syntax includes:
for each serialized object in each serialized object subset, generating target data corresponding to the serialized object for the serialized object based on the data conversion syntax;
taking the target data corresponding to all the serialized objects in each serialized object subset as the target data subset corresponding to the serialized object subset;
and taking the target data subsets corresponding to all the serialized object subsets as target data sets.
Optionally, before acquiring the set of data to be converted from the data table of the database to be converted, the method further includes:
acquiring a data conversion instruction; the data conversion instruction comprises a database to be converted where a data table of the data to be converted is located and a target database where a target data table is located.
In a second aspect, the present application provides an apparatus for data conversion, comprising:
the acquisition module is used for acquiring a data set to be converted from a data table of the database to be converted;
the determining module is used for determining data conversion grammar matched with the type of the target database from a preset data conversion grammar library according to the type of the target database;
the generating module is used for generating a target data set from the data set to be converted based on the data conversion grammar;
and the storage module is used for storing the target data set to a target data table in the target database.
Optionally, the generating module includes:
the conversion unit is used for converting the format of the data set to be converted into a target format corresponding to the target data table;
the analysis unit is used for analyzing the data set to be converted in the target format according to a preset analysis algorithm;
the serialization processing unit is used for carrying out serialization processing on the analyzed data set to be converted to obtain a serialization object set;
a generating unit to generate a target data set from the set of serialized objects based on the data conversion syntax.
Optionally, the analyzed data set to be converted includes at least one object to be converted and a data subset to be converted corresponding to each object to be converted; the serialization processing unit comprises:
the first serialization processing unit is used for carrying out serialization processing on each data item in the conversion data and a value matched with the data item aiming at each conversion data in the to-be-converted data subset corresponding to each to-be-converted object to obtain a serialization object corresponding to the conversion data; the data subsets to be converted, which correspond to the objects to be converted respectively, comprise at least one piece of conversion data;
the second processing unit is used for taking the serialized objects corresponding to all the conversion data in the to-be-converted data subsets corresponding to the to-be-converted objects as the serialized object subsets corresponding to the to-be-converted objects;
and the third processing unit is used for taking the serialized object subsets corresponding to all the objects to be converted as serialized object sets.
Optionally, the generating unit includes:
a first generating unit, configured to generate, for each serialized object in each serialized object subset, target data corresponding to the serialized object based on the data conversion syntax for the serialized object;
the second generation unit is used for taking the target data corresponding to all the serialization objects in each serialization object subset as the target data subset corresponding to the serialization object subset;
and a third generating unit, configured to use the target data subsets corresponding to all the serialized object subsets as target data sets.
Optionally, the obtaining module further includes:
a first obtaining unit that obtains a data conversion instruction; the data conversion instruction comprises a database to be converted where a data table of the data to be converted is located and a target database where a target data table is located.
In a third aspect, the present application provides a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the above method when executing the computer program.
In a fourth aspect, the present application provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the above method.
The application provides a data conversion method, firstly, acquiring a data set to be converted from a data table of a database to be converted; then, determining data conversion grammar matched with the type of the target database from a preset data conversion grammar library according to the type of the target database; generating a target data set from the data set to be converted based on the data conversion grammar; and finally, storing the target data set to a target data table in the target database. The method and the device for converting the data in the different types of databases have the advantages that the data conversion grammar matched with the type of the target database is determined from the preset data conversion grammar library based on the type of the target database, and the data to be converted are collected to generate the target data set by using the data conversion grammar, so that the conversion efficiency when the data are converted in the different types of databases is improved.
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
To more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.
Fig. 1 is a flowchart illustrating a data conversion method according to an embodiment of the present application.
Fig. 2 is a schematic structural diagram of a data conversion apparatus according to an embodiment of the present application.
Fig. 3 is a flowchart illustrating a step S103 in a data conversion method according to an embodiment of the present application.
Fig. 4 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present application without making any creative effort, shall fall within the protection scope of the present application.
With the rapid development of database technology, data such as social media, production equipment and products produced by the production equipment are increasing, the data are usually stored in various databases, some are stored in a traditional relational database, some are stored in a file system, and due to the requirements of system backup, upgrading, data exchange or data sharing, and due to different requirements and environments of users, the types and versions of databases used by the users are various, and sometimes data conversion between various databases is needed. However, the database conversion method in the prior art is relatively fixed and single, and the problem of incompatibility of data structures and data types is easily caused when the data conversion method in the prior art is used, and mutual switching of multiple types of databases cannot be realized, so how to realize flexible switching between different databases, and the problem of low conversion efficiency when data is converted between different types of databases in the prior art is solved.
An embodiment of the present application provides a data conversion method, as shown in fig. 1, including the following steps:
s101, acquiring a data set to be converted from a data table of a database to be converted;
s102, determining data conversion grammar matched with the type of a target database from a preset data conversion grammar library according to the type of the target database;
s103, generating a target data set from the data set to be converted based on the data conversion grammar;
s104, storing the target data set to a target data table in the target database.
In a specific implementation, if there are too many data sets to be converted and the data sets to be converted are to be stored in different types of databases, when the data sets to be converted are obtained, the database where the data sets to be converted are located needs to be found from a plurality of data tables in the databases of different types each time, based on this way, in order to improve the processing performance of the entire system and to quickly find the database where the data sets to be converted are located, before the above-mentioned obtaining the data sets to be converted from the data tables in the databases to be converted is performed, step S101 further includes:
s001, acquiring a data conversion instruction; the data conversion instruction comprises a database to be converted where a data table of the data set to be converted is located and a target database where a target data table is located.
In step S001, the data conversion command is a command input by the user at the user end for specifying a data table in the database to be converted into a data table in another database. The data set to be converted is a data set which needs data conversion. The database to be converted is used for storing a data set to be converted and a data table where the data set to be converted is located, wherein the database to be converted comprises at least one data table. The target database is used for storing the data set to be converted which is converted into the target data set, and the data table where the target data set is located.
Specifically, the server may obtain the data conversion instruction sent by the user side through the data conversion instruction obtaining module, where the user side may use a smart phone, a tablet, a computer, and the like, which is not limited in the present application.
In the step S101, specifically, the server obtains the data set to be converted from the data table of the data set to be converted according to the information of the data table of the data set to be converted carried in the received data conversion instruction and the information of the target database of the target data table.
For example, according to the received data conversion instruction, if the information carried in the data conversion instruction is that the data table a where the data set to be converted is located is stored in the database a to be converted and the target database B where the target data table a is located, the server obtains the data set to be converted from the data table a in the data a to be converted.
In step S102, the preset data conversion grammar library stores data conversion grammars corresponding to different types of databases. The data conversion grammar matched with the type of the target database means that the type corresponding to the data conversion grammar is the same as the type of the target database, wherein the data conversion grammar is used for converting the specified data set to be converted into the target data set conforming to the type of the target database.
Specifically, the server finds the data conversion grammar with the same type as that of the target database corresponding to the data conversion grammar from the multiple types of data conversion grammars in the preset data conversion grammar library.
For example, if the type of the target database is type C, the corresponding type of the target database is type C. The preset data conversion grammar library has a type A data conversion grammar a, a type B data conversion grammar B, a type C data conversion grammar C … … and a type Z data conversion grammar Z, so that the type corresponding to the data conversion C is the same as the type corresponding to the target database and is C type, and the data conversion grammar C is used as the data conversion grammar matched with the type of the target database.
As shown in fig. 3, in order to understand in more detail the process of generating the target data set from the data set to be converted based on the data conversion syntax, step S103 includes:
step 1031, converting the format of the data set to be converted into a target format corresponding to the target data table;
step 1032, analyzing the data set to be converted in the target format according to a preset analysis algorithm;
1033, serializing the analyzed data set to be converted to obtain a serialized object set;
step 1034, generate a target data set from the set of serialized objects based on the data transformation syntax.
In step 1031, the target format corresponding to the target data table is generally the Json format or CSV format, and the file structure using these formats is relatively simple and clear, and the file volume is relatively small, so that when the data to be converted in the target format is uploaded to the server, the transmission speed can be increased.
Specifically, after receiving the data set to be converted, the server converts the format of the data set to be converted into the Json format or the CSV format, and a format conversion method is described in detail in the prior art, and will not be described in more detail here.
In step 1032, the preset parsing algorithm is a pre-programmed parsing algorithm for parsing the data set to be converted in the target format.
In particular, the data set to be converted in the target format usually has a fixed composition rule, i.e., is composed of character strings, wherein the character strings are composed of english letters, symbols, numbers and the like. And based on the composition rules, pre-writing an analysis algorithm for analyzing the data set to be converted in the target format, analyzing the data set to be converted in the target format according to the composition rules of the data set to be converted in the target format by the server according to the preset analysis algorithm, and decomposing the data set to be converted in the target format into one object to be converted and a data subset to be converted corresponding to each object to be converted.
In order to understand in more detail that the parsed data set to be converted includes at least one object to be converted and a data subset to be converted corresponding to each object to be converted; the step 1033 of serializing the analyzed data set to be converted to obtain a serialized object set includes:
step 10331, for each piece of transformation data in the subset of the to-be-transformed data corresponding to each respective object to be transformed, serializing each data item in the transformation data and the value matched with the data item to obtain a serialized object corresponding to the transformation data; the data subsets to be converted, which correspond to the objects to be converted respectively, comprise at least one piece of conversion data;
step 10332, taking the serialized objects corresponding to all the conversion data in the to-be-converted data subset corresponding to each to-be-converted object as the serialized object subsets corresponding to the to-be-converted object;
step 10333, using the subset of the serialized objects corresponding to all the objects to be converted as the set of serialized objects.
In step 10331, each object to be converted refers to the same type of object to be subjected to data conversion, such as all students in a certain class, part of enterprises under a certain brand, and so on, which should not be construed as a limitation of the present application. The data subset to be converted corresponding to each object to be converted is composed of a plurality of pieces of conversion data, and the conversion data is used for distinguishing each object in the objects to be converted. And the serialization processing is to analyze the name of each data item in each conversion data in the to-be-converted data subset corresponding to each to-be-converted object and a value matched with each data item.
Specifically, the server obtains all objects to be converted and a to-be-converted data subset corresponding to each object to be converted, and performs serialization processing on each data item in each converted data item in the to-be-converted data subset corresponding to each object to be converted and a value matched with the data item according to all converted data in the to-be-converted data subset corresponding to each object to be converted to generate a serialized object corresponding to each converted data item.
For example, taking an object to be converted as an example, the object to be converted is a Student, a subset of data to be converted corresponding to the object to be converted contains 3 pieces of conversion data, where the 3 pieces of conversion data are "name: Leo, height:180, weight: 65", "name: Emma, height:163, weight: 48", "name: Ella, height:158, and weight: 52", respectively, and the serialized objects generated according to the conversion data "name: Leo, height:180, and weight: 65" are Student Leo, height:180, and weight: 65. The serialized objects generated according to the conversion data 'name: Emma, height:163 and weight: 48' are Student Emma: name: Emma, height:163 and weight: 48. The serialized objects generated according to the conversion data "name: Ella, height:158 and weight: 52" are Student Ella, name: Ella, height:158 and weight: 52.
In step 10332, the server uses the serialized objects corresponding to each piece of transformation data in the to-be-transformed data subsets corresponding to each piece of object to be transformed as the serialized object subsets corresponding to the to-be-transformed objects.
For example, taking an object to be converted as an example, the object to be converted is a Student, and the serialized objects corresponding to all the converted data in the data subset to be converted corresponding to the object to be converted respectively have 3 items, so that the serialized objects are Student name: Leo, height:180, weight:65, the serialized objects are Student Emma name: Emma, height:163, weight:48, the serialized objects are Student Ella name: Ella, height:158, and weight: 52. Therefore, the serialization subset Student corresponding to the object to be converted comprises the three serialization objects, namely Student Leo and Student Emma, and the serialization subset Student corresponding to the object to be converted, namely Student Ella.
In step 1033, the server generates a set of serialized objects according to the subset of serialized objects corresponding to each object to be transformed.
For example, taking two objects to be transformed as an example, a first object to be transformed is a Student, a second object to be transformed is a Company, a serialization subset corresponding to the first object to be transformed is the Student, and a serialization subset corresponding to the second object to be transformed is the Company, so that the serialization object set includes the serialization subset Student and the serialization subset Company. And the serialization subset Student comprises 3 serialization objects, and the serialization subset Company comprises 5 serialization objects, so that the serialization set comprises 8 serialization objects in total.
Based on this, in the step 1034, the target data set is generated from the serialized object set based on the data conversion syntax, and the following steps may be specifically performed:
step 10341, for each serialized object in each serialized object subset, generating the serialized object into target data corresponding to the serialized object based on the data conversion syntax;
step 10342, taking the target data corresponding to all the serialized objects in each serialized object subset as the target data subset corresponding to the serialized object subset;
step 10343, the target data subsets corresponding to all the serialized object subsets are used as the target data set.
At step 10341, the server generates target data corresponding to each serialized object in accordance with the data transformation grammar and each serialized object in each of the serialized object subsets.
Specifically, when the target database is of a C type, the data conversion grammar C is used as a data conversion grammar matched with the type of the target database, taking serialized objects Student in a serialized subset Student as example, name: Leo, height:180, weight:65 and serialized object Student ma: name: Emma, height:163 and weight:48, inputting the serialized object Student Leo into the data conversion grammar C to obtain target data A corresponding to the serialized object Student Leo, and inputting the serialized object Student ma into the data conversion grammar C to obtain target data B corresponding to the serialized object Student Emma.
In step 10342, the server obtains a target data subset corresponding to each serialized object subset according to the target data of the respective object of all the serialized objects in each serialized object subset.
For example, taking a serialized object subset Student as an example, 2 serialized objects are shared in the serialized object subset Student, and each of the 2 serialized objects corresponds to target data a and target data B, so that the target data subset corresponding to the serialized object subset Student contains the target data a and the target data B; similarly, taking the serialized object subset Company as an example, there are 3 serialized objects in total, and these 3 serialized objects correspond to the target data E, the target data K, and the target data L respectively, so that the corresponding target data subset of the serialized object subset Company includes the target data E, the target data K, and the target data L.
At step 10343, the server generates a full set of target data based on the corresponding target data subsets for each of all of the subsets of serialized objects.
For example, taking 2 subsets of serialized objects as an example, the 1 st subset of serialized objects is Student, and the 2 nd subset of serialized objects is Company, so the target data subset corresponding to the Student of the serialized object subset in the target data set and the target data subset corresponding to the Company of the serialized object subset. The target data subset corresponding to the serialization object subset Student includes target data a and target data B, and the target data subset corresponding to the serialization object subset Company includes target data E, target data K, and target data L, so that the target data set includes the above-mentioned 5 pieces of target data.
In step S104, the server stores the target data set in a target data table of the target database.
According to the data conversion method provided by the embodiment of the application, through the steps, the server acquires the data set to be converted from the data table of the database to be converted; then, determining data conversion grammar matched with the type of the target database from a preset data conversion grammar library according to the type of the target database; generating a target data set from the data set to be converted based on the data conversion grammar; and finally, storing the target data set to a target data table in the target database. The method and the device for converting the data in the different types of databases have the advantages that the data conversion grammar matched with the type of the target database is determined from the preset data conversion grammar library based on the type of the target database, and the data to be converted are collected to generate the target data set by using the data conversion grammar, so that the conversion efficiency when the data are converted in the different types of databases is improved.
Referring to fig. 2, a schematic structural diagram of an apparatus 200 for identifying an enterprise identifier provided in an embodiment of the present application is shown, where the apparatus includes: the device comprises an acquisition module 201, a determination module 202, a generation module 203 and a storage module 204, specifically:
an obtaining module 201, configured to obtain a data set to be converted from a data table of a database to be converted;
the determining module 202 is configured to determine, according to the type of the target database, a data conversion grammar matched with the type of the target database from a preset data conversion grammar library;
a generating module 203, configured to generate a target data set from the data set to be converted based on the data conversion syntax;
a storage module 204, configured to store the target data set to a target data table in the target database.
Optionally, the generating module includes:
the conversion unit is used for converting the format of the data set to be converted into a target format corresponding to the target data table;
the analysis unit is used for analyzing the data set to be converted in the target format according to a preset analysis algorithm;
the serialization processing unit is used for carrying out serialization processing on the analyzed data set to be converted to obtain a serialization object set;
a generating unit to generate a target data set from the set of serialized objects based on the data conversion syntax.
Optionally, the analyzed data set to be converted includes at least one object to be converted and a data subset to be converted corresponding to each object to be converted; the serialization processing unit comprises:
the first serialization processing unit is used for carrying out serialization processing on each data item in the conversion data and a value matched with the data item aiming at each conversion data in the to-be-converted data subset corresponding to each to-be-converted object to obtain a serialization object corresponding to the conversion data; the data subsets to be converted, which correspond to the objects to be converted respectively, comprise at least one piece of conversion data;
the second processing unit is used for taking the serialized objects corresponding to all the conversion data in the to-be-converted data subsets corresponding to the to-be-converted objects as the serialized object subsets corresponding to the to-be-converted objects;
and the third processing unit is used for taking the serialized object subsets corresponding to all the objects to be converted as serialized object sets.
Optionally, the generating unit includes:
a first generating unit, configured to generate, for each serialized object in each serialized object subset, target data corresponding to the serialized object based on the data conversion syntax for the serialized object;
the second generation unit is used for taking the target data corresponding to all the serialization objects in each serialization object subset as the target data subset corresponding to the serialization object subset;
and a third generating unit, configured to use the target data subsets corresponding to all the serialized object subsets as target data sets.
Optionally, the obtaining module further includes:
a first obtaining unit that obtains a data conversion instruction; the data conversion instruction comprises a database to be converted where a data table of the data to be converted is located and a target database where a target data table is located.
Corresponding to a method of data conversion in fig. 1, an embodiment of the present application further provides a computer device 400, as shown in fig. 4, the device includes a memory 401, a processor 402, and a computer program stored on the memory 401 and executable on the processor 402, wherein the processor 402 implements the steps of the method of feedback data conversion when executing the computer program.
Specifically, the memory 401 and the processor 402 can be general memories and processors, which are not specifically limited herein, and when the processor 402 runs a computer program stored in the memory 401, the method for converting the identification data can be executed, first, acquiring a data set to be converted from a data table of a database to be converted; then, determining data conversion grammar matched with the type of the target database from a preset data conversion grammar library according to the type of the target database; generating a target data set from the data set to be converted based on the data conversion grammar; and finally, storing the target data set to a target data table in the target database. The method and the device for converting the data in the different types of databases have the advantages that the data conversion grammar matched with the type of the target database is determined from the preset data conversion grammar library based on the type of the target database, and the data to be converted are collected to generate the target data set by using the data conversion grammar, so that the conversion efficiency when the data are converted in the different types of databases is improved.
Corresponding to the method of identification data conversion in fig. 1, the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to perform the steps of the method of identification data conversion.
Specifically, the storage medium can be a sufficient storage medium, such as a removable disk, a hard disk, and the like, and when a computer program on the storage medium is executed, the method for data conversion can be executed, which solves the problem of low efficiency of conversion of different types of data in the prior art, and first, a data set to be converted is obtained from a data table of a database to be converted; then, determining data conversion grammar matched with the type of the target database from a preset data conversion grammar library according to the type of the target database; generating a target data set from the data set to be converted based on the data conversion grammar; and finally, storing the target data set to a target data table in the target database so as to improve the conversion efficiency when the data are converted in different types of databases.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments provided in the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus once an item is defined in one figure, it need not be further defined and explained in subsequent figures, and moreover, the terms "first", "second", "third", etc. are used merely to distinguish one description from another and are not to be construed as indicating or implying relative importance.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present application, and are used for illustrating the technical solutions of the present application, but not limiting the same, and the scope of the present application is not limited thereto, and although the present application is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope disclosed in the present application; such modifications, changes or substitutions do not depart from the spirit and scope of the present disclosure, which should be construed in light of the above teachings. Are intended to be covered by the scope of this application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (7)

1. A method of data conversion, comprising:
acquiring a data set to be converted from a data table of a database to be converted;
determining data conversion grammar matched with the type of the target database from a preset data conversion grammar library according to the type of the target database;
generating a target data set from the data set to be converted based on the data conversion grammar;
storing the target data set to a target data table in the target database;
generating a target data set from the data set to be converted based on the data conversion grammar, including:
converting the format of the data set to be converted into a target format corresponding to the target data table;
analyzing the data set to be converted in the target format according to a preset analysis algorithm;
carrying out serialization processing on the analyzed data set to be converted to obtain a serialized object set; the serialization processing is to analyze the name of each data item in each conversion data in the to-be-converted data subset corresponding to each to-be-converted object and a value matched with each data item;
generating a target data set from the set of serialized objects based on the data transformation syntax;
the analyzed data set to be converted comprises at least one object to be converted and a data subset to be converted corresponding to each object to be converted; the serializing the analyzed data set to be converted to obtain a serialized object set includes:
for each conversion data in the to-be-converted data subset corresponding to each to-be-converted object, performing serialization processing on each data item in the conversion data and a value matched with the data item to obtain a serialized object corresponding to the conversion data; the data subsets to be converted, which correspond to the objects to be converted respectively, comprise at least one piece of conversion data;
taking the serialized objects corresponding to all the conversion data in the to-be-converted data subset corresponding to each to-be-converted object as the serialized object subsets corresponding to the to-be-converted objects;
and taking the serialized object subsets corresponding to all the objects to be converted as serialized object sets.
2. The method of data transformation according to claim 1, wherein the generating the set of serialized objects into a target set of data based on the data transformation syntax comprises:
for each serialized object in each serialized object subset, generating target data corresponding to the serialized object for the serialized object based on the data conversion syntax;
taking the target data corresponding to all the serialized objects in each serialized object subset as the target data subset corresponding to the serialized object subset;
and taking the target data subsets corresponding to all the serialized object subsets as target data sets.
3. The method of data conversion according to claim 1, wherein before the obtaining the set of data to be converted from the data table of the database to be converted, the method further comprises:
acquiring a data conversion instruction; the data conversion instruction comprises a database to be converted where a data table of the data set to be converted is located and a target database where a target data table is located.
4. An apparatus for data conversion, comprising:
the acquisition module is used for acquiring a data set to be converted from a data table of the database to be converted;
the determining module is used for determining data conversion grammar matched with the type of the target database from a preset data conversion grammar library according to the type of the target database;
the generating module is used for generating a target data set from the data set to be converted based on the data conversion grammar;
the storage module is used for storing the target data set to a target data table in the target database;
the generation module comprises:
the conversion unit is used for converting the format of the data set to be converted into a target format corresponding to the target data table;
the analysis unit is used for analyzing the data set to be converted in the target format according to a preset analysis algorithm;
the serialization processing unit is used for carrying out serialization processing on the analyzed data set to be converted to obtain a serialization object set; the serialization processing is to analyze the name of each data item in each conversion data in the to-be-converted data subset corresponding to each to-be-converted object and a value matched with each data item;
a generating unit for generating a target data set from the serialized object set based on the data conversion syntax;
the analyzed data set to be converted comprises at least one object to be converted and a data subset to be converted corresponding to each object to be converted; the serialization processing unit comprises:
the first serialization processing unit is used for carrying out serialization processing on each data item in the conversion data and a value matched with the data item aiming at each conversion data in the to-be-converted data subset corresponding to each to-be-converted object to obtain a serialization object corresponding to the conversion data; the data subsets to be converted corresponding to the objects to be converted respectively comprise at least one piece of conversion data;
the second processing unit is used for taking the serialized objects corresponding to all the conversion data in the to-be-converted data subsets corresponding to the to-be-converted objects as the serialized object subsets corresponding to the to-be-converted objects;
and the third processing unit is used for taking the serialized object subsets corresponding to all the objects to be converted as serialized object sets.
5. The apparatus of claim 4, wherein the obtaining module is preceded by:
an acquisition unit configured to acquire a data conversion instruction; the data conversion instruction comprises a database to be converted where a data table of the data to be converted is located and a target database where a target data table is located.
6. A computer arrangement comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the method of any of the preceding claims 1-3 when executing the computer program.
7. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, is adapted to carry out the steps of the method according to any one of the preceding claims 1-3.
CN202210089097.2A 2022-01-26 2022-01-26 Data conversion method, device, computer equipment and medium Active CN114116877B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210089097.2A CN114116877B (en) 2022-01-26 2022-01-26 Data conversion method, device, computer equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210089097.2A CN114116877B (en) 2022-01-26 2022-01-26 Data conversion method, device, computer equipment and medium

Publications (2)

Publication Number Publication Date
CN114116877A CN114116877A (en) 2022-03-01
CN114116877B true CN114116877B (en) 2022-05-17

Family

ID=80361667

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210089097.2A Active CN114116877B (en) 2022-01-26 2022-01-26 Data conversion method, device, computer equipment and medium

Country Status (1)

Country Link
CN (1) CN114116877B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109684389A (en) * 2018-08-31 2019-04-26 深圳壹账通智能科技有限公司 Conversion method, device, equipment and the readable storage medium storing program for executing of data list structure
CN109992595A (en) * 2019-04-11 2019-07-09 北京启迪区块链科技发展有限公司 Different database conversion method, apparatus, equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9760380B2 (en) * 2012-03-14 2017-09-12 Microsoft Technology Licensing, Llc Using grammar to serialize and de-serialize objects
CN103645931B (en) * 2013-12-25 2016-06-22 盛杰 The method of code conversion and device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109684389A (en) * 2018-08-31 2019-04-26 深圳壹账通智能科技有限公司 Conversion method, device, equipment and the readable storage medium storing program for executing of data list structure
CN109992595A (en) * 2019-04-11 2019-07-09 北京启迪区块链科技发展有限公司 Different database conversion method, apparatus, equipment and storage medium

Also Published As

Publication number Publication date
CN114116877A (en) 2022-03-01

Similar Documents

Publication Publication Date Title
CN110633292B (en) Query method, device, medium, equipment and system for heterogeneous database
CN107885874B (en) Data query method and device, computer equipment and computer readable storage medium
CN110019712A (en) More intent query method and apparatus, computer equipment and computer readable storage medium
CN111126006A (en) Method and device for exporting Word document with MathType formula, electronic equipment and storage medium
CN101093513A (en) Method and system for solving issue of supporting multilanguage of computer software
CN110795697A (en) Logic expression obtaining method and device, storage medium and electronic device
CN110019713A (en) Based on the data retrieval method and device, equipment and storage medium for being intended to understand
CN110209780B (en) Question template generation method and device, server and storage medium
CN108052310A (en) A kind of data processing method and server based on business model description information
CN110569230A (en) Method, system and equipment for interconversion between database design model and design document
CN114116877B (en) Data conversion method, device, computer equipment and medium
CN112347748A (en) Data report generation method and device, computer equipment and readable storage medium
CN109471935B (en) Questionnaire survey object determining method and device, electronic equipment and storage medium
CN109033082B (en) Learning training method and device of semantic model and computer readable storage medium
CN113742529A (en) Multi-table front-end processing method and device
CN103049275A (en) Method, device and equipment for processing operation commands
CN110110280B (en) Curve integral calculation method, device and equipment for coordinates and storage medium
CN110309235B (en) Data processing method, device, equipment and medium
CN113297311A (en) Data conversion method and device
CN110928876A (en) Credit data storage method and device
CN111126015B (en) Report form compiling method and equipment
CN105912603B (en) Service query method and device for network space
CN115168673B (en) Data graphical processing method, device, equipment and storage medium
CN112328871B (en) Reply generation method, device, equipment and storage medium based on RPA module
US20240104297A1 (en) Analysis of spreadsheet table in response to user input

Legal Events

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