CN112882995A - Script automatic generation method and device, electronic equipment and storage medium - Google Patents

Script automatic generation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112882995A
CN112882995A CN202110206570.6A CN202110206570A CN112882995A CN 112882995 A CN112882995 A CN 112882995A CN 202110206570 A CN202110206570 A CN 202110206570A CN 112882995 A CN112882995 A CN 112882995A
Authority
CN
China
Prior art keywords
file
data
processed
script
content
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.)
Pending
Application number
CN202110206570.6A
Other languages
Chinese (zh)
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.)
OneConnect Financial Technology Co Ltd
Original Assignee
OneConnect Financial 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 OneConnect Financial Technology Co Ltd filed Critical OneConnect Financial Technology Co Ltd
Priority to CN202110206570.6A priority Critical patent/CN112882995A/en
Publication of CN112882995A publication Critical patent/CN112882995A/en
Priority to PCT/CN2021/123890 priority patent/WO2022179121A1/en
Pending legal-status Critical Current

Links

Images

Classifications

    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06F—ELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10—File systems; File servers
    • G06F16/16—File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/164—File meta data generation
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06F—ELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10—File systems; File servers
    • G06F16/18—File system types
    • G06F16/182—Distributed file systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明涉及数据处理技术,揭露了一种脚本自动生成方法,包括:对待处理文件进行文件类型识别并根据文件类型对待处理文件进行文件内容提取,得到文件内容集;对文件内容集进行字段类型读取,得到字段类型;对文件内容集中的数据内容进行数据长度验证;在长度验证通过时,根据字段类型对数据内容进行匹配验证,并将匹配验证通过的数据内容存储至数据文本中;将数据文本装进预设的sql模板中,得到初始sql脚本并提取其入库标识做脚本信息处理,得到标准sql脚本。本发明还涉及区块链技术,所述字段类型可存储于区块链的节点。本发明还提出一种脚本自动生成装置、电子设备以及存储介质。本发明可以解决编写脚本效率慢且正确性没有保证的问题。

Figure 202110206570

The invention relates to data processing technology, and discloses an automatic script generation method, which includes: identifying the file type of the file to be processed and extracting the file content of the file to be processed according to the file type to obtain a file content set; performing field type reading on the file content set Get the field type; perform data length verification on the data content in the file content set; when the length verification passes, match and verify the data content according to the field type, and store the data content that has passed the matching verification in the data text; The text is loaded into the preset sql template, the initial sql script is obtained, and its storage identifier is extracted for script information processing, and a standard sql script is obtained. The present invention also relates to blockchain technology, and the field types can be stored in nodes of the blockchain. The present invention also provides a script automatic generation device, an electronic device and a storage medium. The invention can solve the problems of slow script writing efficiency and no guarantee of correctness.

Figure 202110206570

Description

