Structured query statement generation method and device and computer device

By acquiring and parsing the parameters and code templates of structured query statements, providing an editing interface and data source connection, and automatically generating structured query statements, the problem of time-consuming and labor-intensive processes in existing technologies is solved, and efficient and personalized query statement generation and management are achieved.

CN116610693BActive Publication Date: 2026-01-13IND BANK CO +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310483175.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-28
Publication Date
2026-01-13
Estimated Expiration
2043-04-28

AI Technical Summary

Technical Problem

In existing technologies, writing structured query statements is time-consuming and labor-intensive, requiring manual coding or copying and modifying from other programs.

Method used

By obtaining the parameters and code templates of structured query statements, parsing the edited structured text using a preset set of template instances, generating structured query statements, providing a structured text editing interface and data source connection functionality, and achieving automated generation.

Benefits of technology

It reduces the complexity of manually writing code, improves generation efficiency and convenience, and enables personalized and unified management of structured query statements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116610693B_ABST
    Figure CN116610693B_ABST
Patent Text Reader

Abstract

The application relates to a structured query statement generation method and device and computer equipment. The method comprises the following steps: obtaining parameters of a to-be-generated structured query statement and a code template of the to-be-generated structured query statement; wherein the code template is obtained from a preset template instance set, the template instance set is obtained by analyzing and extracting an edited structured text corresponding to a structure information instance according to the structure information instance; and the structured query statement is generated according to the parameters and the code template. The application realizes completely personalized editing and management of a structured query statement code. When it is necessary to generate a structured query statement, only the corresponding structured query statement template and the corresponding parameters need to be determined, the structured query statement can be automatically generated, and the complexity of manual code writing is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database technology, and in particular to a structured query statement generation apparatus, computer device, storage medium, and computer program product. Background Technology

[0002] Structured Query Language (SQL) is a programming language for databases, used to store, query, update, and manage relational databases. There are numerous types of structured queries, and the demand for them is frequent. Currently, writing structured queries involves manual coding or copying them from other programs and then modifying the copied queries. Therefore, writing structured queries is a time-consuming and labor-intensive process. Summary of the Invention

[0003] Therefore, it is necessary to provide a structured query statement generation device, computer equipment, storage medium, and computer program product to address the above-mentioned technical problems.

[0004] Firstly, this application provides a method for generating structured query statements. The method includes:

[0005] A method for generating structured query statements, characterized by comprising:

[0006] Obtain the parameters of the structured query statement to be generated and the code template of the structured query statement to be generated; wherein, the code template is obtained from a preset template instance set, and the template instance set is obtained by parsing and extracting the edited structured text corresponding to the structure information instance based on the structure information instance;

[0007] The structured query statement is generated based on the parameters and the code template.

[0008] In one possible implementation, before obtaining the parameters of the structured query statement to be generated and the code template corresponding to the structured query statement to be generated, the following steps are included:

[0009] Displays an editing interface for structured text;

[0010] The editing interface receives editing operations on the code template of the structured query statement, resulting in edited structured text.

[0011] In one possible implementation, the interface for displaying structured text includes:

[0012] Displays the configuration interface for structured text metastructures;

[0013] The configuration interface receives the configuration operation of the structured text metastructure to obtain the structured text metastructure file;

[0014] Based on the structured text metastructure file, generate the corresponding structured text and display the editing interface of the structured text.

[0015] In one possible implementation, after obtaining the structured text metastructure text, the process further includes:

[0016] Parse the structured text metastructure text to obtain structural information instances;

[0017] Generate a set of structure information instances based on the structure information instances corresponding to each structured text metastructure text.

[0018] In one possible implementation, after generating the structured query statement based on the parameters and the code template, the method further includes:

[0019] Receive configuration operations from the data source and establish a connection to the database corresponding to the data source;

[0020] Use the structured query statement to retrieve data from the database.

[0021] Secondly, this application also provides an apparatus for generating structured query statements, comprising:

