A SQL statement pre-trial method and device, computer equipment and storage medium
By building a deep learning model to automatically review SQL statements, the problem of low efficiency in manual review by developers is solved, and efficient SQL statement pre-review is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-09
- Publication Date
- 2026-03-31
AI Technical Summary
In existing technologies, relying on developers to pre-audit SQL statements consumes a lot of time and manpower when dealing with large amounts of data, resulting in low efficiency.
Build a deep learning model to generate an SQL statement pre-audit model through preprocessing, training, validation, and testing. This model automatically audits SQL statements and provides optimization suggestions.
It reduces time and manpower costs and improves the efficiency of SQL statement review, especially in the case of large amounts of data.
Smart Images

Figure CN117009379B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database technology, and specifically to an SQL statement pre-examination method, apparatus, computer device, and non-volatile computer-readable storage medium. Background Technology
[0002] Currently, with the development of computer technology, more and more technologies are being applied in the financial field. The traditional financial industry is gradually transforming into financial technology (Fintech), and SQL statement pre-examination technology is no exception. However, due to the security and real-time requirements of the financial industry, higher requirements are also placed on SQL statement pre-examination technology.
[0003] Currently, in the work of databases within banking structures, developers often need to pre-audit the SQL (Structured Query Language) statements executed by the database to prevent poorly performing SQL statements from entering the production system and causing overall database performance degradation. However, in existing technologies, this pre-auditing of SQL statements typically relies on developers themselves, which consumes significant time and manpower costs, resulting in low efficiency, especially when dealing with large volumes of SQL data.
[0004] Therefore, existing technologies still need to be improved and enhanced. Summary of the Invention
[0005] In view of the shortcomings of the prior art, the purpose of this invention is to provide a method, apparatus, computer device and non-volatile computer-readable storage medium for pre-screening SQL statements that can be used in financial technology or other related fields. The invention aims to solve the problem that in the prior art, pre-screening of SQL statements usually relies on developers themselves, which consumes a lot of time and manpower and is inefficient when the amount of SQL statement data is large.
[0006] To achieve the above objectives, the present invention adopts the following technical solution:
[0007] A method for pre-evaluating SQL statements, comprising:
[0008] Pre-build SQL statement pre-examination models;
[0009] Receive SQL statement pre-review requests submitted by developers, and obtain the SQL statements to be reviewed based on the SQL statement pre-review requests;
[0010] Input the SQL statement to be reviewed into the SQL statement pre-review model and output the corresponding pre-review result.
[0011] In a further technical solution, the SQL statement pre-examination method, wherein the pre-construction of the SQL statement pre-examination model includes:
[0012] A deep learning model is pre-built, and the deep learning model is trained based on the collected SQL statement pre-examination samples to generate an SQL statement pre-examination model.
[0013] In a further technical solution, the SQL statement pre-examination method, wherein the step of pre-constructing a deep learning model and training the deep learning model based on collected SQL statement pre-examination samples to generate an SQL statement pre-examination model includes:
[0014] Pre-built deep learning models;
[0015] Collect SQL statement pre-examination samples, preprocess the SQL statement pre-examination samples, and obtain target SQL statement pre-examination samples;
[0016] The deep learning model is trained based on the target SQL statement pre-examination sample to generate an SQL statement pre-examination model.
[0017] In a further technical solution, the SQL statement pre-examination method includes collecting SQL statement pre-examination samples, preprocessing the SQL statement pre-examination samples to obtain target SQL statement pre-examination samples, wherein the preprocessing includes data cleaning, word segmentation, and vocabulary building.
[0018] In a further technical solution, the SQL statement pre-examination method, wherein training the deep learning model based on the target SQL statement pre-examination sample to generate an SQL statement pre-examination model includes:
[0019] The target SQL statement pre-screening sample is divided into a dataset, resulting in a training set, a validation set, and a test set.
[0020] The deep learning model is trained using the training set, then validated and adjusted using the validation set, and finally tested and evaluated using the test set.
[0021] Obtain the test evaluation results, and when the test evaluation results are found to meet the preset requirements, generate an SQL statement pre-audit model.
[0022] In a further technical solution, the SQL statement pre-approval method, after inputting the SQL statement to be approved into the SQL statement pre-approval model and outputting the corresponding pre-approval result, includes:
[0023] If the preliminary review result indicates that the SQL statement to be reviewed has optimization issues, the preliminary review result will be sent to the developer along with optimization suggestions.
[0024] In a further technical solution, the SQL statement pre-screening method, wherein if the pre-screening result indicates that the SQL statement to be screened has optimization issues, then after sending the pre-screening result to the developer and providing optimization suggestions, includes:
[0025] Obtain the modified SQL statement made by the developer based on the optimization suggestions, and input the modified SQL statement into the SQL statement pre-approval model for a second review.
[0026] A SQL statement pre-examination device, comprising:
[0027] Build modules are used to pre-build SQL statement pre-examination models;
[0028] The acquisition module is used to receive SQL statement pre-review requests submitted by developers and to acquire the SQL statements to be reviewed based on the SQL statement pre-review requests.
[0029] The pre-audit module is used to input the SQL statement to be audited into the SQL statement pre-audit model and output the corresponding pre-audit result.
[0030] A computer device, wherein the computer device includes at least one processor; and,
[0031] A memory communicatively connected to the at least one processor; wherein,
[0032] The memory stores a computer program that can be executed by the at least one processor. When the computer program is executed by the at least one processor, it can implement the SQL statement pre-examination method as described above.
[0033] A non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program that, when executed by at least one processor, can implement the SQL statement pre-examination method as described in any of the preceding claims.
[0034] Compared to existing technologies, this invention provides a method, apparatus, computer device, and non-volatile computer-readable storage medium for SQL statement pre-review. The method includes: pre-constructing an SQL statement pre-review model; receiving SQL statement pre-review requests submitted by developers; obtaining SQL statements to be reviewed based on the pre-review requests; inputting the SQL statements to be reviewed into the SQL statement pre-review model; and outputting the corresponding pre-review results. This method solves the problem in existing technologies where pre-reviewing SQL statements typically relies on developers themselves, which consumes significant time and manpower, resulting in low efficiency, especially when dealing with large amounts of SQL data. Attached Figure Description
[0035] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0036] Figure 1 This is a flowchart illustrating a SQL statement pre-examination method provided in an embodiment of the present invention.
[0037] Figure 2 This is another flowchart illustrating a SQL statement pre-examination method provided in an embodiment of the present invention.
[0038] Figure 3 This is a schematic diagram of the functional modules of an SQL statement pre-examination device provided in an embodiment of the present invention.
[0039] Figure 4 This is a schematic diagram of the hardware structure of the computer device provided in an embodiment of the present invention. Detailed Implementation
[0040] To make the objectives, technical solutions, and effects of this invention clearer and more explicit, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0041] In the description of this invention, the terms "comprising," "including," "having," and "containing" are all open-ended terms, meaning that they include but are not limited to. The terms "one embodiment," "one specific embodiment," "some embodiments," and "for example," etc., refer to specific features, structures, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, or characteristics described can be combined in any suitable manner in one or more embodiments or examples. The order of steps involved in the various embodiments is used to illustrate the implementation of this application, and the order of steps is not limited and can be adjusted appropriately as needed.
[0042] Various non-limiting embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0043] Currently, with the development of computer technology, more and more technologies are being applied in the financial field. The traditional financial industry is gradually transforming into financial technology (Fintech), and SQL statement pre-examination technology is no exception. However, due to the security and real-time requirements of the financial industry, higher requirements are also placed on SQL statement pre-examination technology.
[0044] Currently, in the work of databases within banking structures, developers often need to pre-audit the SQL (Structured Query Language) statements executed by the database to prevent poorly performing SQL statements from entering the production system and causing overall database performance degradation. However, in existing technologies, this pre-auditing of SQL statements typically relies on developers themselves, which consumes significant time and manpower costs, resulting in low efficiency, especially when dealing with large volumes of SQL data.
[0045] Therefore, to resolve the above issues, please refer to [link / reference]. Figure 1 This invention provides a method for pre-screening SQL statements, wherein the method includes the following steps:
[0046] S100, Pre-build SQL statement pre-examination model;
[0047] S200: Receive the SQL statement pre-review request submitted by the developer, and obtain the SQL statement to be reviewed according to the SQL statement pre-review request;
[0048] S300. Input the SQL statement to be reviewed into the SQL statement pre-review model and output the corresponding pre-review result.
[0049] Furthermore, in the SQL statement pre-examination method, step S100, pre-constructing the SQL statement pre-examination model, includes:
[0050] A deep learning model is pre-built, and the deep learning model is trained based on the collected SQL statement pre-examination samples to generate an SQL statement pre-examination model.
[0051] Furthermore, the SQL statement pre-examination method, wherein the step of pre-constructing a deep learning model and training the deep learning model based on the collected SQL statement pre-examination samples to generate an SQL statement pre-examination model includes:
[0052] Pre-built deep learning models;
[0053] Collect SQL statement pre-examination samples, preprocess the SQL statement pre-examination samples, and obtain target SQL statement pre-examination samples;
[0054] The deep learning model is trained based on the target SQL statement pre-examination sample to generate an SQL statement pre-examination model.
[0055] In this specific implementation, a deep learning model is pre-built, then SQL statement pre-approval samples are collected, the SQL statement pre-approval samples are pre-processed to obtain target SQL statement pre-approval samples, and finally, the deep learning model is trained based on the target SQL statement pre-approval samples to generate an SQL statement pre-approval model.
[0056] Furthermore, in the SQL statement pre-examination method, the step of collecting SQL statement pre-examination samples and preprocessing the SQL statement pre-examination samples to obtain target SQL statement pre-examination samples includes data cleaning, word segmentation, and vocabulary building.
[0057] In specific implementation, in this embodiment, after collecting SQL statement pre-approval samples, the SQL statement pre-approval samples are preprocessed to obtain target SQL statement pre-approval samples. The preprocessing includes data cleaning (removing useless characters, punctuation marks, special characters, etc.), word segmentation, and vocabulary building.
[0058] Furthermore, in the SQL statement pre-examination method, the step of training the deep learning model based on the target SQL statement pre-examination sample to generate an SQL statement pre-examination model includes:
[0059] The target SQL statement pre-screening sample is divided into a dataset, resulting in a training set, a validation set, and a test set.
[0060] The deep learning model is trained using the training set, then validated and adjusted using the validation set, and finally tested and evaluated using the test set.
[0061] Obtain the test evaluation results, and when the test evaluation results are found to meet the preset requirements, generate an SQL statement pre-audit model.
[0062] In this specific implementation, after obtaining the target SQL statement pre-screening sample, the target SQL statement pre-screening sample is divided into a dataset, resulting in a training set, a validation set, and a test set. Then, the deep learning model is trained using the training set, and the trained deep learning model is validated and adjusted using the validation set. Finally, the validated and adjusted deep learning model is tested and evaluated using the test set. Finally, the test evaluation results are obtained. When the test evaluation results are found to meet preset requirements, an SQL statement pre-screening model is generated.
[0063] The training set is a dataset used to train the deep learning model. In this embodiment, the training set is input into the deep learning model, and the deep learning model will be trained and optimized based on this data.
[0064] A validation set is a dataset used to validate and adjust a trained deep learning model. During model training, if parameters are not working, the validation set is used to test the model's performance to determine whether the model is overfitting or underfitting. The validation set can help select appropriate models and parameters to obtain better performance.
[0065] The test set is used to evaluate the final performance of the model. After the model training and tuning are completed, this embodiment will use the test set to evaluate the model's generalization ability, that is, whether the model can make accurate predictions on new data.
[0066] Preferably, in this embodiment, when dividing the target SQL statement pre-screening samples into training, validation, and test sets, the typical ratio is 50% training set, 25% validation set, and 25% test set. This ratio can be adjusted according to specific circumstances, but it should be noted that each data point can only appear in one dataset to avoid data duplication and inaccurate evaluation results. Specifically, this embodiment can achieve dataset division through random partitioning, that is, randomly dividing the target SQL statement pre-screening samples into training, validation, and test sets. When partitioning the datasets, this embodiment needs to ensure that the sample distribution of the three datasets is similar to guarantee the model's generalization ability and the reliability of the evaluation results.
[0067] Furthermore, in the SQL statement pre-review method, step S200 involves receiving an SQL statement pre-review request submitted by a developer and obtaining the SQL statement to be reviewed based on the SQL statement pre-review request.
[0068] In specific implementation, in this embodiment, after generating the SQL statement pre-review model, the SQL statement pre-review request submitted by the developer is received, and the SQL statement to be reviewed is obtained according to the SQL statement pre-review request.
[0069] Furthermore, in the SQL statement pre-approval method, step S300 involves inputting the SQL statement to be approved into the SQL statement pre-approval model and outputting the corresponding pre-approval result.
[0070] In specific implementation, in this embodiment, after obtaining the SQL statement to be reviewed, the SQL statement to be reviewed is input into the SQL statement pre-review model, and the corresponding pre-review result is output.
[0071] Further, please refer to Figure 2 The SQL statement pre-approval method, wherein step S300, after inputting the SQL statement to be approved into the SQL statement pre-approval model and outputting the corresponding pre-approval result, includes the following steps:
[0072] S400. If the preliminary review result indicates that the SQL statement to be reviewed has optimization issues, then the preliminary review result is sent to the developer and optimization suggestions are provided.
[0073] Further, please refer to Figure 2 The SQL statement pre-approval method, wherein step S400, after sending the pre-approval result to the developer and providing optimization suggestions if the pre-approval result indicates that the SQL statement to be approved has optimization issues, includes the following steps:
[0074] S500: Obtain the SQL statement modified by the developer based on the optimization suggestions, and input the modified SQL statement into the SQL statement pre-review model for further review.
[0075] In specific implementation, in this embodiment, after inputting the SQL statement to be reviewed into the SQL statement pre-review model and outputting the corresponding pre-review result, if the pre-review result indicates that the SQL statement to be reviewed has optimization issues, the pre-review result is sent to the developer with optimization suggestions. Then, after the developer modifies the SQL statement to be reviewed according to the optimization suggestions, the modified SQL statement is obtained and input into the SQL statement pre-review model for a second review.
[0076] As can be seen from the above method embodiments, the SQL statement pre-examination method provided by the present invention firstly collects SQL statement pre-examination samples by pre-constructing a deep learning model, preprocesses the SQL statement pre-examination samples to obtain target SQL statement pre-examination samples, divides the target SQL statement pre-examination samples into a dataset, and obtains a training set, a validation set, and a test set. The deep learning model is trained based on the training set, then the trained deep learning model is validated and adjusted based on the validation set, and finally the validated and adjusted deep learning model is tested and evaluated based on the test set to obtain test evaluation results. When the test evaluation is detected... After the results meet the preset requirements, an SQL statement pre-review model is generated. Then, the system receives SQL statement pre-review requests submitted by developers and obtains the SQL statements to be reviewed based on these requests. The SQL statements to be reviewed are then input into the SQL statement pre-review model, and the corresponding pre-review results are output. Finally, if the pre-review results indicate that the SQL statements to be reviewed have optimization issues, the pre-review results are sent to the developers with optimization suggestions. Simultaneously, the system obtains the SQL statements modified by the developers based on the optimization suggestions and inputs the modified SQL statements into the SQL statement pre-review model for a second review. In this way, the method of this invention solves the problem in the prior art where developers typically rely on themselves to pre-review SQL statements, which consumes significant time and manpower costs and is inefficient when dealing with large amounts of SQL data.
[0077] It should be understood that although this application provides the method operation steps as described in the embodiments or flowcharts, conventional or non-inventive labor may include more or fewer operation steps, and these operation steps are not necessarily executed sequentially according to the order of the embodiments or flowcharts. The order of steps listed in the embodiments or flowcharts is merely one way of executing many steps and does not represent the only execution order. It should be noted that there is no necessary sequential order between the above steps. Those skilled in the art can understand from the description of the embodiments of the present invention that the above steps may have different execution orders in different embodiments, that is, they may be executed in parallel or in exchange, etc. Moreover, at least some steps in the embodiments or flowcharts may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but may be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but may be executed in turn, alternately, or synchronously with other steps or at least a part of the sub-steps or stages of other steps.
[0078] Based on the above embodiments, please refer to Figure 3 Another embodiment of the present invention also provides an SQL statement pre-examination device, wherein the device includes:
[0079] Module 11 is used to pre-build SQL statement pre-examination models;
[0080] The acquisition module 12 is used to receive SQL statement pre-review requests submitted by developers and to obtain the SQL statement to be reviewed based on the SQL statement pre-review requests.
[0081] The pre-audit module 13 is used to input the SQL statement to be audited into the SQL statement pre-audit model and output the corresponding pre-audit result.
[0082] Furthermore, in the aforementioned SQL statement pre-examination device, the pre-construction of the SQL statement pre-examination model includes:
[0083] A deep learning model is pre-built, and the deep learning model is trained based on the collected SQL statement pre-examination samples to generate an SQL statement pre-examination model.
[0084] Furthermore, in the aforementioned SQL statement pre-examination device, the pre-construction of a deep learning model, and the training of the deep learning model based on the collected SQL statement pre-examination samples to generate an SQL statement pre-examination model, includes:
[0085] Pre-built deep learning models;
[0086] Collect SQL statement pre-examination samples, preprocess the SQL statement pre-examination samples, and obtain target SQL statement pre-examination samples;
[0087] The deep learning model is trained based on the target SQL statement pre-examination sample to generate an SQL statement pre-examination model.
[0088] In this specific implementation, a deep learning model is pre-built, then SQL statement pre-approval samples are collected, the SQL statement pre-approval samples are pre-processed to obtain target SQL statement pre-approval samples, and finally, the deep learning model is trained based on the target SQL statement pre-approval samples to generate an SQL statement pre-approval model.
[0089] Furthermore, in the SQL statement pre-examination device, the step of collecting SQL statement pre-examination samples and preprocessing the SQL statement pre-examination samples to obtain target SQL statement pre-examination samples includes data cleaning, word segmentation, and vocabulary building.
[0090] In specific implementation, in this embodiment, after collecting SQL statement pre-approval samples, the SQL statement pre-approval samples are preprocessed to obtain target SQL statement pre-approval samples. The preprocessing includes data cleaning (removing useless characters, punctuation marks, special characters, etc.), word segmentation, and vocabulary building.
[0091] Furthermore, in the SQL statement pre-examination device, the step of training the deep learning model based on the target SQL statement pre-examination sample to generate an SQL statement pre-examination model includes:
[0092] The target SQL statement pre-screening sample is divided into a dataset, resulting in a training set, a validation set, and a test set.
[0093] The deep learning model is trained using the training set, then validated and adjusted using the validation set, and finally tested and evaluated using the test set.
[0094] Obtain the test evaluation results, and when the test evaluation results are found to meet the preset requirements, generate an SQL statement pre-audit model.
[0095] In this specific implementation, after obtaining the target SQL statement pre-screening sample, the target SQL statement pre-screening sample is divided into a dataset, resulting in a training set, a validation set, and a test set. Then, the deep learning model is trained using the training set, and the trained deep learning model is validated and adjusted using the validation set. Finally, the validated and adjusted deep learning model is tested and evaluated using the test set. Finally, the test evaluation results are obtained. When the test evaluation results are found to meet preset requirements, an SQL statement pre-screening model is generated.
[0096] The training set is a dataset used to train the deep learning model. In this embodiment, the training set is input into the deep learning model, and the deep learning model will be trained and optimized based on this data.
[0097] A validation set is a dataset used to validate and adjust a trained deep learning model. During model training, if parameters are not working, the validation set is used to test the model's performance to determine whether the model is overfitting or underfitting. The validation set can help select appropriate models and parameters to obtain better performance.
[0098] The test set is used to evaluate the final performance of the model. After the model training and tuning are completed, this embodiment will use the test set to evaluate the model's generalization ability, that is, whether the model can make accurate predictions on new data.
[0099] Preferably, in this embodiment, when dividing the target SQL statement pre-screening samples into training, validation, and test sets, the typical ratio is 50% training set, 25% validation set, and 25% test set. This ratio can be adjusted according to specific circumstances, but it should be noted that each data point can only appear in one dataset to avoid data duplication and inaccurate evaluation results. Specifically, this embodiment can achieve dataset division through random partitioning, that is, randomly dividing the target SQL statement pre-screening samples into training, validation, and test sets. When partitioning the datasets, this embodiment needs to ensure that the sample distribution of the three datasets is similar to guarantee the model's generalization ability and the reliability of the evaluation results.
[0100] Furthermore, in the SQL statement pre-screening device, the step of receiving the SQL statement pre-screening request submitted by the developer and obtaining the SQL statement to be screened based on the SQL statement pre-screening request is described.
[0101] In specific implementation, in this embodiment, after generating the SQL statement pre-review model, the SQL statement pre-review request submitted by the developer is received, and the SQL statement to be reviewed is obtained according to the SQL statement pre-review request.
[0102] Furthermore, in the SQL statement pre-screening device, the step of inputting the SQL statement to be screened into the SQL statement pre-screening model and outputting the corresponding pre-screening result;
[0103] In specific implementation, in this embodiment, after obtaining the SQL statement to be reviewed, the SQL statement to be reviewed is input into the SQL statement pre-review model, and the corresponding pre-review result is output.
[0104] Furthermore, the SQL statement pre-approval device, after inputting the SQL statement to be approved into the SQL statement pre-approval model and outputting the corresponding pre-approval result, includes:
[0105] If the preliminary review result indicates that the SQL statement to be reviewed has optimization issues, the preliminary review result will be sent to the developer along with optimization suggestions.
[0106] Furthermore, the SQL statement pre-screening device, wherein if the pre-screening result indicates that the SQL statement to be screened has optimization issues, then after sending the pre-screening result to the developer and providing optimization suggestions, includes:
[0107] Obtain the modified SQL statement made by the developer based on the optimization suggestions, and input the modified SQL statement into the SQL statement pre-approval model for a second review.
[0108] In specific implementation, in this embodiment, after inputting the SQL statement to be reviewed into the SQL statement pre-review model and outputting the corresponding pre-review result, if the pre-review result indicates that the SQL statement to be reviewed has optimization issues, the pre-review result is sent to the developer with optimization suggestions. Then, after the developer modifies the SQL statement to be reviewed according to the optimization suggestions, the modified SQL statement is obtained and input into the SQL statement pre-review model for a second review.
[0109] As can be seen from the above device embodiments, the SQL statement pre-examination device provided by the present invention firstly collects SQL statement pre-examination samples by pre-constructing a deep learning model, preprocesses the SQL statement pre-examination samples to obtain target SQL statement pre-examination samples, divides the target SQL statement pre-examination samples into a dataset, and obtains a training set, a validation set, and a test set. The deep learning model is trained based on the training set, then the trained deep learning model is validated and adjusted based on the validation set, and finally the validated and adjusted deep learning model is tested and evaluated based on the test set to obtain test evaluation results. When the test evaluation is detected... After the results meet the preset requirements, an SQL statement pre-review model is generated. Then, the system receives SQL statement pre-review requests submitted by developers and obtains the SQL statements to be reviewed based on these requests. The SQL statements to be reviewed are then input into the SQL statement pre-review model, and the corresponding pre-review results are output. Finally, if the pre-review results indicate that the SQL statements to be reviewed have optimization issues, the pre-review results are sent to the developers with optimization suggestions. Simultaneously, the system obtains the SQL statements modified by the developers based on the optimization suggestions and inputs the modified SQL statements into the SQL statement pre-review model for a second review. In this way, the device of the present invention solves the problem in the prior art where developers typically rely on themselves to pre-review SQL statements, which consumes significant time and manpower costs and is inefficient when dealing with large amounts of SQL data.
[0110] Based on the above embodiments, please refer to Figure 4 Another embodiment of the present invention also provides a computer device, wherein the computer device 10 includes:
[0111] Memory 120 and one or more processors 110, Figure 4 The following description uses a processor 110 as an example. The processor 110 and the memory 120 can be connected via a communication bus or other means. Figure 4 Taking the example of China and Israel being connected via a communication bus.
[0112] Processor 110 performs various control logic functions of computer device 10. It can be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), microcontroller, ARM (Acorn RISC Machine) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components. Furthermore, processor 110 can also be any conventional processor, microprocessor, or state machine. Processor 110 can also be implemented as a combination of computing devices, such as a combination of a DSP and a microprocessor, multiple microprocessors, one or more microprocessors combined with a DSP core, or any other such configuration.
[0113] The memory 120, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the computer program corresponding to the SQL statement pre-screening method in the embodiments of the present invention. The processor 110 executes various functional applications and data processing of the computer device 10 by running the non-volatile software programs, instructions, and units stored in the memory 120, thereby implementing the SQL statement pre-screening method in the above method embodiments.
[0114] The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store application programs required for operating the device and at least one function; and the data storage area may store data created based on the use of the computer device 10. Furthermore, the memory 120 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 120 may optionally include memory remotely located relative to the processor 110, and these remote memories may be connected to the computer device 10 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0115] One or more units are stored in memory 120, and when executed by one or more processors 110, they can implement the SQL statement pre-screening method as described in any of the above method embodiments. For example, they can implement the methods described above. Figure 1 The method steps S100 to S300.
[0116] Those skilled in the art will understand that Figure 4 The hardware structure diagram shown is only a schematic diagram of a part of the structure related to the present invention and does not constitute a limitation on the computer device on which the present invention is applied. The specific computer device may include more components than shown in the figure, or combine some components, or have different component arrangements.
[0117] Based on the above embodiments, the present invention also provides a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by at least one processor, it can implement the SQL statement pre-examination method as described in any of the above method embodiments, for example, it can implement the above-described... Figure 1 The method steps S100 to S300.
[0118] As an example, non-volatile storage media can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) as external cache memory. By way of illustration and not limitation, RAM can be obtained in many forms such as synchronous RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synchronous ink DRAM (SLDRAM), and direct Rambus RAM (DRRAM). The memory components or memories disclosed in the operating environment described herein are intended to include one or more of these and / or any other suitable types of memory.
[0119] Another embodiment of the present invention provides a computer program product comprising a computer program stored on a non-volatile computer-readable storage medium, the computer program including program instructions that, when executed by a processor, can implement the SQL statement pre-examination method as described in any of the above method embodiments, for example, can implement the above-described method. Figure 1 The method steps S100 to S300.
[0120] The embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0121] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general-purpose hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can exist in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods of various embodiments or some parts of embodiments.
[0122] Among other things, conditional language such as “can,” “may,” “may,” or “may,” unless otherwise specifically stated or otherwise understood as in the context in which they are used, is generally intended to convey that a particular implementation may include (but not others) certain features, elements, and / or operations. Therefore, such conditional language is also generally intended to imply that features, elements, and / or operations are necessary for one or more implementations in any way, or that one or more implementations must include logic for determining, with or without input or prompting, whether such features, elements, and / or operations are included or will be performed in any particular implementation.
[0123] The contents already described herein in this specification and accompanying drawings include examples of SQL statement pre-screening methods, apparatuses, computer devices, and non-volatile computer-readable storage media. It is certainly not possible to describe every conceivable combination of elements and / or methods for the purpose of describing the various features of this disclosure, but it will be appreciated that many other combinations and substitutions of the disclosed features are possible. Therefore, it will be apparent that various modifications can be made to this disclosure without departing from the scope or spirit of this disclosure, but all such various modifications should fall within the protection scope of the appended claims. Furthermore, or in alternatives, other embodiments of this disclosure may become apparent from consideration of this specification and accompanying drawings and from practice of this disclosure as presented herein. It is intended that the examples presented in this specification and accompanying drawings be considered illustrative rather than restrictive in all respects. Although specific terminology is used herein, it is used in a general and descriptive sense and is not intended for limiting purposes.
Claims
1. A method of SQL statement pre-auditing, characterized by, The method comprises the following steps: pre-building a SQL statement pre-audit model; receiving a SQL statement pre-audit request submitted by a developer, and obtaining a SQL statement to be audited according to the SQL statement pre-audit request; inputting the SQL statement to be audited into the SQL statement pre-audit model, and outputting a corresponding pre-audit result; the pre-building of the SQL statement pre-audit model comprises the following steps: pre-building a deep learning model, training the deep learning model according to collected SQL statement pre-audit samples, and generating a SQL statement pre-audit model; the pre-building of the deep learning model, the training of the deep learning model according to the collected SQL statement pre-audit samples, and the generation of the SQL statement pre-audit model comprise the following steps: pre-building a deep learning model; collecting SQL statement pre-audit samples, pre-processing the SQL statement pre-audit samples to obtain target SQL statement pre-audit samples; training the deep learning model according to the target SQL statement pre-audit samples to generate a SQL statement pre-audit model; the training of the deep learning model according to the target SQL statement pre-audit samples to generate a SQL statement pre-audit model comprises the following steps: dividing the target SQL statement pre-audit samples into a training set, a verification set and a test set; wherein each data in the target SQL statement pre-audit samples can only appear in one of the training set, the verification set and the test set; training the deep learning model according to the training set, adjusting the trained deep learning model according to the verification set, and testing and evaluating the adjusted deep learning model according to the test set; obtaining a test evaluation result, and generating a SQL statement pre-audit model when it is detected that the test evaluation result meets a preset requirement; wherein the training set is a data set for training the deep learning model, the verification set is a data set for verifying and adjusting the trained deep learning model, and the test set is a data set for evaluating the final performance of the deep learning model.
2. The SQL statement pre-auditing method of claim 1, wherein, The collecting of the SQL statement pre-audit samples, the pre-processing of the SQL statement pre-audit samples to obtain target SQL statement pre-audit samples, wherein the pre-processing comprises data cleaning, word segmentation and establishment of a vocabulary table.
3. The method of claim 2, wherein, after the inputting of the SQL statement to be audited into the SQL statement pre-audit model and the outputting of the corresponding pre-audit result, the method comprises the following steps: if the pre-audit result is that the SQL statement to be audited has an optimization problem, the pre-audit result is sent to the developer and an optimization suggestion is given.
4. The SQL statement pre-auditing method of claim 3, wherein, after the pre-audit result is sent to the developer and the optimization suggestion is given if the pre-audit result is that the SQL statement to be audited has an optimization problem, the method comprises the following steps: obtaining a modified SQL statement of the developer according to the optimization suggestion, and inputting the modified SQL statement into the SQL statement pre-audit model for re-auditing.
5. A SQL statement preaudit device characterized by, The method comprises the following steps: a building module is configured to pre-build a SQL statement pre-audit model; The acquisition module is used to receive SQL statement pre-review requests submitted by developers and to acquire the SQL statements to be reviewed based on the SQL statement pre-review requests. The pre-screening module is used to input the SQL statement to be screened into the SQL statement pre-screening model and output the corresponding pre-screening result; The pre-built SQL statement pre-examination model includes: A deep learning model is pre-built, and the deep learning model is trained based on the collected SQL statement pre-examination samples to generate an SQL statement pre-examination model; The pre-built deep learning model is trained based on the collected SQL statement pre-examination samples to generate an SQL statement pre-examination model, including: Pre-build deep learning models; Collect SQL statement pre-examination samples, preprocess the SQL statement pre-examination samples, and obtain target SQL statement pre-examination samples; The deep learning model is trained based on the target SQL statement pre-examination sample to generate an SQL statement pre-examination model; The step of training the deep learning model based on the target SQL statement pre-examination sample to generate an SQL statement pre-examination model includes: The target SQL statement pre-screening sample is divided into a dataset, resulting in a training set, a validation set, and a test set; wherein each piece of data in the target SQL statement pre-screening sample can only appear in one of the three datasets: the training set, the validation set, and the test set. The deep learning model is trained using the training set, then validated and adjusted using the validation set, and finally tested and evaluated using the test set. Obtain test evaluation results; when the test evaluation results are found to meet preset requirements, generate an SQL statement pre-audit model. The training set is a dataset used to train the deep learning model, the validation set is a dataset used to validate and adjust the trained deep learning model, and the test set is a dataset used to evaluate the final performance of the deep learning model.
6. A computer device, comprising: The computer device includes at least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor. When the computer program is executed by the at least one processor, it can implement the SQL statement pre-examination method as described in any one of claims 1-4.
7. A non-transitory computer readable storage medium, comprising: The non-volatile computer-readable storage medium stores a computer program that, when executed by at least one processor, can implement the SQL statement pre-examination method as described in any one of claims 1-4.
Citation Information
Patent Citations
Machine learning-based code auditing method, device, equipment and storage medium
CN110781072A
SQL statement optimization method and device, equipment, storage medium and product
CN113590647A