Structured query statement extraction method and device, equipment and storage medium
By constructing virtual modules and virtual database connection tools, the SQL execution is decoupled, solving the problems of generalization, security, and integrity in SQL extraction from Perl scripts, and achieving more flexible and efficient SQL statement extraction.
Patent Information
- Application Number
- CN202511631270.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-07
- Publication Date
- 2026-02-24
AI Technical Summary
Existing technologies for SQL extraction from Perl scripts suffer from poor generalization, low security, and insufficient completeness. In particular, methods that rely on Perl scripts lead to database performance overhead and security risks, while methods that do not rely on Perl scripts are prone to mismatches or omissions in SQL code and require frequent secondary development and maintenance.
By constructing a set of virtual modules, a set of virtual databases, and a set of virtual database connection tools, a virtual environment is built to execute Perl scripts to extract structured query statements. The virtual database decouples SQL execution, adapts to scripts based on DBI modules and third-party database connection tools, and provides the ability to dynamically capture SQL code.
It improves the generalizability, security, and completeness of SQL statement extraction in Perl scripts, expands application scenarios, reduces the omission of SQL fragments, and enhances the flexibility and accuracy of SQL statement extraction.
Smart Images

Figure CN121560909A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of big data technology, and in particular to a method, apparatus, device and storage medium for extracting structured query statements. Background Technology
[0002] In data development and operations, programming languages are often combined with Structured Query Language (SQL) code. This makes extracting SQL from programming language scripts an important step when building and managing data lineage.
[0003] Currently, most SQL extraction methods are geared towards scripts such as Python (a high-level, general-purpose, interpreted programming language) and Shell (a scripting language based on Shell commands used to automate the execution of a series of commands), while methods targeting Perl scripts (text files written in the Perl programming language that are typically executed directly by an interpreter without compilation) are relatively few. Current SQL extraction methods in Perl scripts mainly include those that rely on Perl scripts (such as SQL interception methods and log parsing methods) and those that do not rely on Perl scripts (such as regular expression matching methods). However, methods that rely on Perl scripts incur additional database performance overhead and are unsuitable for scenarios with strict data security requirements due to security risks. Methods that do not rely on Perl scripts can lead to false or false matches in the SQL code and require frequent secondary development and maintenance depending on the content of the Perl script.
[0004] Therefore, improving the generalizability, security, and completeness of SQL statement extraction in Perl scripts has become an urgent problem to be solved. Summary of the Invention
[0005] This application provides a method, apparatus, device, and storage medium for extracting structured query statements, which can improve the generalizability, security, and completeness of SQL statement extraction from Perl scripts.
[0006] Firstly, this application provides a method for extracting structured query statements, the method comprising:
[0007] Based on the Perl script to be processed, determine the set of modules used by the Perl script, the set of environment variables, the set of database connection tools, and the set of database types accessed by the Perl script;
[0008] A virtual module set is constructed based on the module set, a virtual database set is constructed based on the database type set, and a virtual database connection tool set is constructed based on the database connection tool set. Each virtual module in the virtual module set is used to process structured query statements. Each virtual database in the virtual database set is used to run the current structured query statement and obtain the running results, which are used to extract structured query statements later. Each virtual database connection tool in the virtual database connection tool set is used to extract structured query statements.
[0009] Based on a set of modules, a set of environment variables, a set of virtual modules, a set of virtual database connection tools, and a set of virtual databases, a virtual environment for running Perl scripts is constructed.
[0010] Execute the Perl script in a virtual environment to obtain the structured query results of the Perl script.
[0011] In one embodiment, constructing a virtual database set based on a set of database types includes: for each database type in the database type set, determining the database connection library for the corresponding programming language based on the database type, and loading the database connection library into the program; constructing a structured query statement extractor and loading a structured query statement parsing tool into the program; the structured query statement parsing tool is used to parse the structured query statement into a syntax tree, extract the table structure information of the syntax tree, convert the table structure information into a pre-defined format, and output the converted table structure information; constructing a virtual data generator; the virtual data generator includes a virtual table creation sub-tool and a data generation sub-tool; the virtual table creation sub-tool is used to call the database connection library to construct a virtual table based on the received converted table structure information, and the data generation sub-tool is used to call the database connection library to insert virtual data into the virtual table based on the received converted table structure information; constructing a virtual database corresponding to the database type based on the database connection library, the structured query statement extractor, and the virtual data generator; and constructing a virtual database set based on the virtual databases corresponding to each database type.
[0012] In one embodiment, constructing a virtual module set based on the module set includes: declaring a database-independent interface virtual module if a database module exists in the module set; constructing a first function, a second function, a third function, and other functions corresponding to the database-independent interface; wherein, the first function is used to store structured query statements; the second function is used to read the structured query statements stored in the first function, process the structured query statements to obtain a structured query statement increment, write the structured query statement increment into a structured query statement extraction file, and call the virtual database and return the running result; the third function is used to directly process the structured query statements to obtain a structured query statement increment, write the structured query statement increment into a structured query statement extraction file, and call the virtual database and return the running result; and determining the virtual module set corresponding to the module set based on the first function, the second function, the third function, and other functions.
[0013] In one embodiment, constructing a virtual database connection tool set based on a database connection tool set includes: constructing a virtual function corresponding to each database connection tool in the database connection tool set; obtaining a set of instruction parameters corresponding to each database connection tool; adding each instruction parameter in the instruction parameter set to the virtual function to obtain a virtual function with added instruction parameters; wherein, when the instruction parameters are used to execute a structured query statement, the instruction parameters in the virtual function are used to incrementally write the structured query statement into a structured query statement extraction file and execute it in the virtual database; determining the virtual database connection tool corresponding to each database connection tool based on the virtual function with added instruction parameters; and constructing a virtual database connection tool set based on the virtual database connection tools corresponding to each database connection tool.
[0014] In one embodiment, determining the virtual database connection tool corresponding to the database connection tool based on the virtual function after adding instruction parameters includes: if it is determined that the database connection tool supports piped input, adding piped input functionality to the virtual function after adding instruction parameters to obtain a new virtual function; the new virtual function is used to write the piped input increment into a structured query statement extraction file and run it in the virtual database; and the new virtual function is encapsulated into an executable file to obtain the virtual database connection tool corresponding to the database connection tool.
[0015] In one embodiment, based on a set of modules, a set of environment variables, a set of virtual modules, a set of virtual database connection tools, and a set of virtual databases, the method includes: determining other modules in the set of modules besides the database module; determining at least one environment variable used by the Perl script based on the set of environment variables, and updating the virtual environment variable corresponding to each environment variable to a virtual value; associating the virtual value with the meaning of the corresponding environment variable; and constructing a virtual environment for running the Perl script based on the other modules, at least one virtual value, the set of virtual modules, the set of virtual database connection tools, and the set of virtual databases.
[0016] In one embodiment, after executing a Perl script in a virtual environment and obtaining the structured query statement extraction result of the Perl script, the method further includes: cleaning and deduplicating the structured query statements in the structured query statement extraction result of the Perl script to obtain the target structured query statement extraction result.
[0017] Secondly, this application provides a structured query statement extraction apparatus, the apparatus comprising:
[0018] The determination module is used to determine, based on the Perl script to be processed, the set of modules used by the Perl script, the set of environment variables, the set of database connection tools, and the set of database types accessed by the Perl script;
[0019] The building module is used to construct a virtual module set based on the module set, a virtual database set based on the database type set, and a virtual database connection tool set based on the database connection tool set. Each virtual module in the virtual module set is used to process structured query statements. Each virtual database in the virtual database set is used to run the current structured query statement and obtain the running results, which are used to extract structured query statements later. Each virtual database connection tool in the virtual database connection tool set is used to extract structured query statements.
[0020] The building module is also used to construct a virtual environment for running Perl scripts based on a set of modules, a set of environment variables, a set of virtual modules, a set of virtual database connection tools, and a set of virtual databases.
[0021] The processing module is used to execute Perl scripts in a virtual environment and obtain the structured query results from the Perl scripts.
[0022] Thirdly, this application provides a computer device including a processor and a memory, the memory storing a computer program; when the processor executes the computer program, it implements the steps in the method provided in the first aspect.
[0023] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method provided in the first aspect.
[0024] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps in the method provided in the first aspect.
[0025] The aforementioned method, apparatus, device, and storage medium for extracting structured query statements include a computer device that, based on the Perl script to be processed, determines the set of modules used by the Perl script, the set of environment variables, the set of database connection tools, and the set of database types accessed by the Perl script; constructs a virtual module set based on the module set, a virtual database set based on the database type set, and a virtual database connection tool set based on the database connection tool set; each virtual module in the virtual module set is used to process the structured query statement; each virtual database in the virtual database set is used to run the current structured query statement and obtain the running result, which is used for subsequent extraction of structured query statements; each virtual database connection tool in the virtual database connection tool set is used to extract the structured query statement; and a virtual environment for running the Perl script is constructed based on the module set, the set of environment variables, the virtual module set, the virtual database connection tool set, and the virtual database set; the Perl script is executed in the virtual environment to obtain the extracted structured query statement results from the Perl script. This method decouples SQL execution from the actual database by running SQL through a constructed virtual database. By building virtual modules and virtual database connection tools, it can adapt to both Perl scripts based on DBI modules and scripts based on third-party database connection tools, thereby improving the generalization and flexibility of SQL statement extraction and expanding application scenarios. Furthermore, by constructing a virtual environment and providing dynamic SQL code capture capabilities within that environment, it helps reduce the omission of SQL fragments and improves the completeness of SQL statement extraction. In short, this method improves the generalization, security, and completeness of SQL statement extraction from Perl scripts. Attached Figure Description
[0026] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1This is a flowchart illustrating a structured query statement extraction method provided in an embodiment of this application;
[0028] Figure 2 This is a flowchart illustrating another method for extracting structured query statements provided in an embodiment of this application;
[0029] Figure 3 This is a schematic diagram of a structured query statement extraction device provided in an embodiment of this application;
[0030] Figure 4 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0031] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0032] In data development and operations, a combination of programming languages and Structured Query Language (SQL) code is often used. This makes extracting SQL from programming language scripts a crucial step in data lineage construction and management. Currently, most SQL extraction methods are geared towards scripts such as Python (a high-level, general-purpose, interpreted programming language) and Shell (a scripting language based on Shell commands used to automate the execution of a series of commands), while methods targeting Perl scripts (text files written in the Perl programming language that are typically executed directly by an interpreter without compilation) are relatively less common.
[0033] Current methods for extracting SQL from Perl scripts mainly include those based on SQL interception and log parsing, as well as methods that do not rely on Perl scripts (such as those based on regular expression matching and syntax parsing). SQL interception methods wrap functions like `execute` in the Database Independent Interface (DBI) module and execute the wrapped Perl script to intercept SQL code during the SQL submission phase. While this method can capture the actual runtime SQL, relying on the actual execution of the Perl script incurs additional database performance overhead and poses a security risk of leaking sensitive information such as production data. Furthermore, this method is only applicable to DBI module-based methods and cannot extract SQL from Perl scripts that call specific database tools. Log parsing methods execute the Perl script to obtain the database output log containing SQL code and extract the SQL code from it. While this method can capture the actual runtime SQL, it faces the same issues of additional database performance overhead and security risks as SQL interception methods. Additionally, database output logs often contain a large amount of non-SQL text, requiring cleaning with regular expressions, which may lead to missed or incorrect SQL matches. Regular expression matching methods use complex regular expression rules to match SQL code segments. However, this method has poor generalization; if a scenario is not covered by the regular expression rules, mismatches or missed matches will occur, requiring rule adjustments, which often involve significant development and maintenance complexity. Syntax parsing methods, on the other hand, parse Perl syntax to identify calling parameters in the DBI module and extract these parameters as SQL code. While this method can avoid the mismatches and missed matches of regular expression matching to some extent, it struggles with dynamic concatenation and conditional statements, and current Perl syntax tree parsing tools are still not perfect.
[0034] Based on this, embodiments of this application provide a method, apparatus, device, and storage medium for extracting structured query statements. The computer device can construct a virtual module set based on the set of modules used by the Perl script to be processed, a virtual environment variable set based on the set of environment variables used by the Perl script to be processed, a virtual database connection tool set based on the set of database connection tools used by the Perl script to be processed, and a virtual database set based on the set of database types accessed by the Perl script to be processed. Each virtual module in the virtual module set is used to process the structured query statement; each virtual database in the virtual database set is used to run the current structured query statement and obtain the running result, which is used for subsequent extraction of structured query statements; each virtual database connection tool in the virtual database connection tool set is used to extract the structured query statement; a virtual environment for running the Perl script is constructed based on the module set, environment variable set, virtual module set, virtual database connection tool set, and virtual database set; the Perl script is executed in the virtual environment to obtain the extracted structured query statement results from the Perl script. This method decouples SQL execution from the actual database by running SQL through a constructed virtual database. By building virtual modules and virtual database connection tools, it can adapt to both Perl scripts based on DBI modules and scripts based on third-party database connection tools, thereby improving the generalization and flexibility of SQL statement extraction and expanding application scenarios. Furthermore, by constructing a virtual environment and providing dynamic SQL code capture capabilities within that environment, it helps reduce the omission of SQL fragments and improves the completeness of SQL statement extraction. In short, this method improves the generalization, security, and completeness of SQL statement extraction from Perl scripts.
[0035] Optionally, the computer equipment mentioned above can be a terminal or a server. Terminals mentioned here may include, but are not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices may include smart speakers, smart TVs, smart air conditioners, smart in-vehicle systems, projection devices, etc. Portable wearable devices may include smartwatches, smart bracelets, head-mounted displays, etc. Head-mounted displays may include virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. Servers mentioned here may be independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers providing cloud computing services, etc., without limitation.
[0036] The structured query statement extraction method provided in the embodiments of this application will be described in detail below.
[0037] Please see Figure 1 , Figure 1 This is a flowchart illustrating a method for extracting structured query statements provided in an embodiment of this application. This method can be executed by a computer device. Figure 1 As shown, this method for extracting structured query statements may include, but is not limited to, the following steps:
[0038] S101. Based on the Perl script to be processed, determine the set of modules used by the Perl script, the set of environment variables, the set of database connection tools, and the set of database types accessed by the Perl script.
[0039] The Perl script uses a set of modules, which includes multiple Perl script modules. Perl script modules refer to reusable code packages of Perl scripts, which usually contain a set of related functions and variables. They can be used for (1) code reuse: encapsulating commonly used code so that it can be reused in multiple scripts; (2) namespace management: avoiding conflicts between variable and function names; (3) function extension: providing various ready-made functions, such as database connection, network communication, graphical interface, etc.
[0040] In some embodiments, the modules used by the Perl script can be identified by the computer device based on the content of the Perl script to be processed through the pattern "use module name". Optionally, the modules used by the Perl script may include basic modules, built-in modules, database connection modules, etc.; wherein, basic modules are, for example, use warnings (enable warnings), built-in modules are, for example, use Getopt::Long (command line argument parsing), and database connection modules are, for example, use DBI (database interface), etc.
[0041] In Perl scripts, environment variables are a set of global variables that exist within the program's execution environment. These variables can affect the script's behavior or provide configuration information. In Perl, environment variables are typically accessed through a built-in hash called %ENV, which contains all environment variables for the current environment.
[0042] In some embodiments, the set of environment variables (which may be denoted as set E) includes multiple environment variables that can be identified by the computer device based on the content of the Perl script to be processed, using the pattern "$ENV{environment variable name}". Optionally, environment variables may include PATH (search path for executable files), HOME (home directory of the current user), USER or USERNAME (current username), PWD (current working directory), etc.
[0043] The database connection tools used by Perl scripts refer to the interfaces through which Perl scripts interact with databases, including DBI, which provides a unified application programming interface to access different database systems.
[0044] The database types used by Perl scripts can include relational databases and non-relational databases (that do not use SQL as the query language). Relational databases include MySQL (an open-source relational database management system), PostgreSQL (a powerful open-source object-relational database system), and SQLite (a lightweight, file-based embedded database engine that does not require a separate server process). Non-relational databases include MongoDB (an open-source, document-oriented NoSQL database that stores data in binary JSON format) and Redis (an open-source in-memory data structure store used as a database, cache, and message broker).
[0045] In some embodiments, the multiple database connection tools included in the database connection toolset (which may be denoted as set T) and the multiple database types included in the database type set (which may be denoted as set D) may be determined by a computer device in the following manner: checking whether a DBI database module (denoted as M) exists in the module set M. D If the DBI database module exists in module set M, check if the `open()` or `print` parameter contains the name of a database connection tool command. For example, if the computer device finds that module set M includes the BTEQ: Teradata database, it can determine that the database connection tool used by the Perl script includes BTEQ and the database type accessed includes Teradata. Teradata is an enterprise-level relational database management system designed for large-scale data warehousing and analytical processing; BTEQ is an interactive command-line tool provided by Teradata for executing SQL queries, importing and exporting data, and running scripts containing multiple SQL statements. If the computer device finds that module set M includes the gsql: GaussDB database, it can determine that the database connection tool used by the Perl script includes gsql and the database type accessed includes GaussDB. GaussDB is an enterprise-level distributed relational database with high availability, high performance, and high security; gsql is a command-line client tool provided by GaussDB for connecting to the GaussDB database, executing SQL statements, and managing database objects.
[0046] S102. Construct a virtual module set based on the module set, construct a virtual database set based on the database type set, and construct a virtual database connection tool set based on the database connection tool set.
[0047] Among them, each virtual module in the virtual module set is used to process structured query statements; each virtual database in the virtual database set is used to run the current structured query statement and obtain the running result, which is used to extract structured query statements later; each virtual database connection tool in the virtual database connection tool set is used to extract structured query statements.
[0048] S103. Based on the module set, environment variable set, virtual module set, virtual database connection tool set, and virtual database set, construct a virtual environment for running Perl scripts.
[0049] A virtual environment is an independent and isolated Perl runtime environment, which includes: a specific version of the Perl interpreter, an independent module installation directory, independent environment variable configuration, and isolated dependencies. By using virtual environments appropriately, the maintainability and portability of Perl projects can be improved.
[0050] S104. Execute the Perl script in the virtual environment to obtain the structured query results of the Perl script.
[0051] In this embodiment, the computer device can determine the set of modules used by the Perl script, the set of environment variables, the set of database connection tools, and the set of database types accessed by the Perl script based on the Perl script to be processed; construct a virtual module set based on the module set, a virtual database set based on the database type set, and a virtual database connection tool set based on the database connection tool set; each virtual module in the virtual module set is used to process structured query statements; each virtual database in the virtual database set is used to run the current structured query statement and obtain the running result, which is used to extract structured query statements later; each virtual database connection tool in the virtual database connection tool set is used to extract structured query statements; based on the module set, the set of environment variables, the virtual module set, the virtual database connection tool set, and the virtual database set, a virtual environment for running the Perl script is constructed; the Perl script is executed in the virtual environment to obtain the structured query statement extraction result of the Perl script. This method decouples SQL execution from the actual database by running SQL through a constructed virtual database. By building virtual modules and virtual database connection tools, it can adapt to both Perl scripts based on DBI modules and scripts based on third-party database connection tools, thereby improving the generalization and flexibility of SQL statement extraction and expanding application scenarios. Furthermore, by constructing a virtual environment and providing dynamic SQL code capture capabilities within that environment, it helps reduce the omission of SQL fragments and improves the completeness of SQL statement extraction. In short, this method improves the generalization, security, and completeness of SQL statement extraction from Perl scripts.
[0052] In one alternative implementation, Figure 1Step S102 in the structured query statement extraction method shown, i.e., the way the computer device constructs a virtual database set based on the database type set, can be as follows: For each database type in the database type set, based on the database type, determine the database connection library for the corresponding programming language and load the database connection library in the program; construct a structured query statement extractor and load a structured query statement parsing tool in the program; the structured query statement parsing tool is used to parse the structured query statement into a syntax tree, extract the table structure information of the syntax tree, convert the table structure information into a pre-defined format, and output the converted table structure information; construct a virtual data generator; the virtual data generator includes a virtual table creation sub-tool and a data generation sub-tool; the virtual table creation sub-tool is used to call the database connection library to construct a virtual table based on the received converted table structure information, and the data generation sub-tool is used to call the database connection library to insert virtual data into the virtual table based on the received converted table structure information; construct the virtual database corresponding to the database type based on the database connection library, the structured query statement extractor, and the virtual data generator; construct a virtual database set based on the virtual databases corresponding to each database type.
[0053] Optionally, after the computer device loads the database connection library in the program, it can also set the address parameter of the database connection library to the address of an empty database.
[0054] Optional structured query parsing tools include sqlparser, sqlglot, and tree-sitter. sqlparser is a library focused on parsing SQL statements, providing an ANSI SQL-compliant parser that parses SQL strings into a structured abstract syntax tree. sqlglot is a more comprehensive SQL parsing, transformation, and generation tool; it's a pure Python-based, dependency-free SQL translator and optimizer that not only parses but also traverses, modifies, and regenerates the abstract syntax tree, ultimately generating the SQL code. tree-sitter is an incremental parser generator that constructs a concrete syntax tree.
[0055] Optionally, the computer device uses a virtual table creation sub-tool to construct a virtual table based on the received converted table structure information by calling a database connection library. This can be done by: receiving the converted table structure information; using the virtual table creation sub-tool to generate table creation SQL code based on the converted table structure information using rule-based methods, neural network-based methods, or big oracle model-based methods, and then calling a database connection library to construct the virtual table.
[0056] Optionally, the computer device uses a data generation sub-tool to insert virtual data into the virtual table based on the received converted table structure information by calling a database connection library. This can be done by: receiving the converted table structure information; using the data generation sub-tool to generate virtual data based on the converted table structure data using machine learning, neural network, or big oracle model methods; and then calling a database connection library to insert the virtual data into the virtual table.
[0057] In some embodiments, after the computer device constructs a virtual database corresponding to the database type based on a database connection library, a structured query extractor, and a virtual data generator, the operation process of the virtual database may include, but is not limited to, the following steps:
[0058] Step 1: Receive the SQL and call the database connection library to execute the SQL.
[0059] Step 2: Determine if the process was successful. If yes, proceed with the next step; otherwise, proceed with the next step.
[0060] Step 3: Call the SQL extractor to obtain the table data structure.
[0061] Step 4: Based on the table data structure, call the virtual data generator to generate virtual data and insert the virtual data into the virtual table.
[0062] Step 5: Call the database connector again to execute the SQL. If it runs successfully, proceed to Step 6; if it fails, proceed to Step 3, until it runs successfully or the number of attempts exceeds the preset number.
[0063] Step 6: Return the results.
[0064] Using this implementation method, virtual database types can be quickly constructed based on the set of database types accessed by Perl scripts, thereby decoupling SQL execution from the actual database, which helps to save database resources and ensure data security.
[0065] In one alternative implementation, Figure 1Step S102 in the structured query statement extraction method shown, i.e., the way the computer device constructs a virtual module set based on the module set, can be as follows: If a database module exists in the module set, declare a database-independent interface virtual module; construct a first function, a second function, a third function, and other functions corresponding to the database-independent interface; wherein, the first function is used to store the structured query statement; the second function is used to read the structured query statement stored in the first function, process the structured query statement to obtain the structured query statement increment, write the structured query statement increment into the structured query statement extraction file, and call the virtual database and return the running result; the third function is used to directly process the structured query statement to obtain the structured query statement increment, write the structured query statement increment into the structured query statement extraction file, and call the virtual database and return the running result; based on the first function, the second function, the third function, and other functions, determine the virtual module set corresponding to the module set.
[0066] Among them, the DBI virtual module refers to a DBI driver or wrapper that does not connect to a real database but simulates the behavior of a database.
[0067] Full SQL, also known as "full update" or "full extraction," refers to operating on the entire dataset each time the SQL is executed. Incremental SQL, also known as "incremental update" or "incremental extraction," refers to processing only the data added, modified, or deleted since the last synchronization each time.
[0068] In some embodiments, the first function can be the prepare function; the second function can be the execute function; the third function can be the do function; and other functions can be other DBI functions.
[0069] In some embodiments, after the computer device determines the virtual module set corresponding to the module set based on the first function, the second function, the third function, and other functions, it may also set the database connection method function to connect to the virtual database.
[0070] This implementation method allows for the rapid construction of virtual module sets, which facilitates the adaptation of different database calling methods and meets general scenarios, thereby improving the generalization and flexibility of SQL statement extraction.
[0071] In one alternative implementation, Figure 1Step S102 in the structured query statement extraction method shown, namely the way the computer device constructs a virtual database connection tool set based on the database connection tool set, can be as follows: For each database connection tool in the database connection tools, construct a virtual function corresponding to the database connection tool; obtain the instruction parameter set corresponding to the database connection tool; add each instruction parameter in the instruction parameter set to the virtual function to obtain the virtual function after adding the instruction parameters; wherein, when the instruction parameters are used to execute structured query statements, the instruction parameters in the virtual function are used to incrementally write the structured query statement into the structured query statement extraction file and execute it in the virtual database; based on the virtual function after adding the instruction parameters, determine the virtual database connection tool corresponding to the database connection tool; construct a virtual database connection tool set based on the virtual database connection tools corresponding to each database connection tool.
[0072] In some embodiments, the computer device obtains the set of instruction parameters corresponding to the database connection tool by: obtaining the operation manual file of the database connection tool; and, based on the operation manual file, obtaining the set of instruction parameters corresponding to the database connection tool (denoted as C). i ).
[0073] In some embodiments, during the process of adding each instruction parameter from the instruction parameter set to the virtual function to obtain the virtual function after adding the instruction parameters, the computer device may also configure the corresponding function for each instruction parameter in the virtual function after adding the instruction parameters based on the function of each instruction parameter.
[0074] For example, suppose the instruction parameter set C i Includes parameter c in And assume c in The function is to execute SQL, so the computer device can execute c in During the process of adding to the virtual function, configure C. in Its function is to write incremental SQL statements to an SQL extraction file and execute them in a pre-built virtual database. Assume c in If the function is other functions, then the computer device can use c in No other processing is performed during the process of adding it to the virtual function.
[0075] In some embodiments, the computer device determines the virtual database connection tool corresponding to the database connection tool based on the virtual function after adding instruction parameters. This may include: if it is determined that the database connection tool supports piped input, adding piped input functionality to the virtual function after adding instruction parameters to obtain a new virtual function; the new virtual function is used to write the piped input increment into a structured query statement extraction file and run it in the virtual database; and the new virtual function is encapsulated into an executable file to obtain the virtual database connection tool corresponding to the database connection tool.
[0076] The pipeline input function is used to write pipeline input increments into an SQL extraction file and execute them in a pre-built virtual database.
[0077] In some embodiments, the process of a computer device constructing a virtual database connection toolset based on a set of database connection tools can be implemented based on a large code generation model.
[0078] This implementation method allows for the rapid construction of virtual database connection tools, making them adaptable to various Perl application scenarios and improving the generalization and flexibility of SQL statement extraction.
[0079] In one alternative implementation, Figure 1 Step S103 in the structured query extraction method shown, namely, the computer device constructs a virtual environment for running Perl scripts based on a set of modules, a set of environment variables, a set of virtual modules, a set of virtual database connection tools, and a set of virtual databases, may include: determining other modules in the module set besides the database module; determining at least one environment variable used by the Perl script based on the set of environment variables, and updating the virtual environment variable corresponding to each environment variable to a virtual value; associating the virtual value with the meaning of the corresponding environment variable; and constructing a virtual environment for running Perl scripts based on other modules, at least one virtual value, the set of virtual modules, the set of virtual database connection tools, and the set of virtual databases.
[0080] In some embodiments, when a computer device updates the virtual environment variable corresponding to each environment variable to a virtual value, the virtual value can be generated in any of the following ways: rule-based, neural network-based, large model-based, etc.
[0081] For example, if the environment variable is a database configuration (such as url, port, user, keyword, etc.), the corresponding virtual environment variable can be a virtual string; if the environment variable is a date, the corresponding virtual environment variable can be a common date (such as 20241231); if the environment variable is a database name, the corresponding virtual environment variable can be a virtual string with the same name.
[0082] In some embodiments, a computer device constructs a virtual environment for running Perl scripts based on other modules, at least one virtual value, a set of virtual modules, a set of virtual database connection tools, and a set of virtual databases. This can be achieved by configuring other modules, at least one virtual value, a set of virtual modules, a set of virtual database connection tools, and a set of virtual databases to obtain a virtual environment for running Perl scripts.
[0083] In some embodiments, the computer device may also be configured with the correct version of Perl, etc.
[0084] Using this implementation method, computer devices can quickly build a virtual environment for running Perl scripts, thereby enabling dynamic capture of SQL code and ensuring the completeness of SQL statement extraction during subsequent SQL extraction.
[0085] In one alternative implementation, Figure 1 After step S104 in the structured query statement extraction method shown, that is, after the computer device executes the Perl script in the virtual environment and obtains the structured query statement extraction result of the Perl script, the structured query statements in the structured query statement extraction result of the Perl script can be cleaned and deduplicated to obtain the target structured query statement extraction result.
[0086] In some embodiments, the computer device performs deduplication on the structured query statements extracted from the Perl script's structured query statement extraction results. This can be done using any of the following methods: string matching-based methods, syntax tree comparison-based methods, or feature similarity-based methods.
[0087] By employing this implementation method, computer devices can improve the quality of SQL statement extraction results by cleaning and deduplicating the structured query statements in the structured query statement extraction results from Perl scripts.
[0088] The SQL statement extraction method provided in the embodiments of this application will be described in general below. Please refer to... Figure 2 , Figure 2 This is a flowchart illustrating another method for extracting structured query statements provided in an embodiment of this application. This method can be executed by a computer device. Figure 2 As shown, this method for extracting structured query statements may include, but is not limited to, the following steps:
[0089] S201. Based on the Perl script to be processed, determine the set of modules used by the Perl script, the set of environment variables, the set of database connection tools, and the set of database types accessed by the Perl script.
[0090] In an optional implementation, the relevant description of step S201 can be found in the description of step S101 above, and will not be repeated here.
[0091] S202. For each database type in the database type set, construct the virtual database corresponding to each database type in sequence to obtain the virtual database set.
[0092] Each virtual database in the virtual database set is used to run the current structured query statement and obtain the running results. The running results are then used to extract structured query statements.
[0093] In one alternative implementation, the computer device may construct virtual databases corresponding to each database type in turn for each database type in the database type set, including but not limited to the following steps:
[0094] Step 1: Select the database connection library corresponding to the programming language based on the database type, load the database connection library in the program, and set the address parameter of the database connection library to the address of an empty database.
[0095] Step 2: Construct an SQL information extractor, import SQL parsing tools (such as sqlparser, sqlglot, tree-sitter, etc.), use the SQL parsing tools to parse the SQL code into a syntax tree and extract table structure information such as tables and field nodes, and output the extracted table structure information according to a pre-defined format.
[0096] Step 3: Construct a virtual data generator, which includes a virtual table creation sub-tool and a data generation sub-tool.
[0097] The virtual table creation sub-tool receives the table structure information output in step two, generates table creation SQL code using any one of the following methods: rule-based, neural network-based, or large language model-based, and calls the database connection library built in step one to construct the virtual table.
[0098] The data generation sub-tool receives the table structure information output in step two, generates virtual data using any one of the methods based on machine learning, neural networks, or large language models, and then calls the database connection library built in step one to insert the virtual data into the virtual table.
[0099] The virtual data generator is constructed by sequentially calling the virtual table creation tool and the data generation tool.
[0100] Step 4: Based on the database connection library, structured query extractor, and virtual data generator, construct the virtual database corresponding to the database type.
[0101] S203. Construct a virtual module based on the database independent interface module in the module set.
[0102] In one alternative implementation, the computer device constructs a virtual module based on the database-independent interface module in the module set, which may include, but is not limited to, the following steps:
[0103] Step 1: Declare a database-independent interface virtual module.
[0104] Step 2: Construct the prepare function.
[0105] The prepare function stores the SQL in memory for later use.
[0106] Step 3: Construct the execute function.
[0107] The functions of the execute function are: (1) receiving SQL or reading SQL prepared and stored in memory; (2) replacing the placeholders in it with parameter values to obtain the complete SQL; (3) writing the complete SQL incrementally into the SQL extraction file, calling the virtual database constructed in step S202 and returning the result.
[0108] Step 4: Construct the do function.
[0109] The functions of the do function are: (1) receiving SQL; (2) replacing the placeholders in it with parameter values to obtain complete SQL; (3) writing the received SQL increment into the SQL extraction file, calling the virtual database constructed in step S202 and returning the result.
[0110] Step 5: Construct other DBI functions.
[0111] It should be noted that this application does not limit the execution order of steps two through five. For example, the computer device may execute step two first, then step three, then step four, and finally step five; or it may execute step three first, then step four, then step two, and finally step five; or it may execute at least two of steps two through five simultaneously, for example, executing steps two and three first, then steps four and five, etc.
[0112] Step 6: Based on the prepare function, execute function, do function, and other DBI functions, determine the virtual module set corresponding to the module set.
[0113] S204. For each database connection tool in the database connection tool set, construct a virtual database connection tool corresponding to the database connection tool, and obtain a set of virtual database connection tools.
[0114] In one alternative implementation, the method by which a computer device constructs a virtual database connection tool corresponding to a database connection tool may include, but is not limited to, the following steps:
[0115] Step 1: Construct the virtual function corresponding to the database connection tool.
[0116] Step 2: Based on the user manual information of the database connection tool, obtain the set of command parameters corresponding to the database connection tool.
[0117] Step 3: For each instruction parameter in the instruction parameter set, if the function of the instruction parameter is to execute SQL, add the instruction parameter to the virtual function and determine that the function of the instruction parameter in the virtual function is to write the SQL increment to the SQL extraction file and execute it in the virtual database constructed in step S202; if the function of the instruction parameter is other, add the instruction parameter to the virtual function without performing any other processing.
[0118] Step 4: Determine whether the database connection tool supports piped input. If it does, add piped input functionality to the virtual function after adding command parameters to obtain a new virtual function. The function of the new virtual function is to write the piped input increment into the SQL extraction file and execute it in the virtual database constructed in step S202.
[0119] Step 5: Package the new virtual function into an executable file, and use the executable file as the virtual database connection tool corresponding to the database connection tool.
[0120] S205. Based on the set of modules, the set of environment variables, the set of virtual modules, the set of virtual database connection tools, and the set of virtual databases, construct a virtual environment for running Perl scripts.
[0121] In one alternative implementation, the computer device constructs a virtual environment for running Perl scripts based on a set of modules, a set of environment variables, a set of virtual modules, a set of virtual database connection tools, and a set of virtual databases. This can be achieved by: identifying modules other than the database module in the module set; determining at least one environment variable used by the Perl script based on the set of environment variables, and updating the virtual environment variable corresponding to each environment variable to a virtual value; associating the virtual value with the meaning of the corresponding environment variable; and constructing the virtual environment for running the Perl scripts based on the other modules, at least one virtual value, the set of virtual modules, the set of virtual database connection tools, and the set of virtual databases.
[0122] S206. Execute the Perl script in the virtual environment to obtain the structured query results of the Perl script.
[0123] S207. Clean and deduplicate the structured query statements in the structured query statement extraction results of the Perl script to obtain the target structured query statement extraction results.
[0124] In this embodiment, SQL execution based on a constructed virtual database decouples SQL execution from the actual database. By constructing a virtual module and a virtual database connection tool, it can adapt to both Perl scripts based on the DBI module and scripts based on third-party database connection tools, thereby improving the generalization and flexibility of SQL statement extraction and expanding application scenarios. By constructing a virtual environment and providing dynamic capture capabilities for SQL code within that environment, it is beneficial to reduce the omission of SQL fragments and improve the completeness of SQL statement extraction. In other words, this method can improve the generalization, security, and completeness of SQL statement extraction from Perl scripts.
[0125] It should be understood that, although Figure 1 and Figure 2 The steps in the flowchart shown are displayed sequentially as indicated by the arrows; however, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise explicitly stated herein, there is no strict order in which these steps are performed, and they can be executed in other orders. Furthermore, Figure 1 and Figure 2 At least some of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the steps or stages in other steps.
[0126] Based on the same inventive concept, this application also provides a structured query statement extraction device for implementing the structured query statement extraction method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations of one or more structured query statement extraction device embodiments provided below can be found in the limitations of the structured query statement extraction method described above, and will not be repeated here.
[0127] Please see Figure 3 , Figure 3 This is a schematic diagram of a structured query statement extraction device provided in an embodiment of this application. Figure 3 As shown, the device may include, but is not limited to:
[0128] Module 301 is used to determine, based on the Perl script to be processed, the set of modules used by the Perl script, the set of environment variables, the set of database connection tools, and the set of database types accessed by the Perl script.
[0129] Module 302 is used to construct a virtual module set based on the module set, a virtual database set based on the database type set, and a virtual database connection tool set based on the database connection tool set. Each virtual module in the virtual module set is used to process structured query statements. Each virtual database in the virtual database set is used to run the current structured query statement and obtain the running result, which is used to extract structured query statements later. Each virtual database connection tool in the virtual database connection tool set is used to extract structured query statements.
[0130] Module 302 is also used to build a virtual environment for running Perl scripts based on a set of modules, a set of environment variables, a set of virtual modules, a set of virtual database connection tools, and a set of virtual databases.
[0131] Processing module 303 is used to execute Perl scripts in a virtual environment and obtain the structured query statement extraction results of the Perl scripts.
[0132] In some embodiments, when the construction module 302 is used to construct a virtual database set based on a set of database types, it specifically performs the following: for each database type in the set of database types, based on the database type, determines the database connection library for the corresponding programming language and loads the database connection library in the program; constructs a structured query statement extractor and loads a structured query statement parsing tool in the program; the structured query statement parsing tool is used to parse the structured query statement into a syntax tree, extract the table structure information of the syntax tree, convert the table structure information into a pre-defined format, and output the converted table structure information; constructs a virtual data generator; the virtual data generator includes a virtual table creation sub-tool and a data generation sub-tool; the virtual table creation sub-tool is used to call the database connection library to construct a virtual table based on the received converted table structure information, and the data generation sub-tool is used to call the database connection library to insert virtual data into the virtual table based on the received converted table structure information; constructs a virtual database corresponding to the database type based on the database connection library, the structured query statement extractor, and the virtual data generator; and constructs a virtual database set based on the virtual databases corresponding to each database type.
[0133] In some embodiments, when the construction module 302 is used to construct a virtual module set based on the module set, it is specifically used to: declare a database-independent interface virtual module when the module set contains a database module; construct a first function, a second function, a third function, and other functions corresponding to the database-independent interface; wherein, the first function is used to store a structured query statement; the second function is used to read the structured query statement stored in the first function, process the structured query statement to obtain a structured query statement increment, write the structured query statement increment into a structured query statement extraction file, and call the virtual database and return the running result; the third function is used to directly process the structured query statement to obtain a structured query statement increment, write the structured query statement increment into a structured query statement extraction file, and call the virtual database and return the running result; and determine the virtual module set corresponding to the module set based on the first function, the second function, the third function, and other functions.
[0134] In some embodiments, when the construction module 302 constructs a virtual database connection tool set based on the database connection tool set, it specifically performs the following steps: for each database connection tool in the database connection tools, constructs a virtual function corresponding to that database connection tool; obtains a set of instruction parameters corresponding to the database connection tool; adds each instruction parameter from the instruction parameter set to the virtual function to obtain a virtual function with the instruction parameters added; wherein, when the instruction parameters are used to execute a structured query statement, the instruction parameters in the virtual function are used to incrementally write the structured query statement into a structured query statement extraction file and execute it in the virtual database; based on the virtual function with the instruction parameters added, determines the virtual database connection tool corresponding to the database connection tool; and constructs a virtual database connection tool set based on the virtual database connection tools corresponding to each database connection tool.
[0135] In some embodiments, when the construction module 302 determines the virtual database connection tool corresponding to the database connection tool based on the virtual function after adding instruction parameters, it specifically performs the following: when it is determined that the database connection tool supports piped input, it adds piped input functionality to the virtual function after adding instruction parameters to obtain a new virtual function; the new virtual function is used to write the piped input increment into a structured query statement extraction file and run it in the virtual database; the new virtual function is encapsulated into an executable file to obtain the virtual database connection tool corresponding to the database connection tool.
[0136] In some embodiments, when the construction module 302 is used based on the module set, environment variable set, virtual module set, virtual database connection tool set, and virtual database set, it is specifically used to: determine other modules in the module set besides the database module; determine at least one environment variable used by the Perl script based on the environment variable set, and update the virtual environment variable corresponding to each environment variable to a virtual value; associate the virtual value with the meaning of the corresponding environment variable; and construct a virtual environment for running the Perl script based on the other modules, at least one virtual value, virtual module set, virtual database connection tool set, and virtual database set.
[0137] In some embodiments, after executing a Perl script in a virtual environment and obtaining the structured query statement extraction result of the Perl script, the processing module 303 is further configured to: clean and deduplicate the structured query statements in the structured query statement extraction result of the Perl script to obtain the target structured query statement extraction result.
[0138] It is understood that the steps that can be implemented by each module in the device and the beneficial effects that can be achieved can be referred to the description in the aforementioned embodiments of the structured query statement extraction method, and will not be repeated here.
[0139] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 4 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When executed by the processor, the computer program implements a structured query extraction method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0140] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0141] In one exemplary embodiment, this application provides a computer device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described structured query extraction method.
[0142] In one exemplary embodiment, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the above-described structured query extraction method.
[0143] In one exemplary embodiment, this application provides a computer program product, including a computer program that, when executed by a processor, implements the steps in the structured query extraction method described above.
[0144] It should be noted that the data involved in this application (including but not limited to Perl scripts to be processed, module sets, environment variable sets, database connection tool sets, and database type sets, etc.) are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with relevant regulations.
[0145] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0146] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0147] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A method for extracting structured query statements, characterized in that, The method includes: Based on the Perl script to be processed, determine the set of modules used by the Perl script, the set of environment variables, the set of database connection tools, and the set of database types accessed by the Perl script; A virtual module set is constructed based on the module set, a virtual database set is constructed based on the database type set, and a virtual database connection tool set is constructed based on the database connection tool set; each virtual module in the virtual module set is used to process structured query statements; each virtual database in the virtual database set is used to run the current structured query statement and obtain the running result, which is used to extract the structured query statement later; each virtual database connection tool in the virtual database connection tool set is used to extract the structured query statement. Based on the module set, the environment variable set, the virtual module set, the virtual database connection tool set, and the virtual database set, a virtual environment for running the Perl script is constructed; The Perl script is executed in the virtual environment to obtain the structured query statement extraction results of the Perl script.
2. The method according to claim 1, characterized in that, The step of constructing a virtual database set based on the database type set includes: For each database type in the database type set, the corresponding database connection library for the programming language is determined based on the database type, and the database connection library is loaded into the program. A structured query statement extractor is constructed, and a structured query statement parsing tool is loaded into the program; the structured query statement parsing tool is used to parse the structured query statement into a syntax tree, extract the table structure information of the syntax tree, convert the table structure information into a pre-defined format, and output the converted table structure information. A virtual data generator is constructed; the virtual data generator includes a virtual table creation sub-tool and a data generation sub-tool; the virtual table creation sub-tool is used to construct a virtual table by calling the database connection library based on the received converted table structure information, and the data generation sub-tool is used to insert virtual data into the virtual table by calling the database connection library based on the received converted table structure information. Based on the database connection library, the structured query statement extractor, and the virtual data generator, a virtual database corresponding to the database type is constructed. A set of virtual databases is constructed based on the virtual databases corresponding to each of the aforementioned database types.
3. The method according to claim 1, characterized in that, The step of constructing a virtual module set based on the module set includes: If a database module exists in the module set, declare a database-independent interface virtual module; Construct a first function, a second function, a third function, and other functions corresponding to other database-independent interfaces; wherein, the first function is used to store the structured query statement; the second function is used to read the structured query statement stored in the first function, process the structured query statement to obtain the structured query statement increment, write the structured query statement increment into a structured query statement extraction file, and call the virtual database and return the running result; the third function is used to directly process the structured query statement to obtain the structured query statement increment, write the structured query statement increment into a structured query statement extraction file, and call the virtual database and return the running result; Based on the first function, the second function, the third function, and the other functions, the virtual module set corresponding to the module set is determined.
4. The method according to claim 1, characterized in that, The step of constructing a virtual database connection toolset based on the database connection toolset includes: For each database connection tool in the database connection tools, construct the corresponding virtual function for that database connection tool; Obtain the set of instruction parameters corresponding to the database connection tool; Each instruction parameter in the instruction parameter set is added to the virtual function to obtain the virtual function with the added instruction parameters; wherein, when the instruction parameter is used to execute a structured query statement, the instruction parameter in the virtual function is used to incrementally write the structured query statement into the structured query statement extraction file and execute it in the virtual database; Based on the virtual function with added instruction parameters, determine the virtual database connection tool corresponding to the database connection tool; A set of virtual database connection tools is constructed based on the virtual database connection tools corresponding to each of the aforementioned database connection tools.
5. The method according to claim 4, characterized in that, The process of determining the virtual database connection tool corresponding to the database connection tool based on the virtual function after adding the instruction parameters includes: If the database connection tool is found to support pipelined input, pipelined input functionality is added to the virtual function after adding instruction parameters to obtain a new virtual function; the new virtual function is used to write the pipelined input increment into a structured query statement extraction file and run it in the virtual database; The new virtual function is encapsulated into an executable file to obtain the virtual database connection tool corresponding to the database connection tool.
6. The method according to claim 1, characterized in that, The system based on the module set, the environment variable set, the virtual module set, the virtual database connection tool set, and the virtual database set includes: Identify the modules in the module set other than the database module; Based on the set of environment variables, at least one environment variable used by the Perl script is determined, and the virtual environment variable corresponding to each environment variable is updated to a virtual value; the virtual value is associated with the meaning of the corresponding environment variable. Based on the other modules, at least one of the virtual values, the set of virtual modules, the set of virtual database connection tools, and the set of virtual databases, a virtual environment for running the Perl script is constructed.
7. The method according to any one of claims 1 to 6, characterized in that, After executing the Perl script in the virtual environment and obtaining the structured query statement extraction results of the Perl script, the process further includes: The structured query statements in the extracted Perl script are cleaned and deduplicated to obtain the target structured query statement extraction result.
8. A structured query statement extraction device, characterized in that, The device includes: The determination module is used to determine, based on the Perl script to be processed, the set of modules used by the Perl script, the set of environment variables, the set of database connection tools, and the set of database types accessed by the Perl script; A construction module is used to construct a virtual module set based on the module set, a virtual database set based on the database type set, and a virtual database connection tool set based on the database connection tool set; each virtual module in the virtual module set is used to process structured query statements; each virtual database in the virtual database set is used to run the current structured query statement and obtain the running result, which is used to extract the structured query statement later; each virtual database connection tool in the virtual database connection tool set is used to extract the structured query statement. The construction module is also used to construct a virtual environment for running the Perl script based on the module set, the environment variable set, the virtual module set, the virtual database connection tool set, and the virtual database set; The processing module is used to execute the Perl script in the virtual environment and obtain the structured query statement extraction results of the Perl script.
9. A device, characterized in that, include: A memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 7.