Disclosure of Invention
In order to solve the technical problems or at least partially solve the technical problems, the application provides a dynamic data warehousing method, a dynamic data warehousing device, electronic equipment and a storage medium.
In a first aspect, the present application provides a dynamic data importing method, where the method includes:
after the table file is imported into a database, the table file with changed table content is obtained;
obtaining a corresponding warehousing rule table according to the table file, wherein the warehousing rule table comprises: a first field sequence in the table file which is imported into the database and a second field sequence in the table file after the table content is changed;
warehousing the changed fields in the first field sequence in the table file imported into the database according to the second field sequence in the warehousing rule table;
and warehousing the field content of the warehoused field in the table file imported into the database.
Optionally, the warehousing the changed field in the first field sequence in the table file imported into the database according to the second field sequence in the warehousing rule table includes:
matching the second fields located at different positions in the second field sequence with the first fields at corresponding positions in the first field sequence in the table file imported into the database one by one;
if the second field sequence is determined to have a new field relative to the first field sequence according to the matching result, determining a new position of the new field;
and adding the new field at the new position.
Optionally, the warehousing the field content of the warehoused field in the table file imported into the database includes:
searching field contents corresponding to the newly added fields in the table file after the table contents are changed;
and adding the searched field content to a content position corresponding to the newly added field.
Optionally, the warehousing the changed field in the first field sequence in the table file imported into the database according to the second field sequence in the warehousing rule table includes:
if no new field exists in the second field sequence relative to the first field sequence according to the matching result, determining whether the field sequence of the second field sequence relative to the first field sequence is changed according to the matching result;
if the field sequence of the second field sequence relative to the first field sequence is determined to be changed according to the matching result, determining the field position of the field sequence to be changed;
and replacing the field in the first field sequence at the field position with the field in the second field sequence at the corresponding field position according to the field in the second field sequence.
Optionally, the warehousing the field content of the warehoused field in the table file imported into the database includes:
searching field contents corresponding to the replaced fields in the table file imported into the database;
and moving the searched field content to a content position corresponding to the replaced field.
Optionally, the warehousing the changed field in the first field sequence in the table file imported into the database according to the second field sequence in the warehousing rule table includes:
if the field sequence of the second field sequence relative to the first field sequence is not changed according to the matching result, determining whether a field with a changed field name and unchanged field content exists in the second field sequence relative to the first field sequence according to the matching result;
if a change field which changes relative to the first field sequence exists in the second field sequence according to the matching result, determining the change position of the change field;
and replacing the field in the change position in the first field sequence with the field in the corresponding field position in the second field sequence.
Optionally, the warehousing the field content of the warehoused field in the table file imported into the database includes:
determining whether the field content corresponding to the change field changes according to the warehousing rule table;
if the field content corresponding to the changed field is changed, searching the field content corresponding to the changed field in the table file after the table content is changed;
and adding the searched field content to a content position corresponding to the change field.
In a second aspect, the present application provides a dynamic data importing apparatus, the apparatus including:
the first acquisition module is used for acquiring the table file after the table content is changed after the table file is imported into the database;
the second obtaining module is configured to obtain a corresponding entry rule table according to the table file, where the entry rule table includes: a first field sequence in the table file which is imported into the database and a second field sequence in the table file after the table content is changed;
the first warehousing module is used for warehousing the changed fields in the first field sequence in the table file imported into the database according to the second field sequence in the warehousing rule table;
and the second warehousing module is used for warehousing the field content of the warehoused field in the table file imported into the database.
Optionally, the first warehousing module is further configured to:
matching the second fields located at different positions in the second field sequence with the first fields at corresponding positions in the first field sequence in the table file imported into the database one by one;
if the second field sequence is determined to have a new field relative to the first field sequence according to the matching result, determining a new position of the new field;
and adding the new field at the new position.
Optionally, the second warehousing module is further configured to:
searching field contents corresponding to the newly added fields in the table file after the table contents are changed;
and adding the searched field content to a content position corresponding to the newly added field.
Optionally, the first warehousing module is further configured to:
if no new field exists in the second field sequence relative to the first field sequence according to the matching result, determining whether the field sequence of the second field sequence relative to the first field sequence is changed according to the matching result;
if the field sequence of the second field sequence relative to the first field sequence is determined to be changed according to the matching result, determining the field position of the field sequence to be changed;
and replacing the field in the first field sequence at the field position with the field in the second field sequence at the corresponding field position according to the field in the second field sequence.
Optionally, the second warehousing module is further configured to: searching field contents corresponding to the replaced fields in the table file imported into the database;
and moving the searched field content to a content position corresponding to the replaced field.
Optionally, the first warehousing module is further configured to:
if the field sequence of the second field sequence relative to the first field sequence is not changed according to the matching result, determining whether a field with a changed field name and unchanged field content exists in the second field sequence relative to the first field sequence according to the matching result;
if a change field which changes relative to the first field sequence exists in the second field sequence according to the matching result, determining the change position of the change field;
and replacing the field in the change position in the first field sequence with the field in the corresponding field position in the second field sequence.
Optionally, the second warehousing module is further configured to: determining whether the field content corresponding to the change field changes according to the warehousing rule table;
if the field content corresponding to the changed field is changed, searching the field content corresponding to the changed field in the table file after the table content is changed;
and adding the searched field content to a content position corresponding to the change field.
In a third aspect, the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing the dynamic data warehousing method according to any one of the first aspect when executing the program stored in the memory.
In a fourth aspect, the present application provides a computer readable storage medium having stored thereon a program for a dynamic data warehousing method, which when executed by a processor, implements the steps of any one of the dynamic data warehousing methods of the first aspect.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages:
according to the embodiment of the invention, after the table file is imported into a database, the table file with changed table content is obtained, and a corresponding warehousing rule table is obtained according to the table file, wherein the warehousing rule table comprises: a first field sequence in the table file which is imported into the database and a second field sequence in the table file after the table content is changed; warehousing the changed fields in the first field sequence in the table file imported into the database according to the second field sequence in the warehousing rule table; and warehousing the field content of the warehoused field in the table file imported into the database.
According to the embodiment of the invention, the fields which are changed in the first field sequence in the table file and are imported into the database can be warehoused according to the warehouse-in rule table, and the field contents of the warehoused fields in the table file and are imported into the database are warehoused, so that the automatic warehouse-in of dynamic data is realized, the database table is not required to be reestablished, the operation of a developer is simpler, the working efficiency of the developer is improved, and the resource consumption of a server and the database is reduced.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of 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 apparent that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present application based on the embodiments herein.
Since in the prior art, for irregular dynamic data, such as: the data of the field sequence and name of the EXCEL table or the number of the field sequence and name of the EXCEL table cannot realize the dynamic conversion of the content in the EXCEL table and the corresponding content in the database and the conversion of the corresponding relation. To this end, an embodiment of the present invention provides a method, an apparatus, an electronic device, and a storage medium for importing dynamic data, where the method for importing dynamic data may be applied to a server, as shown in fig. 1, and the method for importing dynamic data may include the following steps:
step S101, after a table file is imported into a database, the table file with changed table content is obtained;
in the embodiment of the invention, the form file may refer to an EXCEL form file, dynamic data is stored in the form file, the dynamic data refers to data changed along with time change in system application, the data directly reflects transaction process, such as inventory data, website access amount, online population, daily sales and the like, when the trigger condition of warehousing (such as time is up) is met, the form file can be warehoused, and after the form file is warehoused, a form file with the same form content as the form file before the warehouse is created in a database.
Since the dynamic data often changes with time, after the table file is put in storage, the table content of the table file changes with the time, so in this step, the table file may be acquired again at intervals after the table file is imported into the database, or after the maintainer finds that the table content changes, the server may be triggered to acquire the table file again by triggering operation, etc.
Step S102, obtaining a corresponding warehousing rule table according to the table file.
In an embodiment of the present invention, the binning rule table includes: the first field sequence in the table file which is imported into the database and the second field sequence in the table file after the table content is changed, in practical application, the warehousing rule table may be configured by a developer according to practical requirements, and the first field sequence may include: the table file imported into the database is located in a field of a header, and the second field sequence may include: the table file after the table content change is located in the field of the table header, and the arrangement order of the fields in the first field sequence and the second field sequence may be according to the arrangement order of the fields in the table header of the table file, for example: the header of the table file imported into the database includes three fields from left to right: name, gender and age, then three fields are also included in the first field sequence: name, gender, and age, and in the same order as in the header of the table file; such as: five fields are included in the header of the table file after the table content is changed from left to right: name, gender, age, home address and academy, five fields are also included in the second field sequence: name, gender, age, home address and academic, and the order is the same as in the header of the table file;
in this step, the matched entry rule table can be searched in the storage space for storing the entry rule table according to the file name of the table file and the field sequence of the field in the table file after the table content is changed.
Step S103, according to the second field sequence in the warehousing rule table, warehousing the changed fields in the first field sequence in the table file imported into the database;
in this step, the second field sequence and the first field sequence may be compared to obtain a field that changes in the first field sequence, for example: newly added fields, fields with changed orders or fields with changed field names, etc.
When the changed field exists in the first field sequence, the changed field can be put in storage by utilizing the field which is positioned at the corresponding position with the changed field in the second field sequence.
Step S104, the field content of the fields which are imported into the table file of the database and put into storage is put into storage.
Since in practical applications, each field will generally have corresponding field contents, such as: the field content corresponding to the field name is reddish, the field content corresponding to the field gender is woman, the field content corresponding to the field age is 19, and the like, so that after the changed field finishes warehousing, the field content corresponding to the field, which is changed along with the field, is generally required to be warehoused.
According to the embodiment of the invention, after the table file is imported into a database, the table file with changed table content is obtained, and a corresponding warehousing rule table is obtained according to the table file, wherein the warehousing rule table comprises: a first field sequence in the table file which is imported into the database and a second field sequence in the table file after the table content is changed; warehousing the changed fields in the first field sequence in the table file imported into the database according to the second field sequence in the warehousing rule table; and warehousing the field content of the warehoused field in the table file imported into the database.
According to the embodiment of the invention, the fields which are changed in the first field sequence in the table file and are imported into the database can be warehoused according to the warehouse-in rule table, and the field contents of the warehoused fields in the table file and are imported into the database are warehoused, so that the automatic warehouse-in of dynamic data is realized, the database table is not required to be reestablished, the operation of a developer is simpler, the working efficiency of the developer is improved, and the resource consumption of a server and the database is reduced.
In yet another embodiment of the present invention, the step S103 includes:
matching the second fields located at different positions in the second field sequence with the first fields at corresponding positions in the first field sequence in the table file imported into the database one by one;
if the second field sequence is determined to have a new field relative to the first field sequence according to the matching result, determining a new position of the new field;
and adding the new field at the new position.
For example: the first field sequence includes three fields: name, gender and age, the second field sequence includes five fields: the name, sex, age, home address and academic, and the changed field in the first field sequence can be determined as the 'age' field by comparing the field sequences, and the changed field is put in storage, namely: the "home address" field and the "academic" field in the second field sequence at the fourth field position and the fifth field position are added to the "age" field.
Accordingly, the step S104 includes:
searching field contents corresponding to the newly added fields in the table file after the table contents are changed;
and adding the searched field content to a content position corresponding to the newly added field.
The method comprises the following steps of: when the "home address" field and the "academic" field located at the fourth field position and the fifth field position in the second field sequence are added to the "age" field, since the "home address" field and the "academic" field are newly added fields, the field content corresponding to the newly added fields only exists in the table file after the table content is changed, so that the field content "xx province xx city xx region" corresponding to the field "home address" and the field content "Gramineae" corresponding to the field "academic" in the table file after the table content is changed can be put in storage.
The embodiment of the invention can automatically warehouse the newly added field and the field content corresponding to the newly added field, realize the automatic warehouse entry of the dynamic data, avoid reestablishing the database table, simplify the operation of developers, improve the working efficiency of the developers and reduce the resource consumption of the server and the database.
In yet another embodiment of the present invention, the step S103 includes:
if no new field exists in the second field sequence relative to the first field sequence according to the matching result, determining whether the field sequence of the second field sequence relative to the first field sequence is changed according to the matching result;
if the field sequence of the second field sequence relative to the first field sequence is determined to be changed according to the matching result, determining the field position of the field sequence to be changed;
and replacing the field in the first field sequence at the field position with the field in the second field sequence at the corresponding field position according to the field in the second field sequence.
Such as: the first field sequence includes three fields: name, gender and age, the second field sequence includes five fields: the names, ages and sexes can be determined that the sequence of the sexes and ages in the first field sequence is changed through the comparison of the field sequences, namely, the changed fields are a gender field and an age field, and the changed fields are put in storage, namely: the "age" field in the second field sequence is used for replacing the "sex" field in the second field sequence in the second field position, and the "sex" field in the second field sequence in the third field position is used for replacing the "age" field in the first field sequence in the third field position.
Accordingly, the step S104 includes:
searching field contents corresponding to the replaced fields in the table file imported into the database;
and moving the searched field content to a content position corresponding to the replaced field.
Such as: the method comprises the following steps of: when the "age" field located at the second field position in the second field sequence is used for replacing the "sex" field located at the second field position in the first field sequence, and the "sex" field located at the third field position in the second field sequence is used for replacing the "age" field located at the third field position in the first field sequence, the "sex" field and the corresponding field content thereof are all fields existing in the table file imported into the database, so that the content positions of the corresponding field contents of the fields can be directly exchanged.
The embodiment of the invention can automatically warehouse fields with changed field sequences and the field contents corresponding to the fields, realize automatic warehouse entry of dynamic data, avoid reestablishing database tables, simplify the operation of developers, improve the working efficiency of the developers and reduce the resource consumption of servers and databases.
In yet another embodiment of the present invention, the step S103 includes:
if the field sequence of the second field sequence relative to the first field sequence is not changed according to the matching result, determining whether a field with a changed field name and unchanged field content exists in the second field sequence relative to the first field sequence according to the matching result;
if a change field which changes relative to the first field sequence exists in the second field sequence according to the matching result, determining the change position of the change field;
and replacing the field in the change position in the first field sequence with the field in the corresponding field position in the second field sequence.
Such as: the first field sequence includes three fields: name, gender and age, the second field sequence includes five fields: the name, the age and the home address can be compared by the field sequence to determine that the 'age' field in the first field sequence is changed, and the changed field is put in storage, namely: the "home address" field in the third field position in the second field sequence is used to replace the "age" field in the third field position in the first field sequence.
Accordingly, the step S104 includes:
determining whether the field content corresponding to the change field changes according to the warehousing rule table;
if the field content corresponding to the changed field is changed, searching the field content corresponding to the changed field in the table file after the table content is changed;
and adding the searched field content to a content position corresponding to the change field.
Such as: the method comprises the following steps of: when the "home address" field located at the third field position in the second field sequence is used to replace the "age" field located at the third field position in the first field sequence, the field content corresponding to the "home address" field in the table file after the table content is changed can be put in storage and stored in the content position corresponding to the "home address" field.
The embodiment of the invention can automatically warehouse the changed fields and the field content corresponding to the changed fields, realize the automatic warehouse entry of dynamic data, avoid reestablishing a database table, simplify the operation of developers, improve the working efficiency of the developers and reduce the resource consumption of the server and the database.
In still another embodiment of the present invention, there is also provided a dynamic data importing apparatus, as shown in fig. 2, including:
a first obtaining module 11, configured to obtain a table file after a table content change after the table file is imported into a database;
the second obtaining module 12 is configured to obtain a corresponding entry rule table according to the table file, where the entry rule table includes: a first field sequence in the table file which is imported into the database and a second field sequence in the table file after the table content is changed;
a first warehousing module 13, configured to warehouse, according to the second field sequence in the warehousing rule table, a field that changes in a first field sequence in the table file that has been imported into the database;
and a second warehousing module 14, configured to warehouse field contents of the warehoused fields in the table file imported into the database.
Optionally, the first warehousing module is further configured to:
matching the second fields located at different positions in the second field sequence with the first fields at corresponding positions in the first field sequence in the table file imported into the database one by one;
if the second field sequence is determined to have a new field relative to the first field sequence according to the matching result, determining a new position of the new field;
and adding the new field at the new position.
Optionally, the second warehousing module is further configured to:
searching field contents corresponding to the newly added fields in the table file after the table contents are changed;
and adding the searched field content to a content position corresponding to the newly added field.
Optionally, the first warehousing module is further configured to:
if no new field exists in the second field sequence relative to the first field sequence according to the matching result, determining whether the field sequence of the second field sequence relative to the first field sequence is changed according to the matching result;
if the field sequence of the second field sequence relative to the first field sequence is determined to be changed according to the matching result, determining the field position of the field sequence to be changed;
and replacing the field in the first field sequence at the field position with the field in the second field sequence at the corresponding field position according to the field in the second field sequence.
Optionally, the second warehousing module is further configured to: searching field contents corresponding to the replaced fields in the table file imported into the database;
and moving the searched field content to a content position corresponding to the replaced field.
Optionally, the first warehousing module is further configured to:
if the field sequence of the second field sequence relative to the first field sequence is not changed according to the matching result, determining whether a field with a changed field name and unchanged field content exists in the second field sequence relative to the first field sequence according to the matching result;
if a change field which changes relative to the first field sequence exists in the second field sequence according to the matching result, determining the change position of the change field;
and replacing the field in the change position in the first field sequence with the field in the corresponding field position in the second field sequence.
Optionally, the second warehousing module is further configured to: determining whether the field content corresponding to the change field changes according to the warehousing rule table;
if the field content corresponding to the changed field is changed, searching the field content corresponding to the changed field in the table file after the table content is changed;
and adding the searched field content to a content position corresponding to the change field.
In yet another embodiment of the present invention, there is provided an electronic device including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
a memory for storing a computer program;
and the processor is used for realizing the dynamic data warehousing method according to the embodiment of the method when executing the program stored in the memory.
According to the electronic equipment provided by the embodiment of the invention, after the table file is imported into the database by executing the program stored in the memory, the processor acquires the table file with changed table content, and acquires the corresponding warehousing rule table according to the table file, wherein the warehousing rule table comprises: a first field sequence in the table file which is imported into the database and a second field sequence in the table file after the table content is changed; warehousing the changed fields in the first field sequence in the table file imported into the database according to the second field sequence in the warehousing rule table; the method comprises the steps of warehousing field contents of the fields which are imported into the table file of the database, warehousing the fields which are imported into the table file of the database and change in a first field sequence of the table file of the database according to a warehousing rule table, warehousing the field contents of the fields which are imported into the table file of the database, realizing automatic warehousing of dynamic data, and having no need of reestablishing a database table, the operation of developers is simpler, the working efficiency of the developers is improved, and the resource consumption of the server and the database is reduced.
The communication bus 1140 mentioned above for the electronic device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industrial Standard Architecture (EISA) bus, etc. The communication bus 1140 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in fig. 3, but not only one bus or one type of bus.
The communication interface 1120 is used for communication between the electronic device and other devices described above.
The memory 1130 may include Random Access Memory (RAM) or non-volatile memory (non-volatile memory), such as at least one magnetic disk memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor 1110 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSP), application Specific Integrated Circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In still another embodiment of the present invention, there is further provided a computer readable storage medium having stored thereon a program of a dynamic data warehousing method, which when executed by a processor, implements the steps of the dynamic data warehousing method described in the foregoing method embodiment.
It should be noted that in this document, relational terms such as "first" and "second" and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing is only a specific embodiment of the invention to enable those skilled in the art to understand or practice the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.