[0022] The acquisition module is used to acquire the parameters of the structured query statement to be generated and the code template of the structured query statement to be generated; wherein, the code template is acquired from a preset template instance set, and the template instance set is obtained by parsing and extracting the edited structured text corresponding to the structure information instance based on the structure information instance;

[0023] The generation module is used to generate the structured query statement based on the parameters and the code template.

[0024] One possible implementation also includes:

[0025] The display module is used to show the editing interface for structured text;

[0026] The editing module is used to receive editing operations on the code template of the structured query statement in the editing interface, and obtain the edited structured text.

[0027] In one possible implementation, the display module includes:

[0028] The first display submodule is used to display the configuration interface of the structured text metastructure;

[0029] The configuration submodule is used to receive the configuration operation of the structured text metastructure in the configuration interface and obtain the structured text metastructure file.

[0030] The second display submodule is used to generate corresponding structured text based on the structured text metastructure file and display the editing interface of the structured text.

[0031] In one possible implementation, the display module further includes:

[0032] The parsing submodule is used to parse the structured text metastructure text to obtain structural information instances;

[0033] The generation submodule is used to generate a set of structure information instances based on the structure information instances corresponding to each structured text metastructure text.

[0034] One possible implementation also includes:

[0035] The connection module is used to receive configuration operations from the data source and establish a connection with the database corresponding to the data source.

[0036] The query module is used to query data in the database using the structured query statement.

[0037] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method for generating structured query statements as described in any one of the embodiments of this disclosure.

[0038] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the method for generating structured query statements as described in any one of the embodiments of this disclosure.

[0039] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the method for generating structured query statements as described in any of the embodiments of this disclosure.

[0040] The aforementioned method, apparatus, computer equipment, storage medium, and computer program product for generating structured query statements receive various code templates for editing via structured text. The structured text can have different formats, and the structural information of different formats is stored in corresponding structured information instances. The edited structured text is parsed based on these structured information instances to obtain the code template for the structured query statement. This allows for fully personalized editing and management of structured query statement code. When generating a structured query statement, only the corresponding structured query statement template and input parameters are required; the statement can be automatically generated, reducing the complexity of manual coding. Furthermore, the structured text corresponding to various structured query statement templates is uniformly managed through structured information instances, making it easy and quick to find code templates for structured query statements written by different accounts, thus improving efficiency. Attached Figure Description

[0041] Figure 1 This is a first flowchart illustrating a method for generating structured query statements in one embodiment;

[0042] Figure 2 This is a schematic diagram of the second process of generating a structured query statement in another embodiment;

[0043] Figure 3 This is a structural block diagram of a structured query statement generation device in one embodiment;

[0044] Figure 4 This is an internal structural diagram of a computer device in one embodiment;

[0045] Figure 5 This is a diagram of the internal structure of a computer device in another embodiment. Detailed Implementation

[0046] 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.

[0047] It should be noted that the acquisition, storage, use, and processing of data in this application's technical solution all comply with the relevant provisions of national laws and regulations.

[0048] In one embodiment, such as Figure 1 As shown, a method for generating structured query statements is provided, including the following steps:

[0049] Step S101: Obtain the parameters of the structured query statement to be generated and the code template of the structured query statement to be generated; wherein, the code template is obtained from a preset template instance set, and the template instance set is obtained by parsing and extracting the edited structured text corresponding to the structure information instance based on the structure information instance.

[0050] Specifically, the structured query statement is an important operation statement in relational databases. It can perform various data operations, such as querying, filtering, sorting, grouping, and limiting the number of records. Relational databases include databases that use a relational model to organize data, storing data in the form of rows and columns. This series of rows and columns in a relational database is called a table, and a group of tables constitutes a database. In this embodiment of the disclosure, the parameters of the structured query statement can include variable parameters. For example, the structured query statement to view the total records of table A can include: SELECT COUNT(1) FROM A. Here, table A can be regarded as a parameter because when we need to view other tables, we only need to replace A with the identifier of the target table to be viewed.

