A method for writing data into a database and a computer device
By corresponding to the target table template by presetting the object data list and reading and converting the table file data into a json object data group, the problem of low data writing efficiency in the prior art is solved, and an efficient data writing solution that simplifies steps and reduces costs is realized.
Patent Information
- Application Number
- CN202111501420.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-09
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2041-12-09
AI Technical Summary
In the prior art, writing data to a database is relatively inefficient, and data reading and writing scripts need to be adjusted according to the content and format of different table files.
By using the preset object data list to correspond to the target table template, describing the correspondence between the target data content of each row/column and the json object variable, reading the data content of the target table file, converting it into a json object data group, and writing it to the database.
It enables efficient writing of database data without adjusting data to scripts based on table file content or format, simplifying steps and reducing implementation costs.
Smart Images

Figure CN114356912B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of databases, and in particular, relates to a method for writing data into a database, an apparatus for writing data into a database, a computer device, and a computer-readable storage medium. Background Art
[0002] At present, big data analysis technology is widely used in various industries. For example, commodity business data analysis and product open navigation based on big data technology. In the implementation of big data analysis technology, the collection and aggregation of data samples and the construction of databases are also very important.
[0003] In the prior art, when data samples are collected and summarized, the data is recorded and summarized in the form of a table file. The data content in the table file is then written into a database. In the process of writing the data content in the table file into the database, it is necessary to first read the data content in the table file, and then write the read data content into the database. However, since the business data content recorded in different table files is different, or the format of the recorded data is different, the data reading method used is also different. Based on this, when writing data into the database for table files constructed with different table templates, different data reading and writing scripts are required, resulting in low efficiency in writing the data content of the table file into the database. Summary of the invention
[0004] In view of this, embodiments of the present application provide a method for writing data to a database, an apparatus for writing data to a database, a computer device, and a computer-readable storage medium to solve the problem of low efficiency of the solutions for writing data to a database in the prior art.
[0005] A first aspect of an embodiment of the present application provides a method for writing data to a database, comprising:
[0006] Based on a preset object data list corresponding to a target table file, the data content of the target table file is read to obtain a json object data group; wherein the target table file is obtained by entering at least one row / column of target data content in a target table template; the content in the preset object data list is at least used to describe the correspondence between the target data content of each row / column in the target table template and the json object variable;
[0007] According to the JSON string corresponding to the JSON object data group, obtain the target data content of each row / column;
[0008] Write the target data content of each row / column into the database.
[0009] A second aspect of an embodiment of the present application provides a device for writing data to a database, including:
[0010] A reading unit, configured to read the data content of the target table file based on a preset object data list corresponding to the target table file, and obtain a json object data group; wherein the target table file is obtained by entering at least one row / column of target data content in a target table template; and the content in the preset object data list is at least used to describe the corresponding relationship between the target data content of each row / column in the target table template and the json object variable;
[0011] A conversion unit, used for obtaining the target data content of each row / column according to the JSON string corresponding to the JSON object data group;
[0012] The writing unit is used to write the target data content of each row / column into the database.
[0013] A third aspect of an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the first aspect when executing the computer program.
[0014] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the first aspect are implemented.
[0015] The method for writing data to a database, the device for writing data to a database, the computer equipment, and the computer-readable storage medium provided by the embodiments of the present application have the following beneficial effects:
[0016] In the embodiment of the present application, since the target table file is obtained by entering at least one row / column of target data content in the target table template, by making the preset object data list correspond to the target table template, and using the content in the preset object data list to at least describe the correspondence between the target data content of each row / column in the target table template and the json object variable, the data content of the target table file is read based on the preset object data list corresponding to the target table file, and a json object data group corresponding to the target data content of each row / column in the target table file can be obtained, and then the target data content of each row / column is obtained according to the json string corresponding to the json object data group, and then the target data content of each row / column is written into the database. The invention realizes that when writing target data content in a target table file into a database, data is read from a target table file obtained by entering the target data content into a target table template based on a preset object data list corresponding to the target table file and a correspondence between the target table template and the preset object data list, so that a json object data group of target data content in all rows / columns in the target table file can be obtained, and then the target data content can be written into the database according to a json string corresponding to the json object data group. A new scheme for writing data into a database is provided, and there is no need to reconfigure the data writing script file due to different contents or formats in the table file, thereby improving the efficiency of writing data into the database.
[0017] In addition, in the embodiments of the present application, when writing data to a database for table files with different contents or table files in different formats, there is no need to repeatedly configure data reading and writing scripts. It is only necessary to configure the correspondence between the target table template and the preset object data list, and enter at least one row / column of target data content into the target table template to obtain the target table file. Then, based on the preset object data list, the json object data group of the target data content of all rows / columns can be read from the target table file, and then the target data content can be written into the database according to the json string corresponding to the json object data group. This simplifies the steps of writing data to the database and reduces the implementation cost of writing data to the database. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0019] Figure 1 This is a flowchart of a method for writing data to a database provided in an embodiment of the present application;
[0020] Figure 2 is a flowchart of a method for writing data to a database provided by another embodiment of the present application;
[0021] Figure 3 is a flowchart of a method for writing data to a database provided in yet another embodiment of the present application;
[0022] Figure 4 It is a structural block diagram of a device for writing data to a database provided by an embodiment of the present application;
[0023] Figure 5 It is a structural block diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0025] The present embodiment provides a method for writing data to a database, and the execution subject is a computer device. Here, the computer device can be a computer device, such as a personal computer, a mobile phone, or a tablet computer, etc., which is not limited here. By configuring a target script file for the computer device, the target script file describes the method for writing data to a database provided by the present embodiment, so that the computer device executes the target script file when writing the target table file to the database, and then executes each step in the method for writing data to the database.
[0026] During implementation, since the target table file is obtained by entering at least one row / column of target data content in the target table template, by making the preset object data list correspond to the target table template, and using the content in the preset object data list to at least describe the correspondence between the target data content of each row / column in the target table template and the json object variable, the computer device reads the data content of the target table file based on the preset object data list corresponding to the target table file, and can obtain the json object data group corresponding to the target data content of each row / column in the target table file, and then obtains the target data content of each row / column according to the json string corresponding to the json object data group, and then writes the target data content of each row / column into the database. The invention realizes that when writing target data content in a target table file into a database, a computer device reads data of a target table file obtained by entering the target data content into a target table template based on a preset object data list corresponding to the target table file and a correspondence between the target table template and the preset object data list, and can obtain a json object data group of target data content in all rows / columns in the target table file, and then writes the target data content into the database according to a json character string corresponding to the json object data group. A new scheme for writing data into a database is provided, and there is no need to reconfigure a data writing script file due to different contents or formats in the table file, thereby improving the efficiency of writing data into the database.
[0027] In addition, in the embodiments of the present application, when writing data to a database for table files with different contents or table files in different formats, there is no need to repeatedly configure data reading and writing scripts. It is only necessary to configure the correspondence between the target table template and the preset object data list, and enter at least one row / column of target data content into the target table template to obtain the target table file. This can enable the computer device to read the json object data group of the target data content of all rows / columns from the target table file based on the preset object data list, and then write the target data content into the database according to the json string corresponding to the json object data group, which simplifies the steps of writing data to the database and reduces the implementation cost of writing data to the database.
[0028] The following describes in detail a method for writing data to a database provided by this embodiment through a specific implementation.
[0029] Figure 1 The following is a flowchart of a method for writing data to a database according to an embodiment of the present application, which is described in detail as follows:
[0030] S11: Based on the preset object data list corresponding to the target table file, the data content of the target table file is read to obtain a json object data group.
[0031] In step S11, the target table file is obtained by entering at least one row / column of target data content in the target table template. The content in the preset object data list is at least used to describe the correspondence between the target data content of each row / column in the target table template and the json object variable. Here, the target table template can be configured with N target data rows / columns, and N is an integer greater than 1. By entering at least one row / column of target data into the target table template, the target table file can be obtained. The target data refers to the data content corresponding to any target data row / column in the target table template. The json object data group includes all json object variables corresponding to the target data content of all rows / columns in the target table file, and all json object variables are used to point to the target data content of all rows / columns in the target table file.
[0032] In this embodiment, the preset object data list corresponding to the target table file refers to the correspondence between the preset object data list and the target table template on which the target table file is based. Because the target table file is obtained by entering at least one row / column of target data content in the target table template, the preset object data list corresponding to the target table file can not only be used to at least describe the correspondence between each target data row / column in the target table template and the json object variable, but also can be used to at least describe the correspondence between each target data row / column, target data content and the json object variable in the target table file. Here, since the content in the preset object data list is at least used to describe the correspondence between each row / column target data content in the target table template and the json object variable, when the data content of the target table file is read based on the preset object data list, the content in the preset object data list can be used as the basis for reading data or the strategy for reading data.
[0033] In specific implementation, different preset object data lists can be adapted according to the content dimensions and / or data configuration formats of different target table templates. As an example, the content in the preset object data list can also be used to describe the meaning of the target data content of each row / column in the target table template and / or the target table file, the position of the target data content of each row / column in the table, and the correspondence between the target data content and the json object variable. For example, the meaning of the target data content can be the header description information, and the position of the target data content of each row / column in the table is the row coordinates and / or column coordinates, etc.
[0034] It should be noted that the json object data group obtained by reading the data content of the target table file based on the preset object data list corresponding to the target table file is not the target data content itself, but a collection of json objects corresponding to the target data content of each row / column in the target document. In the collection of json objects, each json object corresponds to and points to a row / column of target data content. Here, the json object can include at least one pair of key-value pairs, for example, a key-value pair consisting of a keyword key and a value value, where the key represents the row / column of the target data content; and the value is an object of the target data content, which is used to point to or represent the target data content.
[0035] As an embodiment, step S11 specifically includes:
[0036] Based on a preset object data list corresponding to the target table file, the data content in the target table file is read according to the arrangement order of the data content in the target table file to obtain a json object data group.
[0037] In this embodiment, since the content in the preset object data list is at least used to describe the correspondence between the target data content of each row / column in the target table template and the json object variable, when the data content of the target table file is read based on the preset object data list, the content in the preset object data list can be used as a basis for reading data or a strategy for reading data.
[0038] In the specific implementation, the arrangement order between the target data contents in different rows / columns of the target table file can also be determined according to the contents in the preset object data list. Therefore, based on the preset object data list corresponding to the target table file, when reading data from the target table file, the arrangement order of the data contents in the target table file can be determined according to the contents in the preset object data list, and then the data contents in the target table file can be read according to the arrangement order of the data contents in the target table file to obtain a json object data group.
[0039] As an example, the above step: based on the preset object data list corresponding to the target table file, according to the arrangement order of the data content in the target table file, reading the data content in the target table file to obtain the json object data group may specifically include:
[0040] According to the preset object data list corresponding to the target table file, a data reading strategy related to the arrangement order of the data content in the target table file is generated; the data content of the target table file is read according to the data reading strategy to obtain a json object data group.
[0041] Here, since the data reading strategy is related to the arrangement order of the data content in the target table file, according to the data reading strategy, the data content in the target table file can be read according to the arrangement order of the data content in the target table file to obtain the json object data group.
[0042] S12: Obtain the target data content of each row / column according to the JSON character string corresponding to the JSON object data group.
[0043] In step S12, the json object data group includes at least one group of json objects corresponding to at least one row / column of target data content. The json string generally refers to a json string obtained by converting or parsing the json object data group.
[0044] In this embodiment, the json object data group and the json string are presented in different ways, so the json object data group cannot be directly equated with one or more groups of json strings. The json object data group is converted or parsed to obtain the corresponding json string, and then the json string is converted to obtain the target data content of each row / column.
[0045] As an embodiment, step S12 includes:
[0046] Convert the json object data group into a json string; get the target data content of each row / column according to the json string.
[0047] In this embodiment, the fields based on the rows / columns of ProductVO are kept consistent with the fields of the json object, such as using the following statement to convert the json object into a json string:
[0048] List <productvo>productVOList=JSONObject.parseArray(offListJson,ProductVO.class)
[0049] It is understandable that, in the specific implementation, the JSON object data group can be converted into a JSON string by using global methods such as JSON.stringify() or toJSONString().
[0050] For example: use var last = obj.toJSONString(); to convert a JSON object into a JSON string, or use var last = JSON.stringify(obj); to convert a JSON object into a JSON string.
[0051] S13: Write the target data content of each row / column into the database.
[0052] In step S13, the target data content may include data content that is the same as or different from the existing content in the database.
[0053] In this embodiment, writing the target data content of each row / column into the database may be writing content not recorded in the database, or updating or replacing the existing content in the database.
[0054] It is easy to understand that in actual applications, the target data content of each row / column is written into the database by directly writing the target data content of each row / column into the database as the written content, or writing the target data content of each row / column into the database in other ways, such as key-value pairs, which is not limited here.
[0055] In the above scheme, since the target table file is obtained by entering at least one row / column of target data content in the target table template, by making the preset object data list correspond to the target table template and using the content in the preset object data list to at least describe the correspondence between the target data content of each row / column in the target table template and the json object variable, the data content of the target table file is read based on the preset object data list corresponding to the target table file, and a json object data group corresponding to the target data content of each row / column in the target table file can be obtained, and then the target data content of each row / column is obtained according to the json string corresponding to the json object data group, and then the target data content of each row / column is written into the database. The invention realizes that when writing target data content in a target table file into a database, data is read from a target table file obtained by entering the target data content into a target table template based on a preset object data list corresponding to the target table file and a correspondence between the target table template and the preset object data list, so that a json object data group of target data content in all rows / columns in the target table file can be obtained, and then the target data content can be written into the database according to a json string corresponding to the json object data group. A new scheme for writing data into a database is provided, and there is no need to reconfigure the data writing script file due to different contents or formats in the table file, thereby improving the efficiency of writing data into the database.
[0056] In addition, in the embodiments of the present application, when writing data to a database for table files with different contents or table files in different formats, there is no need to repeatedly configure data reading and writing scripts. It is only necessary to configure the correspondence between the target table template and the preset object data list, and enter at least one row / column of target data content into the target table template to obtain the target table file. Then, based on the preset object data list, the json object data group of the target data content of all rows / columns can be read from the target table file, and then the target data content can be written into the database according to the json string corresponding to the json object data group. This simplifies the steps of writing data to the database and reduces the implementation cost of writing data to the database.
[0057] Figure 2 This is a flowchart of a method for writing data to a database provided by another embodiment of the present application. Figure 2 The illustrated embodiment, with Figure 1 The difference between the illustrated embodiments is that step S21 is included before step S11. Specifically:
[0058] S21: Determine a preset object data list based on the table template identifier carried by the target table file.
[0059] In this embodiment, the table template identifier is used to indicate the target table template corresponding to the target table file. That is, the table template identifier can also be used to distinguish the target table template from other table templates. Here, the table template identifier can be a table template number or a table template id. For example, the table template identifier of the first target table template can be mode_1.
[0060] In a specific implementation, since the target table file is a file obtained by entering at least one row / column of target data content into the target table, the target table file carries a table template identifier corresponding to the target table template. Since the target table template corresponds to the preset object data list, when determining the preset object data list, the preset object data list can be determined from a cache or a preset database using the table template identifier corresponding to the target table template.
[0061] As an embodiment, step S21 includes:
[0062] Query the cache to see whether there is a list object identifier corresponding to the table template identifier; if the list object identifier is in the cache, determine the preset object data list based on the list object identifier; if the list object identifier is not in the cache, determine the preset object data list from the preset database based on the table template identifier.
[0063] In this embodiment, the list object identifier is used to distinguish the preset object data list corresponding to the target table template from other preset object data lists. Here, querying whether there is a list object identifier corresponding to the table template identifier in the cache can specifically be querying whether there is a corresponding list object identifier in the cache data according to the table template identifier.
[0064] It should be noted that if there is a list object identifier corresponding to the table template identifier in the cache, the content pointed to by the list object identifier can be determined as a preset object data list according to the list object identifier. If there is no list object identifier corresponding to the table template identifier in the cache, the preset object data list is determined from the preset database according to the list object identifier. Here, the preset database is used to store each preset object data list corresponding to each target table target, and the data in the preset database is also used to describe the correspondence between each table template identifier, each list object identifier and each preset object data list.
[0065] As an embodiment, the above step of: querying whether there is a list object identifier corresponding to the table template identifier in the cache includes:
[0066] Obtain a hash list in the cache; query whether there is a value corresponding to the key value in the hash list according to the key value corresponding to the table template identifier; if there is a value corresponding to the key value in the hash list, determine that the list object identifier is in the cache; if there is no value corresponding to the key value in the hash list, determine that the list object identifier is not in the cache.
[0067] In this embodiment, the data type in the cache may be a HashMap hash list, and the hash list is used to store a preset object data list corresponding to the target table template.
[0068] For example, the key value corresponding to the table template identifier points to the table template identifier no1, and the preset object data list data1 is an array of table VO objects, that is, map1 is used as a cache. The key-value pair can be stored in the cache: key = no1, value = data1. When the key value is used to retrieve data in map1, if there is a value value, it is determined that there is a list object identifier in the cache. If there is no value value, the key value is used to query the data in the preset database, and the queried data is put into the cache as the value value, that is, the value value pointing to the preset object data list is put into the cache.
[0069] As an embodiment, in the above step: if the list object identifier is not in the cache, after determining the preset object data list from the preset database according to the list object identifier, the method further includes:
[0070] If the preset object data list cannot be determined from the preset database according to the table template identifier, a prompt message is output; wherein the prompt message is used to indicate that the preset object data list corresponding to the list object identifier does not exist in the preset database, or indicates that the preset object data list corresponding to the list object identifier is not configured.
[0071] In this embodiment, if the preset object data list cannot be determined from the preset database, it means that the preset object data list corresponding to the list object identifier does not exist in the preset database, or the preset object data list corresponding to the list object identifier has not been configured. Therefore, by outputting a prompt message to indicate this, it can be made clear that the preset object data list cannot be determined, thereby avoiding users from performing unresponsive operations.
[0072] Figure 3 This is a flowchart of a method for writing data to a database provided in yet another embodiment of the present application. Figure 3 The illustrated embodiment, with Figure 2 The difference between the illustrated embodiments is that step S13 further includes steps S31 to S34. Specifically:
[0073] S31: In response to a preset operation of writing new target table file data into a database, refreshing the cache to obtain a new preset object data list;
[0074] S32: Based on the new preset object data list, the data content of the new target table file is read to obtain a new json object data group; wherein the new target table file is obtained by entering at least one row / column of new target data content in a new target table template; the new preset object data list corresponds to the new target table template, and the content in the new preset object data list is used to describe the corresponding relationship between the new target data content of each row / column in the new target table file and the new json object variable;
[0075] S33: obtaining the new target data content of each row / column according to the new JSON string corresponding to the new JSON object data group;
[0076] S34: Write the new target data content of each row / column into the database.
[0077] In this embodiment, the new target table file can be updated based on the target table file, or reconfigured. Here, in response to the preset operation of writing the new target table file data into the database, it refers to an operation that is triggered again after the target table file data is written into the database, so that a new preset object data list can be obtained by refreshing the cache.
[0078] In specific implementation, the user can export the corresponding target data content from other databases to the target table template, thereby obtaining a target table file or a new target table file.
[0079] It is easy to understand that in this embodiment, steps S32 to S34 describe the steps of writing the data content of the new target table file into the database, which corresponds to the steps of writing the data content of the target table file into the database described in steps S11 to S13. That is, the specific implementation of steps S32 to S34 can refer to the specific implementation of steps S11 to S13, so it will not be repeated here.
[0080] See also Figure 4 , Figure 4 1 is a structural block diagram of a device for writing data to a database provided in an embodiment of the present application. In this embodiment, the mobile computer device includes various units for executing Figures 1 to 3 For details, please refer to the steps in the corresponding embodiment. Figures 1 to 3 as well as Figures 1 to 3 For the convenience of explanation, only the parts related to this embodiment are shown. Figure 4 The device 40 for writing data to a database includes: a reading unit 41, a conversion unit 42 and a writing unit 43. Specifically:
[0081] The reading unit 41 is used to read the data content of the target table file based on the preset object data list corresponding to the target table file to obtain a json object data group; wherein the target table file is obtained by entering at least one row / column of target data content in the target table template; the content in the preset object data list is at least used to describe the corresponding relationship between the target data content of each row / column in the target table template and the json object variable;
[0082] A conversion unit 42, configured to obtain the target data content of each row / column according to the JSON character string corresponding to the JSON object data group;
[0083] The writing unit 43 is used to write the target data content of each row / column into the database.
[0084] As an embodiment, the device 40 for writing data to the database further includes:
[0085] A query unit, used for querying whether there is a list object identifier corresponding to the table template identifier in the cache;
[0086] A first determining unit, configured to determine a preset object data list according to the list object identifier if the list object identifier is present in the cache;
[0087] The second determining unit is configured to determine a preset object data list from a preset database according to the table template identifier if the list object identifier is not in the cache.
[0088] As an embodiment, the device 40 for writing data to the database further includes:
[0089] A response unit, configured to, in response to a preset operation of writing new target table file data into a database, refresh the cache to obtain a new preset object data list;
[0090] A first execution unit is configured to read the data content of the new target table file based on the new preset object data list to obtain a new json object data group; wherein the new target table file is obtained by entering at least one row / column of new target data content in a new target table template; the new preset object data list corresponds to the new target table template, and the content in the new preset object data list is used to describe the corresponding relationship between the new target data content of each row / column in the new target table file and the new json object variable;
[0091] A second execution unit is used to obtain the new target data content of each row / column according to a new JSON string corresponding to the new JSON object data group;
[0092] The third execution unit is used to write the new target data content of each row / column into the database.
[0093] It should be understood that Figure 4 In the structural block diagram of the device for writing data to a database, each unit is used to execute Figures 1 to 3 The steps in the corresponding embodiments, and for Figures 1 to 3 Each step in the corresponding embodiment has been explained in detail in the above embodiment. Figures 1 to 3 as well as Figures 1 to 3 The relevant descriptions in the corresponding embodiments are not repeated here.
[0094] Figure 5 is a structural block diagram of a computer device provided in an embodiment of the present application. Figure 5 As shown, the computer device 50 of this embodiment includes: a processor 51, a memory 52, and a computer program 53 stored in the memory 52 and executable on the processor 51, such as a program for a method of writing data to a database. When the processor 51 executes the computer program 53, the steps in each embodiment of the method of writing data to a database are implemented, such as Figure 1 S11 to S13 as shown, or Figure 2 S21 to S31 shown, or Figure 3 From S21 to S34 shown in FIG. 1 , the processor 51 executes the computer program 53 to implement the above Figure 4 The functions of each unit in the corresponding embodiment are, for example, Figure 4 For details on the functions of the units 41 to 43 shown, please refer to Figure 3 The relevant descriptions in the corresponding embodiments are not repeated here.
[0095] Exemplarily, the computer program 53 may be divided into one or more units, which are stored in the memory 52 and executed by the processor 51 to complete the present application. The one or more units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 53 in the computer device 50. For example, the computer program 53 may be divided into a reading unit, a conversion unit, and a writing unit, and the specific functions of each unit are as described above.
[0096] The turntable device may include, but is not limited to, a processor 51 and a memory 52. Those skilled in the art will appreciate that Figure 5 It is only an example of the computer device 50 and does not constitute a limitation of the computer device 50. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the turntable device may also include input and output devices, network access devices, buses, etc.
[0097] The processor 51 may be a central processing unit (CPU), or other general-purpose processors, 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, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0098] The memory 52 may be an internal storage unit of the computer device 50, such as a hard disk or memory of the computer device 50. The memory 52 may also be an external storage device of the computer device 50, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device 50. Further, the memory 52 may also include both an internal storage unit of the computer device 50 and an external storage device. The memory 52 is used to store the computer program and other programs and data required by the turntable device. The memory 52 may also be used to temporarily store data that has been output or is to be output.
[0099] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.< / productvo>
Claims
1. A method for writing data into a database, characterized in that: include: Based on the preset object data list corresponding to the target table file, the data content of the target table file is read to obtain a json object data group; wherein the target table file is obtained by entering at least one row / column of target data content in the target table template; the content in the preset object data list is at least used to describe the corresponding relationship between the target data content of each row / column in the target table template and the json object variable; different target table templates correspond to different preset object data lists; According to the JSON string corresponding to the JSON object data group, obtain the target data content of each row / column; Write the target data content of each row / column into the database.
2. The method for writing data to a database according to claim 1, characterized in that: Based on the preset object data list corresponding to the target table file, the data content of the target table file is read to obtain a json object data group, including: Based on a preset object data list corresponding to the target table file, the data content in the target table file is read according to the arrangement order of the data content in the target table file to obtain a json object data group.
3. The method for writing data into a database according to claim 1, characterized in that: Before the step of reading the data content of the target table file based on the preset object data list corresponding to the target table file to obtain the json object data group, the method further includes: A preset object data list is determined based on a table template identifier carried by a target table file; wherein the table template identifier is used to indicate a target table template corresponding to the target table file.
4. The method for writing data into a database according to claim 3, characterized in that: The step of determining the preset object data list based on the table template identifier carried by the target table file includes: Querying whether there is a list object identifier corresponding to the table template identifier in the cache; If the list object identifier is present in the cache, determining a preset object data list according to the list object identifier; If the list object identifier is not in the cache, a preset object data list is determined from a preset database according to the table template identifier.
5. The method for writing data into a database according to claim 4, characterized in that: The querying cache whether there is a list object identifier corresponding to the table template identifier includes: Get the hash list in the cache; According to the key value corresponding to the table template identifier, query whether there is a value corresponding to the key value in the hash table; If the value corresponding to the key value exists in the hash list, it is determined that the list object identifier exists in the cache; If the value corresponding to the key value does not exist in the hash list, it is determined that the list object identifier does not exist in the cache.
6. The method for writing data into a database according to claim 4, characterized in that: After the step of determining a preset object data list from a preset database according to the table template identifier if the list object identifier is not in the cache, the method further includes: If the preset object data list cannot be determined from the preset database according to the table template identifier, a prompt message is output; wherein the prompt message is used to indicate that the preset object data list corresponding to the list object identifier does not exist in the preset database, or indicates that the preset object data list corresponding to the list object identifier is not configured.
7. The method for writing data into a database according to any one of claims 1 to 6, characterized in that: After the step of writing the target data content of each row / column into the database, the method further includes: In response to a preset operation of writing new target table file data into the database, refreshing the cache to obtain a new preset object data list; Based on the new preset object data list, the data content of the new target table file is read to obtain a new json object data group; wherein, the new target table file is obtained by entering at least one row / column of new target data content in a new target table template; the new preset object data list corresponds to the new target table template, and the content in the new preset object data list is used to describe the corresponding relationship between the new target data content of each row / column in the new target table file and the new json object variable; According to the new JSON string corresponding to the new JSON object data group, obtain the new target data content of each row / column; Write the new target data content of each row / column into the database.
8. A device for writing data into a database, characterized in that: include: A reading unit, configured to read the data content of the target table file based on a preset object data list corresponding to the target table file, and obtain a json object data group; wherein the target table file is obtained by entering at least one row / column of target data content in a target table template; the content in the preset object data list is at least used to describe the corresponding relationship between the target data content of each row / column in the target table template and the json object variable; different target table templates correspond to different preset object data lists; A conversion unit, used for obtaining the target data content of each row / column according to the JSON string corresponding to the JSON object data group; The writing unit is used to write the target data content of each row / column into the database.
9. A computer device, characterized in that: The computer device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Risk control audit model generation method, device and equipment and readable storage medium
CN109615534A
Data storage method and device, data query method and device, equipment and storage medium
CN110147413A