Script automatic generation method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method and an apparatus for automatically generating a script, an electronic device, and a computer-readable storage medium.
Background
In work, it is often necessary to insert a batch of data into a database manually, at this time, data in a file needs to be converted into an sql script, then the correctness of the sql script is verified in a test database, and finally the sql script is executed in the database.
The basic methods for writing scripts are two, the first method is to directly write the scripts manually when the data volume is small, the efficiency is low, and the correctness is not guaranteed; the other method is that when the data volume is large, a small function is written to read the file, the data of the file is converted into the sql script, and then the correctness of the sql script is verified, so that the expansibility and compatibility of the method are not high.
Disclosure of Invention
The invention provides a method and a device for automatically generating a script and a computer readable storage medium, and mainly aims to solve the problems that the efficiency of writing the script is low and the correctness is not guaranteed.
In order to achieve the above object, the present invention provides an automatic script generation method, including:
acquiring a file to be processed, and identifying the file type of the file to be processed to obtain the file type of the file to be processed;
extracting the file content of the file to be processed according to the file type of the file to be processed to obtain a file content set;
reading the field type of the file content set to obtain the field type;
performing data length verification on the data content in the file content set;
when the data length verification is passed, performing matching verification on the data content according to the field type, and storing the data content passing the matching verification into a preset data text;
and loading the data text into a preset sql template to obtain an initial sql script, extracting a warehousing identifier in the initial sql script, and performing script information processing on the initial sql script according to the warehousing identifier to obtain a standard sql script.
Optionally, the extracting the file content of the file to be processed according to the file type of the file to be processed to obtain a file content set includes:
according to the file type of the file to be processed, carrying out the following file content extraction processing on the file to be processed:
extracting the file content in the file to be processed by utilizing a preset java input stream mode to obtain a file content set; or
And extracting the file content in the file to be processed in a preset jxl mode to obtain a file content set.
Optionally, the extracting the file content in the file to be processed by using a preset java input stream manner to obtain a file content set, including:
acquiring a preset byte input stream;
and performing data extraction on the file to be processed by using the byte input stream to obtain a file content set.
Optionally, the extracting, by a preset jxl method, file content in the file to be processed to obtain a file content set, including:
building jxl plug-in;
and performing data extraction on the file to be processed by using the jxl plug-in to obtain a file content set.
Optionally, the reading the field type of the file content set to obtain the field type includes:
acquiring a table name of the file content set;
and searching the corresponding field name and field type from a preset database according to the table name.
Optionally, the performing data length verification on the data content in the file content set includes:
identifying the data length of the data content with the preset line number in the file content set;
judging whether the data length is greater than or equal to a preset field threshold value or not;
if the data length is larger than or equal to a preset field threshold value, judging that the data length verification fails;
and if the data length is smaller than a preset field threshold value, judging that the data length verification is passed.
Optionally, the performing matching verification on the data content according to the field type includes:
judging whether the field of the data content is empty or not;
if the field is not empty, determining that the matching verification fails;
and if the field is empty, judging whether the data content is matched with the field type, if so, judging that the matching verification is passed, and if not, judging that the matching verification is not passed.
In order to solve the above problem, the present invention further provides an automatic script generation apparatus, including:
the file type identification module is used for acquiring a file to be processed and identifying the file type of the file to be processed to obtain the file type of the file to be processed;
the file content extraction module is used for extracting the file content of the file to be processed according to the file type of the file to be processed to obtain a file content set;
the field type reading module is used for reading the field type of the file content set to obtain the field type;
the data length verification module is used for verifying the data length of the data contents in the file content set;
the matching verification module is used for performing matching verification on the data content according to the field type when the data length verification is passed, and storing the data content which is passed through the matching verification into a preset data text;
and the script information processing module is used for loading the data text into a preset sql template to obtain an initial sql script, extracting a warehousing identifier in the initial sql script and carrying out script information processing on the initial sql script according to the warehousing identifier to obtain a standard sql script.
In order to solve the above problem, the present invention also provides an electronic device, including:
a memory storing at least one instruction; and
and the processor executes the instructions stored in the memory to realize the automatic script generation method.
In order to solve the above problem, the present invention further provides a computer-readable storage medium, in which at least one instruction is stored, and the at least one instruction is executed by a processor in an electronic device to implement the automatic script generation method described above.
According to the method and the device, the file type of the file to be processed is obtained by identifying the file type of the file to be processed, the file content of the file to be processed is extracted according to the file type of the file to be processed, different content extraction methods are adopted for different file types, the expansibility and the compatibility are improved, the data length verification and matching verification are carried out on the extracted file content set, data which do not meet requirements are eliminated, the verified data texts are loaded into the preset sql template in batches for script information processing, and the accuracy of the standard sql script is improved. Therefore, the automatic script generation method, the automatic script generation device, the electronic equipment and the computer readable storage medium can solve the problems that the efficiency of script writing is slow and the correctness is not guaranteed.
Drawings
Fig. 1 is a schematic flowchart of an automatic script generation method according to an embodiment of the present invention;
FIG. 2 is a functional block diagram of an apparatus for automatically generating scripts according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of an electronic device for implementing the automatic script generation method according to an embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The embodiment of the application provides an automatic script generation method. The execution subject of the automatic script generation method includes, but is not limited to, at least one of electronic devices such as a server and a terminal that can be configured to execute the method provided by the embodiments of the present application. In other words, the script automatic generation method may be performed by software or hardware installed in the terminal device or the server device, and the software may be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like.
Fig. 1 is a schematic flow chart of a method for automatically generating a script according to an embodiment of the present invention. In this embodiment, the automatic script generation method includes:
s1, acquiring the file to be processed, and carrying out file type identification on the file to be processed to obtain the file type of the file to be processed.
In the embodiment of the invention, the file to be processed comprises a plurality of pieces of file information to be processed.
Specifically, in the embodiment of the present invention, the file type of the file to be processed is obtained by identifying and distinguishing the file suffix name of the file to be processed.
Wherein the file suffix name is a mechanism used by the operating system to mark a file type.
In detail, the file types may include a TXT format, a CSV format, and an EXCEL format.
The TXT format mainly stores text information, that is, text information, the CSV (Comma-Separated Values) format, in which a file stores table data in a plain text format, and the EXCEL format mainly stores a table format.
For example, if the file name of the file to be processed is "aaahhhhkkk. TXT", the suffix name of the file to be processed is "TXT", and the type of the file to be processed is TXT format.
And S2, extracting the file content of the file to be processed according to the file type of the file to be processed to obtain a file content set.
In detail, according to the file type of the file to be processed, the following file content extraction processing is performed on the file to be processed:
extracting the file content in the file to be processed by utilizing a preset java input stream mode to obtain a file content set; or
And extracting the file content in the file to be processed in a preset jxl mode to obtain a file content set.
Specifically, when the file type is a TXT format or a CSV format, the embodiment of the present invention extracts the file content in the file to be processed by using a preset java input stream mode to obtain a file content set; and when the file type is the EXCEL format, extracting the file content in the file to be processed by a preset jxl mode to obtain a file content set.
Specifically, the extracting the file content in the file to be processed by using a preset java input stream mode to obtain a file content set includes:
acquiring a preset byte input stream;
and performing data extraction on the file to be processed by using the byte input stream to obtain a file content set.
In detail, the preset byte input stream is an InputStream, the byte input stream is an abstract class which must realize various functions depending on the subclasses of the byte input stream, the streams inherited from the byte input stream all input data into a program, and the data unit is a byte.
Further, the extracting the file content in the file to be processed in a preset jxl manner to obtain a file content set includes:
building jxl plug-in;
and performing data extraction on the file to be processed by using the jxl plug-in to obtain a file content set.
In detail, the jxl (jexcelapi) plug-in is a tool for operating excel in a java program.
And S3, reading the field type of the file content set to obtain the field type.
In this embodiment of the present invention, the reading the field type of the file content set to obtain the field type includes:
acquiring a table name of the file content set;
and searching the corresponding field name and field type from a preset database according to the table name.
The field type refers to a field format, such as a number type or a character string type.
And S4, performing data length verification on the data content in the file content set.
In this embodiment of the present invention, the verifying the data length of the data content in the file content set includes:
identifying the data length of the data content with the preset line number in the file content set;
judging whether the data length is greater than or equal to a preset field threshold value or not;
if the data length is larger than or equal to a preset field threshold value, judging that the data length verification fails;
and if the data length is smaller than a preset field threshold value, judging that the data length verification is passed.
If the data length verification of the data content with the preset number of lines does not pass, the embodiment of the invention deletes the data content with the preset number of lines and traverses the data of the next line to perform the data length verification, verifies whether the data length is in a reasonable range, and if the verification is illegal, the program is not terminated, but the processing of the data is terminated, and the next data is traversed.
And S5, when the data length is verified, performing matching verification on the data content according to the field type, and storing the data content which is verified to be matched into a preset data text.
In this embodiment of the present invention, the performing matching verification on the data content according to the field type includes:
judging whether the field of the data content is empty or not;
if the field is not empty, determining that the matching verification fails;
and if the field is empty, judging whether the data content is matched with the field type, if so, judging that the matching verification is passed, and if not, judging that the matching verification is not passed.
Further, if the field is empty, the field may be converted into a null value corresponding to the field type, the number type may be converted into 0, and the character string type may be converted into a null character string, etc., so as to determine whether the data content is matched with the field type. When the matching verification is passed, the embodiment of the invention stores the data content into a preset data text.
In detail, for example, the field type of the data content is a number, and the preset field type is a number, when the matching verification is passed, the line of data is written into the preset data text.
S6, loading the data text into a preset sql template to obtain an initial sql script, extracting a warehousing identifier in the initial sql script, and performing script information processing on the initial sql script according to the warehousing identifier to obtain a standard sql script.
In the embodiment of the invention, the preset sql template is a template which is automatically generated by reading the relevant information of the database in the file to be processed and is inserted into the sql statement.
Specifically, after the data text is loaded into a preset sql template to obtain an initial sql script, the embodiment of the present invention may further include: and performing corresponding format processing according to a specific format of a field in the initial sql script, for example, a character string type needs to be added with a single quotation mark before and after the data, a time type needs to convert the data into the time type through a preset to _ data function, and the like.
In detail, the warehousing identifier is used for judging whether script operation verification is required.
Further, the processing script information of the initial sql script according to the warehousing identifier to obtain a standard sql script includes:
if the warehousing identification is wrong, writing the initial sql script into the abnormal data text;
if the warehousing identification is correct, executing the initial sql script and obtaining an execution result;
when the execution result is normal, outputting the initial sql script as a standard sql script;
and when the execution result is in error, writing the data which causes error reporting in the initial sql script into the abnormal data text, performing repair processing, and re-executing the repaired text until the execution result is normal to obtain a standard sql script.
According to the method and the device, the file type of the file to be processed is obtained by identifying the file type of the file to be processed, the file content of the file to be processed is extracted according to the file type of the file to be processed, different content extraction methods are adopted for different file types, the expansibility and the compatibility are improved, the data length verification and matching verification are carried out on the extracted file content set, data which do not meet requirements are eliminated, the verified data texts are loaded into the preset sql template in batches for script information processing, and the accuracy of the standard sql script is improved. Therefore, the automatic script generation method provided by the invention can solve the problems that the efficiency of script writing is slow and the correctness is not guaranteed.
Fig. 2 is a functional block diagram of an automatic script generation apparatus according to an embodiment of the present invention.
The automatic script generation apparatus 100 according to the present invention may be installed in an electronic device. According to the realized functions, the automatic script generation device 100 may include a file type identification module 101, a file content extraction module 102, a field type reading module 103, a data length verification module 104, a matching verification module 105, and a script information processing module 106. The module of the present invention, which may also be referred to as a unit, refers to a series of computer program segments that can be executed by a processor of an electronic device and that can perform a fixed function, and that are stored in a memory of the electronic device.
In the present embodiment, the functions regarding the respective modules/units are as follows:
the file type identification module 101 is configured to acquire a file to be processed, and perform file type identification on the file to be processed to obtain a file type of the file to be processed;
the file content extraction module 102 is configured to extract file content of the file to be processed according to the file type of the file to be processed, so as to obtain a file content set;
the field type reading module 103 is configured to perform field type reading on the file content set to obtain a field type;
the data length verification module 104 is configured to perform data length verification on the data content in the file content set;
the matching verification module 105 is configured to perform matching verification on the data content according to the field type when the data length verification passes, and store the data content that passes the matching verification in a preset data text;
the script information processing module 106 is configured to pack the data text into a preset sql template to obtain an initial sql script, extract a warehousing identifier in the initial sql script, and perform script information processing on the initial sql script according to the warehousing identifier to obtain a standard sql script.
In detail, the modules in the automatic script generation apparatus 100, when executed by a processor of an electronic device, may implement an automatic script generation method including the following steps:
step one, the file type identification module 101 acquires a file to be processed, and performs file type identification on the file to be processed to obtain a file type of the file to be processed.
In the embodiment of the invention, the file to be processed comprises a plurality of pieces of file information to be processed.
Specifically, in the embodiment of the present invention, the file type identification module 101 identifies and distinguishes the file suffix name of the file to be processed, so as to obtain the file type of the file to be processed.
Wherein the file suffix name is a mechanism used by the operating system to mark a file type.
In detail, the file types may include a TXT format, a CSV format, and an EXCEL format.
The TXT format mainly stores text information, that is, text information, the CSV (Comma-Separated Values) format, in which a file stores table data in a plain text format, and the EXCEL format mainly stores a table format.
For example, if the file name of the file to be processed is "aaahhhhkkk. TXT", the suffix name of the file to be processed is "TXT", and the type of the file to be processed is TXT format.
And step two, the file content extraction module 102 extracts the file content of the file to be processed according to the file type of the file to be processed to obtain a file content set.
In detail, in the embodiment of the present invention, the file content extraction module 102 performs the following file content extraction processing on the file to be processed according to the file type of the file to be processed:
extracting the file content in the file to be processed by utilizing a preset java input stream mode to obtain a file content set; or
And extracting the file content in the file to be processed in a preset jxl mode to obtain a file content set.
Specifically, when the file type is a TXT format or a CSV format, the file content extraction module 102 in the embodiment of the present invention extracts file content in the file to be processed by using a preset java input stream manner, so as to obtain a file content set; and when the file type is in the EXCEL format, the file content extraction module 102 in the embodiment of the present invention extracts the file content in the file to be processed in a preset jxl manner, so as to obtain a file content set.
Specifically, the extracting the file content in the file to be processed by using a preset java input stream mode to obtain a file content set includes:
acquiring a preset byte input stream;
and performing data extraction on the file to be processed by using the byte input stream to obtain a file content set.
In detail, the preset byte input stream is an InputStream, the byte input stream is an abstract class which must realize various functions depending on the subclasses of the byte input stream, the streams inherited from the byte input stream all input data into a program, and the data unit is a byte.
Further, the extracting the file content in the file to be processed in a preset jxl manner to obtain a file content set includes:
building jxl plug-in;
and performing data extraction on the file to be processed by using the jxl plug-in to obtain a file content set.
In detail, the jxl (jexcelapi) plug-in is a tool for operating excel in a java program.
And step three, the field type reading module 103 reads the field type of the file content set to obtain the field type.
In this embodiment of the present invention, the field type reading module 103 performs field type reading on the file content set to obtain a field type, where the field type reading module includes:
acquiring a table name of the file content set;
and searching the corresponding field name and field type from a preset database according to the table name.
The field type refers to a field format, such as a number type or a character string type.
And fourthly, the data length verification module 104 performs data length verification on the data contents in the file content set.
In this embodiment of the present invention, the data length verification module 104 performs data length verification on the data content in the file content set, including:
identifying the data length of the data content with the preset line number in the file content set;
judging whether the data length is greater than or equal to a preset field threshold value or not;
if the data length is larger than or equal to a preset field threshold value, judging that the data length verification fails;
and if the data length is smaller than a preset field threshold value, judging that the data length verification is passed.
If the data length verification of the data content with the preset number of lines does not pass, the embodiment of the invention deletes the data content with the preset number of lines and traverses the data of the next line to perform the data length verification, verifies whether the data length is in a reasonable range, and if the verification is illegal, the program is not terminated, but the processing of the data is terminated, and the next data is traversed.
And step five, when the data length verification is passed, the matching verification module 105 performs matching verification on the data content according to the field type, and stores the data content passing the matching verification into a preset data text.
In this embodiment of the present invention, the matching verification module 105 performs matching verification on the data content according to the field type, including:
judging whether the field of the data content is empty or not;
if the field is not empty, determining that the matching verification fails;
and if the field is empty, judging whether the data content is matched with the field type, if so, judging that the matching verification is passed, and if not, judging that the matching verification is not passed.
Further, if the field is empty, the field may be converted into a null value corresponding to the field type, the number type may be converted into 0, and the character string type may be converted into a null character string, etc., so as to determine whether the data content is matched with the field type. When the matching verification is passed, the embodiment of the invention stores the data content into a preset data text.
In detail, for example, the field type of the data content is a number, and the preset field type is a number, when the matching verification is passed, the line of data is written into the preset data text.
And step six, the script information processing module 106 loads the data text into a preset sql template to obtain an initial sql script, extracts a warehousing identifier in the initial sql script and performs script information processing on the initial sql script according to the warehousing identifier to obtain a standard sql script.
In the embodiment of the invention, the preset sql template is a template which is automatically generated by reading the relevant information of the database in the file to be processed and is inserted into the sql statement.
Specifically, after the data text is loaded into a preset sql template to obtain an initial sql script, the embodiment of the present invention may further include: and performing corresponding format processing according to a specific format of a field in the initial sql script, for example, a character string type needs to be added with a single quotation mark before and after the data, a time type needs to convert the data into the time type through a preset to _ data function, and the like.
In detail, the warehousing identifier is used for judging whether script operation verification is required.
Further, the script information processing module 106 performs script information processing on the initial sql script according to the warehousing identifier to obtain a standard sql script, including:
if the warehousing identification is wrong, writing the initial sql script into the abnormal data text;
if the warehousing identification is correct, executing the initial sql script and obtaining an execution result;
when the execution result is normal, outputting the initial sql script as a standard sql script;
and when the execution result is in error, writing the data which causes error reporting in the initial sql script into the abnormal data text, performing repair processing, and re-executing the repaired text until the execution result is normal to obtain a standard sql script.
According to the method and the device, the file type of the file to be processed is obtained by identifying the file type of the file to be processed, the file content of the file to be processed is extracted according to the file type of the file to be processed, different content extraction methods are adopted for different file types, the expansibility and the compatibility are improved, the data length verification and matching verification are carried out on the extracted file content set, data which do not meet requirements are eliminated, the verified data texts are loaded into the preset sql template in batches for script information processing, and the accuracy of the standard sql script is improved. Therefore, the automatic script generation device provided by the invention can solve the problems that the efficiency of script writing is slow and the correctness is not guaranteed.
Fig. 3 is a schematic structural diagram of an electronic device implementing an automatic script generation method according to an embodiment of the present invention.
The electronic device 1 may comprise a processor 10, a memory 11 and a bus, and may further comprise a computer program, such as a script auto-generation program 12, stored in the memory 11 and executable on the processor 10.
The memory 11 includes at least one type of readable storage medium, which includes flash memory, removable hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device 1, such as a removable hard disk of the electronic device 1. The memory 11 may also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the electronic device 1. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device 1. The memory 11 may be used not only to store application software installed in the electronic device 1 and various types of data, such as codes of the script automatic generation program 12, but also to temporarily store data that has been output or is to be output.
The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged with the same or different functions, including one or more Central Processing Units (CPUs), microprocessors, digital Processing chips, graphics processors, and combinations of various control chips. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects various components of the electronic device by using various interfaces and lines, and executes various functions and processes data of the electronic device 1 by running or executing programs or modules (e.g., script automatic generation programs, etc.) stored in the memory 11 and calling data stored in the memory 11.
The bus may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is arranged to enable connection communication between the memory 11 and at least one processor 10 or the like.
Fig. 3 shows only an electronic device with components, and it will be understood by those skilled in the art that the structure shown in fig. 3 does not constitute a limitation of the electronic device 1, and may comprise fewer or more components than those shown, or some components may be combined, or a different arrangement of components.
For example, although not shown, the electronic device 1 may further include a power supply (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the at least one processor 10 through a power management device, so as to implement functions of charge management, discharge management, power consumption management, and the like through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device 1 may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
Further, the electronic device 1 may further include a network interface, and optionally, the network interface may include a wired interface and/or a wireless interface (such as a WI-FI interface, a bluetooth interface, etc.), which are generally used for establishing a communication connection between the electronic device 1 and other electronic devices.
Optionally, the electronic device 1 may further comprise a user interface, which may be a Display (Display), an input unit (such as a Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable for displaying information processed in the electronic device 1 and for displaying a visualized user interface, among other things.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
The script automatic generation program 12 stored in the memory 11 of the electronic device 1 is a combination of a plurality of instructions, and when running in the processor 10, can realize:
acquiring a file to be processed, and identifying the file type of the file to be processed to obtain the file type of the file to be processed;
extracting the file content of the file to be processed according to the file type of the file to be processed to obtain a file content set;
reading the field type of the file content set to obtain the field type;
performing data length verification on the data content in the file content set;
when the data length verification is passed, performing matching verification on the data content according to the field type, and storing the data content passing the matching verification into a preset data text;
and loading the data text into a preset sql template to obtain an initial sql script, extracting a warehousing identifier in the initial sql script, and performing script information processing on the initial sql script according to the warehousing identifier to obtain a standard sql script.
Specifically, the specific implementation method of the processor 10 for the instruction may refer to the description of the relevant steps in the embodiment corresponding to fig. 1, which is not described herein again.
Further, the integrated modules/units of the electronic device 1, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. The computer readable storage medium may be volatile or non-volatile. For example, the computer-readable medium may include: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM).
The present invention also provides a computer-readable storage medium, storing a computer program which, when executed by a processor of an electronic device, may implement:
acquiring a file to be processed, and identifying the file type of the file to be processed to obtain the file type of the file to be processed;
extracting the file content of the file to be processed according to the file type of the file to be processed to obtain a file content set;
reading the field type of the file content set to obtain the field type;
performing data length verification on the data content in the file content set;
when the data length verification is passed, performing matching verification on the data content according to the field type, and storing the data content passing the matching verification into a preset data text;
and loading the data text into a preset sql template to obtain an initial sql script, extracting a warehousing identifier in the initial sql script, and performing script information processing on the initial sql script according to the warehousing identifier to obtain a standard sql script.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method can be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules 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 modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention 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 integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1.一种脚本自动生成方法,其特征在于,所述方法包括:1. a script automatic generation method, is characterized in that, described method comprises: 获取待处理文件,对所述待处理文件进行文件类型识别,得到所述待处理文件的文件类型;Obtaining a file to be processed, performing file type identification on the file to be processed, and obtaining the file type of the file to be processed; 根据所述待处理文件的文件类型对所述待处理文件进行文件内容提取,得到文件内容集;Extracting the file content of the to-be-processed file according to the file type of the to-be-processed file to obtain a file content set; 对所述文件内容集进行字段类型读取,得到字段类型;Perform field type reading on the file content set to obtain the field type; 对所述文件内容集中的数据内容进行数据长度验证;performing data length verification on the data content in the file content set; 在所述数据长度验证通过时,根据所述字段类型对所述数据内容进行匹配验证,并将所述匹配验证通过的数据内容存储至预设的数据文本中;When the data length verification is passed, the data content is matched and verified according to the field type, and the data content that has passed the matching verification is stored in a preset data text; 将所述数据文本装进预设的sql模板中,得到初始sql脚本,提取所述初始sql脚本中的入库标识并根据所述入库标识对所述初始sql脚本进行脚本信息处理,得到标准sql脚本。Load the data text into a preset sql template, obtain an initial sql script, extract the warehousing identifier in the initial sql script and perform script information processing on the initial sql script according to the warehousing identifier to obtain a standard sql script. 2.如权利要求1所述的脚本自动生成方法,其特征在于,所述根据所述待处理文件的文件类型对所述待处理文件进行文件内容提取,得到文件内容集,包括:2. The method for automatically generating a script according to claim 1, wherein the file content extraction is performed on the to-be-processed file according to the file type of the to-be-processed file to obtain a file content set, comprising: 根据所述待处理文件的文件类型对所述待处理文件进行下述文件内容提取处理:Perform the following file content extraction processing on the to-be-processed file according to the file type of the to-be-processed file: 利用预设的java输入流方式提取所述待处理文件中的文件内容,得到文件内容集;或Extract the file content in the to-be-processed file by using a preset java input stream to obtain a file content set; or 通过预设的jxl方式提取所述待处理文件中的文件内容,得到文件内容集。The file content in the to-be-processed file is extracted through a preset jxl method to obtain a file content set. 3.如权利要求2所述的脚本自动生成方法,其特征在于,所述利用预设的java输入流方式提取所述待处理文件中的文件内容,得到文件内容集,包括:3. The method for automatically generating a script according to claim 2, wherein the use of a preset java input stream mode to extract the file content in the to-be-processed file obtains a file content set, comprising: 获取预设的字节输入流;Get the preset byte input stream; 利用所述字节输入流对所述待处理文件进行数据提取,得到文件内容集。Extracting data from the to-be-processed file using the byte input stream to obtain a file content set. 4.如权利要求2所述的脚本自动生成方法,其特征在于,所述通过预设的jxl方式提取所述待处理文件中的文件内容,得到文件内容集,包括:4. The method for automatically generating a script according to claim 2, wherein the file content in the to-be-processed file is extracted by a preset jxl mode to obtain a file content set, comprising: 构建jxl插件;Build the jxl plugin; 利用所述jxl插件对所述待处理文件进行数据提取,得到文件内容集。Use the jxl plug-in to extract data from the to-be-processed file to obtain a file content set. 5.如权利要求1至4中任意一项所述的脚本自动生成方法,其特征在于,所述对所述文件内容集进行字段类型读取,得到字段类型,包括:5. The method for automatically generating a script according to any one of claims 1 to 4, wherein the performing field type reading on the file content set to obtain the field type, comprising: 获取所述文件内容集的表名称;Get the table name of the file content set; 根据所述表名称从预设的数据库中查到到对应的字段名和字段类型。The corresponding field name and field type are found from the preset database according to the table name. 6.如权利要求1至4中任意一项所述的脚本自动生成方法,其特征在于,所述对所述文件内容集中的数据内容进行数据长度验证,包括:6. The automatic script generation method according to any one of claims 1 to 4, wherein the data length verification is performed on the data content in the file content set, comprising: 识别所述文件内容集中预设行数的数据内容的数据长度;Identifying the data length of the data content of the preset number of lines in the file content set; 判断所述数据长度是否大于或者等于预设的字段阈值;Determine whether the data length is greater than or equal to a preset field threshold; 若所述数据长度大于或者等于预设的字段阈值,则判定所述数据长度验证不通过;If the data length is greater than or equal to a preset field threshold, it is determined that the data length verification fails; 若所述数据长度小于预设的字段阈值,则判定所述数据长度验证通过。If the data length is less than a preset field threshold, it is determined that the data length verification is passed. 7.如权利要求1至4中任意一项所述的脚本自动生成方法,其特征在于,所述根据所述字段类型对所述数据内容进行匹配验证,包括:7. The method for automatically generating a script according to any one of claims 1 to 4, wherein the matching and verifying the data content according to the field type comprises: 判断所述数据内容的字段是否为空;Determine whether the field of the data content is empty; 若所述字段不为空,则将判定所述匹配验证未通过;If the field is not empty, it will be determined that the matching verification fails; 若所述字段为空,则判定所述数据内容与所述字段类型是否匹配,若匹配则判定匹配验证通过,若不匹配则判定匹配验证未通过。If the field is empty, it is determined whether the data content matches the field type, if it matches, it is determined that the matching verification is passed, and if it does not match, it is determined that the matching verification is not passed. 8.一种脚本自动生成装置,其特征在于,所述装置包括:8. A device for automatically generating scripts, wherein the device comprises: 文件类型识别模块,用于获取待处理文件,对所述待处理文件进行文件类型识别,得到所述待处理文件的文件类型;a file type identification module, configured to obtain a file to be processed, perform file type identification on the to-be-processed file, and obtain the file type of the to-be-processed file; 文件内容提取模块,用于根据所述待处理文件的文件类型对所述待处理文件进行文件内容提取,得到文件内容集;a file content extraction module, configured to extract the file content of the to-be-processed file according to the file type of the to-be-processed file to obtain a file content set; 字段类型读取模块,用于对所述文件内容集进行字段类型读取,得到字段类型;a field type reading module, used to read the field type of the file content set to obtain the field type; 数据长度验证模块,用于对所述文件内容集中的数据内容进行数据长度验证;a data length verification module for performing data length verification on the data content in the file content set; 匹配验证模块,用于在所述数据长度验证通过时,根据所述字段类型对所述数据内容进行匹配验证,并将所述匹配验证通过的数据内容存储至预设的数据文本中;a matching verification module, configured to perform matching verification on the data content according to the field type when the data length verification is passed, and store the data content that has passed the matching verification in a preset data text; 脚本信息处理模块,用于将所述数据文本装进预设的sql模板中,得到初始sql脚本,提取所述初始sql脚本中的入库标识并根据所述入库标识对所述初始sql脚本进行脚本信息处理,得到标准sql脚本。The script information processing module is used for loading the data text into a preset sql template, obtaining an initial sql script, extracting the warehousing identifier in the initial sql script, and performing an analysis on the initial sql script according to the warehousing identifier Script information processing is performed to obtain a standard sql script. 9.一种电子设备,其特征在于,所述电子设备包括:9. An electronic device, characterized in that the electronic device comprises: 至少一个处理器;以及,at least one processor; and, 与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein, 所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行如权利要求1至7中任意一项所述的脚本自动生成方法。The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the execution of any one of claims 1 to 7 The automatic script generation method described above. 10.一种计算机可读存储介质,存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至7中任意一项所述的脚本自动生成方法。10 . A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the method for automatically generating a script according to any one of claims 1 to 7 is implemented. 11 .
CN202110206570.6A 2021-02-24 2021-02-24 Script automatic generation method and device, electronic equipment and storage medium Pending CN112882995A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202110206570.6A CN112882995A (en) 2021-02-24 2021-02-24 Script automatic generation method and device, electronic equipment and storage medium
PCT/CN2021/123890 WO2022179121A1 (en) 2021-02-24 2021-10-14 Automatic script generation method and apparatus, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110206570.6A CN112882995A (en) 2021-02-24 2021-02-24 Script automatic generation method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112882995A true CN112882995A (en) 2021-06-01

Family

ID=76054888

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110206570.6A Pending CN112882995A (en) 2021-02-24 2021-02-24 Script automatic generation method and device, electronic equipment and storage medium

Country Status (2)

Country Link
CN (1) CN112882995A (en)
WO (1) WO2022179121A1 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113343662A (en) * 2021-06-28 2021-09-03 平安信托有限责任公司 Data landing method and device, electronic equipment and medium
CN114625853A (en) * 2022-03-11 2022-06-14 中国建设银行股份有限公司 Text processing method and device, electronic equipment and computer storage medium
WO2022179121A1 (en) * 2021-02-24 2022-09-01 深圳壹账通智能科技有限公司 Automatic script generation method and apparatus, electronic device and storage medium
CN115665126A (en) * 2022-10-11 2023-01-31 平安银行股份有限公司 Batch execution file generation method, device, medium and equipment

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116720077A (en) * 2023-05-11 2023-09-08 南方电网数字电网科技(广东)有限公司 Multi-source data modeling method and device for secondary equipment of transformer substation

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050120014A1 (en) * 2003-07-11 2005-06-02 Deffler Tad A. System and method for generating SQL using templates
US20100082656A1 (en) * 2008-09-24 2010-04-01 Yi Jing Methods and apparatus for generating dynamic program files based on input queries that facilitate use of persistent query services
CN109325046A (en) * 2018-10-25 2019-02-12 深圳壹账通智能科技有限公司 Database script generation method, device, medium and electronic device
CN112395251A (en) * 2020-12-21 2021-02-23 深圳赛安特技术服务有限公司 Intelligent analysis method and device for data file, electronic equipment and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110019485A (en) * 2018-02-07 2019-07-16 中国平安人寿保险股份有限公司 A kind of product data storage method, terminal device and storage medium
CN109783509A (en) * 2019-01-04 2019-05-21 中国银行股份有限公司 SQL scenario generation method and device
CN110069449B (en) * 2019-03-20 2023-09-26 平安科技(深圳)有限公司 File processing method, device, computer equipment and storage medium
CN112882995A (en) * 2021-02-24 2021-06-01 深圳壹账通智能科技有限公司 Script automatic generation method and device, electronic equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050120014A1 (en) * 2003-07-11 2005-06-02 Deffler Tad A. System and method for generating SQL using templates
US20100082656A1 (en) * 2008-09-24 2010-04-01 Yi Jing Methods and apparatus for generating dynamic program files based on input queries that facilitate use of persistent query services
CN109325046A (en) * 2018-10-25 2019-02-12 深圳壹账通智能科技有限公司 Database script generation method, device, medium and electronic device
CN112395251A (en) * 2020-12-21 2021-02-23 深圳赛安特技术服务有限公司 Intelligent analysis method and device for data file, electronic equipment and storage medium

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022179121A1 (en) * 2021-02-24 2022-09-01 深圳壹账通智能科技有限公司 Automatic script generation method and apparatus, electronic device and storage medium
CN113343662A (en) * 2021-06-28 2021-09-03 平安信托有限责任公司 Data landing method and device, electronic equipment and medium
CN114625853A (en) * 2022-03-11 2022-06-14 中国建设银行股份有限公司 Text processing method and device, electronic equipment and computer storage medium
CN114625853B (en) * 2022-03-11 2025-08-26 中国建设银行股份有限公司 Text processing method, device, electronic device and computer storage medium
CN115665126A (en) * 2022-10-11 2023-01-31 平安银行股份有限公司 Batch execution file generation method, device, medium and equipment

Also Published As

Publication number Publication date
WO2022179121A1 (en) 2022-09-01

Similar Documents

Publication Publication Date Title
CN112052242A (en) Data query method and device, electronic equipment and storage medium
WO2022179121A1 (en) Automatic script generation method and apparatus, electronic device and storage medium
CN113672483B (en) Device log storage method, device, electronic device and medium
CN111625252A (en) Cluster upgrading maintenance method and device, electronic equipment and storage medium
CN112395251A (en) Intelligent analysis method and device for data file, electronic equipment and storage medium
CN113051224A (en) File transmission method and device, electronic equipment and computer readable storage medium
CN114185797A (en) Front-end code checking method and device, electronic equipment and readable storage medium
CN113051171A (en) Interface test method, device, equipment and storage medium
CN113434542A (en) Data relation identification method and device, electronic equipment and storage medium
CN112667244A (en) Data verification method, apparatus, electronic device and computer-readable storage medium
CN114625755A (en) Script checking method and device, electronic equipment and storage medium
CN112506931B (en) Data query method, device, electronic equipment and storage medium
CN112685117A (en) System language internationalization maintenance method, device and computer readable storage medium
CN112579098A (en) Software release method and device, electronic equipment and readable storage medium
CN113238929A (en) Code testing method and device based on Mock data, electronic equipment and storage medium
CN113282854A (en) Data request response method and device, electronic equipment and storage medium
CN113254446A (en) Data fusion method and device, electronic equipment and medium
CN112579475A (en) Code testing method, device, equipment and readable storage medium
CN115658968A (en) Business data number creation method, device, electronic equipment and readable storage medium
CN114398194A (en) Data collection method and device, electronic equipment and readable storage medium
CN112685384A (en) Data migration method and device, electronic equipment and storage medium
CN111985194A (en) Data storage method and device, electronic equipment and storage medium
CN113468175B (en) Data compression method, device, electronic device and storage medium
CN114936148A (en) Page testing method and device, electronic equipment and readable storage medium
CN114519004A (en) Stability testing method, device, equipment and medium for application software

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
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40049999

Country of ref document: HK

RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210601