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
preset
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 Shanghai
Original Assignee
OneConnect Financial Technology Co Ltd Shanghai
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 Shanghai filed Critical OneConnect Financial Technology Co Ltd Shanghai
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

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/164File meta data generation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/182Distributed 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

The invention relates to a data processing technology, and discloses an automatic script generation method, which comprises the following steps: 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; reading the field type of the file content set to obtain the field type; carrying out data length verification on the data content in the file content set; when the 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 data text; and loading the data text into a preset sql template to obtain an initial sql script, extracting a warehousing identifier of the initial sql script, and performing script information processing to obtain a standard sql script. The invention also relates to a blockchain technique, and the field type can be stored in a node of the blockchain. The invention also provides an automatic script generation device, electronic equipment and a storage medium. The invention can solve the problems of low efficiency and no guarantee of correctness in script compiling.

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. An automatic script generation method, characterized in that the method comprises:
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.
2. The method for automatically generating scripts according to claim 1, wherein the step of extracting the file contents of the file to be processed according to the file type of the file to be processed to obtain a file content set comprises the following steps:
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.
3. The automatic script generation method of claim 2, wherein said extracting the file content in the file to be processed by using a preset java input stream mode to obtain a file content set comprises:
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.
4. The method for automatically generating scripts according to claim 2, wherein the extracting the file contents in the file to be processed through a preset jxl mode to obtain a file content set comprises:
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.
5. The automatic script generation method of any one of claims 1 to 4, wherein the reading a field type of the file content set to obtain a field type comprises:
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.
6. The automatic script generation method of any one of claims 1 to 4, wherein the performing data length verification on the data content in the file content set comprises:
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.
7. The automatic script generation method of any one of claims 1 to 4, wherein the performing matching verification on the data content according to the field type comprises:
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.
8. An apparatus for automatically generating a script, the apparatus comprising:
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.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a method of automatically generating scripts according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the automatic script generation method according to any one of claims 1 to 7.
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
CN112882995A (en) Script automatic generation method and device, electronic equipment and storage medium
CN112052242A (en) Data query method and device, electronic equipment and storage medium
CN113239106A (en) Excel file export method and device, electronic equipment and storage medium
CN113672483B (en) Device log storage method and device, electronic device and medium
CN113238929B (en) Code testing method and device based on Mock data, electronic equipment and storage medium
CN114979120A (en) Data uploading method, device, equipment and storage medium
CN112559337A (en) Code coverage rate testing method and device, electronic equipment and storage medium
CN113434542A (en) Data relation identification method and device, electronic equipment and storage medium
CN113051224A (en) File transmission method and device, electronic equipment and computer readable storage medium
CN113377661A (en) Interface testing method and device, electronic equipment and storage medium
CN113051171A (en) Interface test method, device, equipment and storage medium
CN114185797A (en) Front-end code checking method and device, electronic equipment and readable storage medium
CN114398194A (en) Data collection method and device, electronic equipment and readable storage medium
CN112506931A (en) Data query method and device, electronic equipment and storage medium
CN112579475A (en) Code testing method, device, equipment and readable storage medium
CN112486490A (en) Front-end code packaging method and device, electronic equipment and storage medium
CN112579098A (en) Software release method and device, electronic equipment and readable storage medium
CN112541688B (en) Service data verification method and device, electronic equipment and computer storage medium
CN114896164A (en) Interface optimization method and device, electronic equipment and storage medium
CN112667244B (en) Data verification method, device, electronic equipment and computer readable storage medium
CN113468175A (en) Data compression method and device, electronic equipment and storage medium
CN113254446A (en) Data fusion method and device, electronic equipment and medium
CN113032275A (en) Method and device for testing field, electronic equipment and storage medium
CN112527655A (en) Software version quality abnormity detection method and device, electronic equipment and storage medium
CN112686759A (en) Account checking monitoring method, device, equipment and medium

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