[0051] In this embodiment, the code template for the structured query statement may include a common code portion of a class of statements with the same function or purpose, and the code template may include different forms. In an exemplary embodiment, the code template for the structured query statement corresponding to the above embodiment may include: SELECT COUNT(1) FROM @{param}. Here, @{param} can be assigned or replaced according to specific application scenarios. In another exemplary embodiment, the code template for the structured query statement corresponding to the above embodiment may also include: SELECT @{param1} FROM @{param2}. Here, @{param1} and @{param2} can be assigned or replaced according to specific application scenarios.

[0052] In this embodiment of the disclosure, the template instance set may include code templates for various structured query statements. These code templates may originate from the same edited structured text or from different edited structured texts. In an exemplary embodiment, the code templates for structured query statements in the template instance set can be evaluated to filter out templates with a usage frequency greater than a preset threshold and delete those with a usage frequency less than the preset threshold. The structured query statement templates with a usage frequency less than the preset threshold can also be modified and improved. In another exemplary embodiment, the lifecycle of the code templates for structured query statements in the template instance set can be managed, including stages such as creation, modification and maintenance, and termination.

[0053] In this embodiment of the disclosure, structured text may include a text file obtained by standardizing text information according to preset rules. The edited structured text may include structured text obtained after performing some editing operations on the structured text, such as adding, deleting, or modifying data. The metastructure of the structured text may include a structure for defining the structured text structure, which can be understood as a rule system for generating structured text. For example, for structured text 'a', the symbol "..." can be defined. ”、" "and the content between them represent paragraphs within a structured text 'a', which are part of the structured text; while " "and" "It is part of the metastructure of this structured text."

[0054] In an exemplary embodiment, structural information can be extracted from the metastructure corresponding to the structured text to obtain a structural information instance corresponding to the structured text. Accordingly, based on the structural information instance, the corresponding edited structured text can be parsed to obtain the code template of the structured query statement in the edited structured text.

[0055] Step S103: Generate the structured query statement based on the parameters and the code template.

[0056] Specifically, parameters from actual application scenarios can be inserted into the code template, or the parameters can be replaced or assigned to corresponding variables in the code template. For example, in the above embodiment, replacing @{param} in the code template SELECT COUNT(1)FROM@{param} with table A yields the structured query statement SELECT COUNT(1)FROM A. In an exemplary embodiment, when the code template for the structured query statement can include multiple templates, the code templates for multiple structured query statements can be processed in batches to obtain the corresponding structured query statements.

[0057] In the above method for generating structured query statements, various code templates are received and edited via structured text. The structured text can have different formats, and the structural information of different formats is stored in corresponding structure information instances. The edited structured text is parsed based on these structure information instances to obtain the code template for the structured query statement. This allows for fully personalized editing and management of structured query statement code. When generating a structured query statement, only the corresponding structured query statement template and the corresponding parameters need to be determined, and the structured query statement can be automatically generated, reducing the complexity of manual code writing. Furthermore, the structured text corresponding to various structured query statement templates is uniformly managed through structured information instances, making it easy and quick to find code templates for structured query statements written by different users, thus improving efficiency.

[0058] In one possible implementation, before obtaining the parameters of the structured query statement to be generated and the code template corresponding to the structured query statement to be generated, the following steps are included:

[0059] Displays an editing interface for structured text;

[0060] The editing interface receives editing operations on the code template of the structured query statement, resulting in edited structured text.

[0061] Specifically, the structured text can include both offline and online forms. When the structured text is offline, it can be imported into the system for subsequent extraction of structural information and generation of structural information instances. In one exemplary embodiment, the editing interface of the structured text can also display the writing rules for the code template of the structured query statement. In another exemplary embodiment, a selection box can be provided for the user to select an appropriate statement. In yet another exemplary embodiment, validation options can be provided to perform format validation and provide prompts for the code template entered by the user.

[0062] In this embodiment of the disclosure, the structured text can be written in units of tables, or all template structured texts of all tables can be written in a single template structured text. The structure of the structured text must conform to the structural information defined in the metastructure of the structured text.

[0063] In the above embodiments, by displaying a structured text editing interface, users can pre-edit the code template for structured query statements, thereby reusing the code template when generating structured query statements later, improving code generation efficiency. Compared to the traditional method of pasting and modifying structured query statements from other code, this embodiment of the disclosure can effectively manage each code template, facilitate querying, eliminate the need to understand the context of the structured query statement, and decouple the code template from the parameters of the structured query statement.

[0064] In one possible implementation, the interface for displaying structured text includes:

[0065] Displays the configuration interface for structured text metastructures;

[0066] The configuration interface receives the configuration operation of the structured text metastructure to obtain the structured text metastructure file;

[0067] Based on the structured text metastructure file, generate the corresponding structured text and display the editing interface of the structured text.

[0068] Specifically, the meta-structure of the structured text, as described in the above embodiments, may include a structure for defining the structured text structure, which can be understood as a rule system for generating structured text. In one exemplary embodiment, a configuration interface for structured text is displayed, in which rules are configured for the meta-structure of the structured text. This generates a custom syntax system for structured text, and structured text is constructed based on this syntax system. In another exemplary embodiment, the structured text can also be maintained through the configuration interface for structured text.

[0069] The above embodiments allow for the configuration of the meta-structure of structured text through a configuration interface, thereby enabling personalized structured text and improving user convenience and usability.

[0070] In one possible implementation, after obtaining the structured text metastructure text, the process further includes:

[0071] Parse the structured text metastructure text to obtain structural information instances;

[0072] Generate a set of structure information instances based on the structure information instances corresponding to each structured text metastructure text.

[0073] Specifically, the structured text metastructure text is a file used to store the metastructure information of structured text. Parsing the structured text metastructure text involves obtaining corresponding structural information instances from the metastructure text according to the semantic system defined for structured text. These structural information instances are used to extract code templates for structured program statements from the structured text.

[0074] In this embodiment of the disclosure, the metastructure of the structured text can be defined by the user. Therefore, the metastructure of each structured text may be different, and thus the structure information instances of each structured text will also be different. A set of structure information instances is generated based on the structure information instances corresponding to each structured text. In an exemplary embodiment, the lifecycle and usage of the structure information instances in the set of structure information instances can be managed. It should be noted that both automatic and manual management methods can be used to manage the set of structure information instances, allowing users to operate on the set of structure information instances.

[0075] In the above embodiments, by managing the structural information instances corresponding to each structured text metastructure, users are no longer limited to using code templates of their own structured program statements, which greatly improves the generation efficiency of structured program statements.

[0076] In one possible implementation, after generating the structured query statement based on the parameters and the code template, the method further includes:

[0077] Receive configuration operations from the data source and establish a connection to the database corresponding to the data source;

[0078] Use the structured query statement to retrieve data from the database.

[0079] Specifically, users can maintain connection information for all used data sources through the data source configuration function, establishing connections between the program and the database. After completing the data source configuration and connection, users can input and execute structured programming statements where needed to query data. In an exemplary embodiment, query results can be received.

[0080] The above embodiments establish a connection with the database through data source configuration, enabling direct data retrieval from the database using generated structured query statements and receiving the query results. This improves the convenience of data retrieval and enhances development efficiency and quality.

[0081] Figure 2 This is a second flowchart illustrating the method for generating structured query statements in another embodiment, see reference. Figure 2 As shown, the method includes:

[0082] Step S201: Display the configuration interface for the structured text metastructure.

[0083] Step S203: Receive the configuration operation of the structured text metastructure in the configuration interface to obtain the structured text metastructure file.

[0084] Step S205: Generate corresponding structured text based on the structured text metastructure file, and display the editing interface of the structured text.

[0085] Specifically, the meta-structure of the structured text, as described in the above embodiments, may include a structure for defining the structured text structure, which can be understood as a rule system for generating structured text. In one exemplary embodiment, a configuration interface for structured text is displayed, in which rules are configured for the meta-structure of the structured text. This generates a custom syntax system for structured text, and structured text is constructed based on this syntax system. In another exemplary embodiment, the structured text can also be maintained through the configuration interface for structured text.

[0086] Step S207: In the editing interface, receive the editing operation of the code template of the structured query statement to obtain the edited structured text.

[0087] Specifically, the structured text can include both offline and online forms. When the structured text is offline, it can be imported into the system for subsequent extraction of structural information and generation of structured information instances. In an exemplary embodiment, the structured text editing interface can also display the rules for writing code templates for structured query statements.

[0088] Step S101: Obtain the parameters of the structured query statement to be generated and the code template of the structured query statement to be generated.

[0089] Step S103: Generate the structured query statement based on the parameters and the code template.

[0090] Specifically, the structured query statement is an important operation statement in relational databases, capable of performing various data operations such as querying, filtering, sorting, grouping, and limiting quantities. In this embodiment, the code template for the structured query statement may include common code portions shared by a class of statements with the same function or purpose, and this code template may include different forms. In this embodiment, the template instance set may include multiple code templates for structured query statements, which may originate from the same edited structured text or from different edited structured texts.

[0091] Step S209: Receive configuration operations from the data source and establish a connection to the database corresponding to the data source.

[0092] Step S211: Use the structured query statement to query data in the database.

[0093] Specifically, users can maintain connection information for all used data sources through the data source configuration function, establishing connections between the program and the database. After completing the data source configuration and connection, users can input and execute structured programming statements where needed to query data. In an exemplary embodiment, query results can be received.

[0094] The above embodiments, through the configuration of structured text metastructures, enable customization of structured text, allowing users to define, manage, and maintain their own structured query statements in a flexible and clean manner. By using parameters and code templates for structured statements, users can reuse these templates, reducing workload. Therefore, this solution provides users with a loosely coupled, dynamically generated, and easily maintained method for generating, using, and managing structured query statements, enabling them to operate and manage structured query statements in a more flexible and convenient way, improving development efficiency and quality.

[0095] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above 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 performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0096] Based on the same inventive concept, this application also provides a structured query statement generation apparatus for implementing the structured query statement generation method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations of one or more structured query statement generation apparatus embodiments provided below can be found in the limitations of the structured query statement generation method described above, and will not be repeated here.

[0097] In one embodiment, such as Figure 3 As shown, a structured query statement generation apparatus 300 is provided, comprising:

[0098] The acquisition module 301 is used to acquire the parameters of the structured query statement to be generated and the code template of the structured query statement to be generated; wherein, the code template is acquired from a preset template instance set, and the template instance set is obtained by parsing and extracting the edited structured text corresponding to the structure information instance based on the structure information instance;

[0099] The generation module 303 is used to generate the structured query statement based on the parameters and the code template.

[0100] One possible implementation also includes:

[0101] The display module is used to show the editing interface for structured text;

[0102] The editing module is used to receive editing operations on the code template of the structured query statement in the editing interface, and obtain the edited structured text.

[0103] In one possible implementation, the display module includes:

[0104] The first display submodule is used to display the configuration interface of the structured text metastructure;

[0105] The configuration submodule is used to receive the configuration operation of the structured text metastructure in the configuration interface and obtain the structured text metastructure file.

[0106] The second display submodule is used to generate corresponding structured text based on the structured text metastructure file and display the editing interface of the structured text.

[0107] In one possible implementation, the display module further includes:

[0108] The parsing submodule is used to parse the structured text metastructure text to obtain structural information instances;

[0109] The generation submodule is used to generate a set of structure information instances based on the structure information instances corresponding to each structured text metastructure text.

[0110] One possible implementation also includes:

[0111] The connection module is used to receive configuration operations from the data source and establish a connection with the database corresponding to the data source.

[0112] The query module is used to query data in the database using the structured query statement.

[0113] Each module in the aforementioned structured query statement generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0114] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 4 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. 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, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database stores data for methods of generating structured query statements. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a method for generating structured query statements.

[0115] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 5 As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing 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 communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a method for generating structured query statements. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.

[0116] Those skilled in the art will understand that Figure 5The 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.

[0117] 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 above methods. Any references to memory, 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, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0118] 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.

[0119] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. 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 application should be determined by the appended claims.

Claims

1. A method for generating structured query statements, characterized in that, include: Obtain the parameters of the structured query statement to be generated and the code template of the structured query statement to be generated; wherein, the code template is obtained from a preset template instance set, and the template instance set is obtained by parsing and extracting the edited structured text corresponding to the structure information instance; wherein, the structure information instance is obtained by parsing the structured text metastructure file, and the structured text metastructure file is generated by configuring the structured text metastructure, and the structured text metastructure is used to define the structured text syntax rules. The structured query statement is generated based on the parameters and the code template.

2. The method according to claim 1, characterized in that, Before obtaining the parameters of the structured query statement to be generated and the code template corresponding to the structured query statement to be generated, the following steps are also included: Displays an editing interface for structured text; The editing interface receives editing operations on the code template of the structured query statement, resulting in edited structured text.

3. The method according to claim 2, characterized in that, The interface for displaying structured text editing includes: Displays the configuration interface for structured text metastructures; The configuration interface receives the configuration operation of the structured text metastructure to obtain the structured text metastructure file; Based on the structured text metastructure file, generate the corresponding structured text and display the editing interface of the structured text.

4. The method according to claim 3, characterized in that, After obtaining the structured text metastructure file, the process further includes: Parse the structured text metastructure file to obtain structural information instances; Generate a set of structure information instances based on the structure information instances corresponding to each structured text metastructure file.

5. The method according to any one of claims 1 to 4, characterized in that, After generating the structured query statement based on the parameters and the code template, the process further includes: Receive configuration operations from the data source and establish a connection to the database corresponding to the data source; Use the structured query statement to retrieve data from the database.

6. A device for generating structured query statements, characterized in that, include: The acquisition module is used to acquire the parameters of the structured query statement to be generated and the code template of the structured query statement to be generated; wherein, the code template is acquired from a preset template instance set, and the template instance set is obtained by parsing and extracting the edited structured text corresponding to the structure information instance; wherein, the structure information instance is obtained by parsing the structured text metastructure file, and the structured text metastructure file is generated by configuring the structured text metastructure, and the structured text metastructure is used to define the structured text syntax rules; The generation module is used to generate the structured query statement based on the parameters and the code template.

7. The apparatus according to claim 6, characterized in that, Also includes: The display module is used to show the editing interface for structured text; The editing module is used to receive editing operations on the code template of the structured query statement in the editing interface, and obtain the edited structured text.

8. The apparatus according to claim 7, characterized in that, The display module includes: The first display submodule is used to display the configuration interface of the structured text metastructure; The configuration submodule is used to receive the configuration operation of the structured text metastructure in the configuration interface and obtain the structured text metastructure file. The second display submodule is used to generate corresponding structured text based on the structured text metastructure file and display the editing interface of the structured text.

9. The apparatus according to claim 8, characterized in that, The display module also includes: The parsing submodule is used to parse the structured text metastructure file to obtain structural information instances; The generation submodule is used to generate a set of structure information instances based on the structure information instances corresponding to each structured text metastructure file.

10. The apparatus according to any one of claims 6 to 9, characterized in that, Also includes: The connection module is used to receive configuration operations from the data source and establish a connection with the database corresponding to the data source. The query module is used to query data in the database using the structured query statement.

11. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method for generating structured query statements according to any one of claims 1 to 5.

12. 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 for generating structured query statements according to any one of claims 1 to 5.

13. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the method for generating a structured query statement as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data query method and device based on configuration information

    CN110019350A

  • Structured query statement generation method and device and computer equipment

    CN113918594A