Database statement generation method and device, equipment, medium and program product
By identifying the user's data operation requirements information and using the template library to generate database statements, the problem of developers needing to learn multiple database statement syntax is solved, and the development efficiency and statement accuracy are improved.
Patent Information
- Application Number
- CN202411868312.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-03-28
AI Technical Summary
When using multiple databases, developers need to learn the statement syntax of each database, which leads to high learning costs and high time and energy consumption, which in turn reduces development efficiency.
Provides a database statement generation method, which generates matching database statements by identifying user data operation requirements information, and using database statement templates and parameter sets in the template library. Users do not need to learn the database statement syntax, but directly generate the required statements by entering text.
Improve development efficiency, reduce the time and energy to learn database statement syntax, ensure that the generated database statements can meet the needs of users, and improve the accuracy of the statements.
Smart Images

Figure CN119719138A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of artificial intelligence technology and big data technology, and more specifically to a database statement generation method, device, equipment, medium and program product. Background Art
[0002] With the continuous development and innovation of big data technology, databases have gradually become a tool for improving enterprise efficiency and productivity, greatly promoting product development and innovation. In addition, as the business scale continues to grow and new businesses continue to emerge, different databases need to be used to adapt to the characteristics of different businesses.
[0003] Since the statement syntax of different databases is different, when using multiple databases, developers are usually required to learn the statement syntax of each database. However, learning database statement syntax is not only costly, but also consumes a lot of time and energy of developers, which leads to low development efficiency. Summary of the invention
[0004] In view of the above problems, the present disclosure provides a database statement generation method, apparatus, device, medium and program product.
[0005] According to a first aspect of the present disclosure, a method for generating a database statement is provided, comprising: in response to receiving a user's input text, recognizing the input text to obtain the user's data operation requirement information; generating a plurality of first database statements matching the data operation requirement information according to the data operation requirement information and a database statement template set stored in a first template library; displaying the data operation requirement information and the plurality of first database statements; and in response to the user's modification operation on the data operation requirement information, generating a target database statement according to the modified data operation requirement information and the database statement template set stored in the first template library when it is determined that the plurality of first database statements do not meet the user's requirements due to the data operation requirement information.
[0006] According to an embodiment of the present disclosure, the first template library stores a database parameter set, and the multiple first database statements matching the data operation requirement information are generated based on the data operation requirement information and the database statement template set stored in the first template library, including: determining multiple database statement templates matching the data operation requirement information from the database statement template set; determining target database parameters matching the data operation requirement information from the database parameter set; and filling the target database parameters into the multiple database statement templates to obtain multiple first database statements corresponding to the multiple database statement templates.
[0007] According to an embodiment of the present disclosure, in response to the user's modification operation on the above-mentioned data operation requirement information, a target database statement is generated according to the modified data operation requirement information and the database statement template set stored in the above-mentioned first template library, including: generating multiple second database statements matching the above-mentioned modified data operation requirement information according to the above-mentioned modified data operation requirement information and the database statement templates stored in the above-mentioned first template library; displaying the above-mentioned multiple second database statements; and in response to the above-mentioned user's selection operation, determining that the second database statement selected by the user is the above-mentioned target database statement.
[0008] According to an embodiment of the present disclosure, the method further includes: in response to a user's modification operation on a database statement, determining that the modified database statement is the target database statement, wherein the database statement is the first database statement or the second database statement.
[0009] According to an embodiment of the present disclosure, the first template library stores a database parameter set, and the method further includes: in a case where it is determined that the modification operation on the database statement is used to modify the database parameters, obtaining the modified database parameters; matching the modified database parameters with the database parameters in the database parameter set to obtain a matching result; in a case where it is determined that the matching result indicates that the database parameter set does not include the modified database parameters, classifying the modified database parameters using a preset classification model to obtain a parameter category matching the modified database parameters; and storing the modified database parameters and the parameter category matching the modified database in the database parameter set.
[0010] According to an embodiment of the present disclosure, determining the target database parameters matching the above-mentioned data operation requirement information from the above-mentioned database parameter set includes: determining the target parameter category matching the above-mentioned data operation requirement information from multiple parameter categories; and determining the target database parameters from multiple database parameters corresponding to the above-mentioned target parameter category based on the above-mentioned data operation requirement information.
[0011] According to an embodiment of the present disclosure, the method further includes: in response to the user selecting a statement escape operation, determining the target statement type selected by the user; determining a second template library corresponding to the target statement type; and generating an escaped target database statement based on the target database statement and the database statement template set stored in the second template library.
[0012] A second aspect of the present disclosure provides a database statement generation device, comprising: an identification module, for identifying the input text in response to receiving a user's input text, and obtaining the user's data operation requirement information; a first generation module, for generating a plurality of first database statements matching the data operation requirement information according to the data operation requirement information and a database statement template set stored in a first template library; a display module, for displaying the data operation requirement information and the plurality of first database statements; and a second generation module, for generating a target database statement according to the modified data operation requirement information and the database statement template set stored in the first template library in response to the user's modification operation on the data operation requirement information when it is determined that the plurality of first database statements do not meet the user's requirements due to the data operation requirement information.
[0013] A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the above method.
[0014] The fourth aspect of the present disclosure further provides a computer-readable storage medium having a computer program or instructions stored thereon, which implements the steps of the above method when the above computer program or instructions are executed by a processor.
[0015] The fifth aspect of the present disclosure further provides a computer program product, including a computer program or instructions, which implement the steps of the above method when the above computer program or instructions are executed by a processor.
[0016] According to the embodiment of the present disclosure, the user's data operation requirement information is obtained by identifying the user's input text, and the first database statement is generated using the data operation requirement information and the database statement template in the database statement template set, without the user having to learn the database statement syntax and manually write the database statement, thereby improving development efficiency. Furthermore, in the case where it is determined that the multiple first database statements do not meet the user's needs due to the data operation requirement information, a target database statement is generated according to the data operation requirement information modified by the user, so that the obtained target database statement can meet the user's needs, thereby improving the accuracy of the target database statement. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0018] Figure 1The application scenario diagram schematically shows the database statement generation method, apparatus, device, medium and program product according to the embodiment of the present disclosure;
[0019] Figure 2 A flowchart of a method for generating a database statement according to an embodiment of the present disclosure is schematically shown;
[0020] Figure 3 A schematic diagram schematically shows a method of generating a first database statement according to an embodiment of the present disclosure;
[0021] Figure 4 The schematic diagram shows an architecture diagram for generating a target database statement according to a specific embodiment of the present disclosure;
[0022] Figure 5 A schematic diagram showing a structure of a database statement generating device according to an embodiment of the present disclosure; and
[0023] Figure 6 A block diagram of an electronic device suitable for implementing a database statement generating method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0024] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0025] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0026] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0027] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0028] In the technical solution of the present disclosure, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0029] In the scenario of using personal information for automated decision-making, the methods, devices, and systems provided by the embodiments of the present disclosure provide users with corresponding operation portals for users to choose to agree or reject the automated decision-making results; if the user chooses to reject, the expert decision-making process will be entered. The expression "automated decision-making" here refers to the activity of automatically analyzing and evaluating a person's behavioral habits, interests and hobbies, or economic, health, credit status, etc. through computer programs, and making decisions. The expression "expert decision-making" here refers to the activity of making decisions by people who specialize in a certain field, have specialized experience, knowledge and skills, and have reached a certain level of professionalism.
[0030] Different databases differ in terms of data operations and statement syntax. Developers can only adapt to different databases by learning how to operate different databases and becoming familiar with the operation interfaces of different databases. However, in actual business processing, developers do not have enough time to learn new database statement syntax, which causes errors in database statements due to unfamiliarity with syntax, resulting in low efficiency and development obstruction. In addition, learning database statement syntax consumes a lot of time and energy of developers, and the learning cost is high. In particular, when encountering urgent needs, the response speed is slow and the emergency response time is prolonged.
[0031] An embodiment of the present disclosure provides a method for generating a database statement. In response to receiving a user's input text, the input text is recognized to obtain the user's data operation requirement information; based on the data operation requirement information and a database statement template set stored in a first template library, a plurality of first database statements matching the data operation requirement information are generated; the data operation requirement information and the plurality of first database statements are displayed; and in a case where it is determined that the plurality of first database statements do not meet the user's requirements due to the data operation requirement information, in response to the user's modification operation on the data operation requirement information, a target database statement is generated based on the modified data operation requirement information and the database statement template set stored in the first template library.
[0032] The embodiment of the present disclosure can generate database statements based on the user's input text only, without the user having to learn the database statement syntax, thereby improving development efficiency. In addition, through the user's modification operation on the data operation requirement information, the target database statement obtained can meet the user's needs and improve the accuracy of the target database statement.
[0033] Figure 1 The application scenario diagram of the database statement generation method, apparatus, device, medium and program product according to the embodiments of the present disclosure is schematically shown.
[0034] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0035] The user can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).
[0036] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0037] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0038] It should be noted that the database statement generation method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the database statement generation device provided in the embodiment of the present disclosure can generally be set in the server 105. The database statement generation method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the database statement generation device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.
[0039] For example, a user can send input text to a server 105 through a first terminal device 101, a second terminal device 102, and a third terminal device 103 via a network 104. In response to receiving the user's input text, the server 105 identifies the input text and obtains the user's data operation requirement information. After generating multiple first database statements matching the data operation requirement information based on the data operation requirement information and a database statement template set stored in a first template library, the data operation requirement information and the multiple first database statements are sent to the first terminal device 101, the second terminal device 102, and the third terminal device 103 via a network 104, so as to display the data operation requirement information and the multiple first database statements on the first terminal device 101, the second terminal device 102, and the third terminal device 103. When it is determined that the data operation requirement information causes multiple first database statements to fail to meet the user's needs, the user may modify the data operation requirement information through the first terminal device 101, the second terminal device 102, and the third terminal device 103. The server 105 generates a target database statement in response to the user's modification operation on the data operation requirement information according to the modified data operation requirement information and the database statement template set stored in the first template library.
[0040] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0041] The following will be based on Figure 1 The scene described by Figure 2~Figure 6 The database statement generating method of the disclosed embodiment is described in detail.
[0042] Figure 2 The flowchart of the method for generating a database statement according to an embodiment of the present disclosure is schematically shown.
[0043] like Figure 2 As shown, the database statement generation of this embodiment includes operations S210 to S240.
[0044] In operation S210, in response to receiving the input text of the user, the input text is recognized to obtain the data operation requirement information of the user.
[0045] According to an embodiment of the present disclosure, the input text may be a database statement or a natural language text. Specifically, when the user inputs the text, he may input a database statement that may contain errors or a natural language text that represents the demand.
[0046] According to an embodiment of the present disclosure, the data operation requirement information may be a keyword in the input text that can represent the user's requirement, and may also include an expanded keyword having the same meaning as the keyword.
[0047] According to an embodiment of the present disclosure, input text can be input into a preset text recognition model for text recognition to obtain data operation requirement information. Specifically, the text recognition model can be obtained by training a machine learning model or a deep learning model using the user's historical input text.
[0048] In operation S220, a plurality of first database statements matching the data operation requirement information are generated according to the data operation requirement information and a database statement template set stored in the first template library.
[0049] According to an embodiment of the present disclosure, since different sentence types correspond to different grammars, different template libraries may be set for different sentence types. Specifically, the first template library may be a template library corresponding to a preset sentence type.
[0050] According to an embodiment of the present disclosure, a database statement template set may include multiple database statement templates, and different database statement templates may represent different operations. Specifically, the database statement template may include operations such as adding (insert) data, deleting (delete) data, modifying (update) data, and querying (select) data, and may also include operations such as joint table query and conditional screening.
[0051] According to an embodiment of the present disclosure, a database statement template matching the data operation requirement information can be determined from a database statement template set, and then a first database statement is generated according to the data operation requirement information and the matching database statement template.
[0052] According to an embodiment of the present disclosure, when determining a database statement template that matches the database statement operation requirement information, multiple database statement templates with the highest matching degree may be determined, and then a first database statement corresponding to each database statement template is generated.
[0053] In operation S230, data operation requirement information and a plurality of first database statements are displayed.
[0054] According to an embodiment of the present disclosure, after generating multiple first database statements, the multiple first database statements and data operation requirement information can be returned to the user's terminal, and the multiple first database statements and data operation requirement information can be displayed on the terminal, so that the user can understand the correspondence between the data operation requirement information and the first database statements, and select the first database statement that meets the requirements.
[0055] According to an embodiment of the present disclosure, when displaying data operation requirement information, the user's input text may be displayed, and keywords related to the data operation requirement information in the input text may be prominently displayed.
[0056] In operation S240, when it is determined that the multiple first database statements do not meet the user's needs due to the data operation requirement information, in response to the user's modification operation on the data operation requirement information, a target database statement is generated based on the modified data operation requirement information and the database statement template set stored in the first template library.
[0057] According to an embodiment of the present disclosure, the input text may fail to express actual needs due to the user's expression habits, which may lead to inaccurate data operation requirement information generated based on the input text. At this time, the user can modify the data operation requirement information.
[0058] According to an embodiment of the present disclosure, since the data operation requirement information is obtained by recognizing the input text, it may not be able to accurately represent the user's needs, and as a result, the first database statement generated based on the data operation requirement information cannot meet the user's needs. At this time, the user can also modify the data operation requirement information.
[0059] According to an embodiment of the present disclosure, after a user modifies data operation information, a target database statement that meets the user's needs can be generated based on the modified data operation requirement information and a database statement template set.
[0060] According to an embodiment of the present disclosure, when the input text is a natural language text, the target database statement may be a database statement that meets the requirements; when the input text is a database statement, the target database statement may be a revised database statement.
[0061] According to an embodiment of the present disclosure, a database statement template matching the modified data operation information can be determined from a database statement template set, and then a target database statement is generated based on the modified data operation requirement information and the matching database statement template.
[0062] According to the embodiments of the present disclosure, the user's input text is recognized to obtain the user's data operation requirement information, and the first database statement is generated using the data operation requirement information and a database statement template in a database statement template set, without the user having to learn the database statement syntax and manually write the database statement, thereby improving development efficiency. Furthermore, when it is determined that the data operation requirement information causes multiple first database statements to not meet the user's needs, a target database statement is generated according to the data operation requirement information modified by the user, so that the obtained target database statement can meet the user's needs, thereby improving the accuracy of the target database statement.
[0063] According to an embodiment of the present disclosure, multiple first database statements matching the data operation requirement information are generated based on the data operation requirement information and a database statement template set stored in a first template library, including: determining multiple database statement templates matching the data operation requirement information from the database statement template set; determining target database parameters matching the data operation requirement information from a database parameter set; and filling the target database parameters into multiple database statement templates to obtain multiple first database statements corresponding to the multiple database statement templates.
[0064] According to an embodiment of the present disclosure, when the input text is a natural language text such as Chinese, the obtained data operation requirement information is also in Chinese. At this time, in order to improve the matching efficiency and accuracy, the Chinese data operation requirement information can be translated into English and then matched using the English data operation requirement information.
[0065] According to an embodiment of the present disclosure, a database statement template set includes multiple database statement templates. Specifically, when determining multiple database statement templates that match data operation requirement information, the degree of matching between the data operation requirement information and each database statement in the database statement template set can be calculated, and multiple database statement templates with the highest matching degree can be determined as database statement templates that match the data operation requirement information.
[0066] According to an embodiment of the present disclosure, the first template library stores a database parameter set, which may include multiple database parameters. Specifically, the database parameters may include a database identifier, a data table identifier, and a field identifier required when generating a database statement.
[0067] According to an embodiment of the present disclosure, the data table represented by the data table identifier may belong to the database represented by the database identifier, that is, one database identifier may correspond to multiple data table identifiers. The field represented by the field identifier may belong to the data table represented by the data table identifier, that is, one data table identifier may correspond to multiple field identifiers.
[0068] According to the embodiments of the present disclosure, when determining the target database parameters, the target database identifier, the target data table identifier, and the target field identifier that match the data operation requirement information can be determined in sequence. Specifically, the target database identifier that matches the data operation requirement information can be determined first, and then the target data table identifier that matches the data operation requirement information can be determined from the multiple data table identifiers corresponding to the target database identifier, and finally the target field identifier that matches the data operation requirement information can be determined from the multiple field identifiers that match the target data table identifier.
[0069] According to an embodiment of the present disclosure, when filling target data parameters into a database statement template, the target database identifier, target data table identifier and target field identifier may be respectively filled into the database statement template to obtain a first database statement corresponding to the database statement template.
[0070] According to the embodiments of the present disclosure, by matching database statement templates and target database parameters according to data operation requirement information, users do not need to understand database parameters and syntax of database statements, thereby improving development efficiency.
[0071] Figure 3 A schematic diagram of generating a first database statement according to an embodiment of the present disclosure is schematically shown.
[0072] like Figure 3As shown, the input text 310 is recognized to obtain data operation requirement information 320. Multiple database statement templates matching the data operation requirement information 320 are determined from the database statement template set 330, such as database statement template 350_1, database statement template 350_2, ..., database statement template 350_n, and target database parameters 360 matching the data operation requirement information 320 are determined from the database parameter set 340. The target database parameters 360 are filled into the database statement template 350_1 to obtain a first database statement 370_1, the target database parameters 360 are filled into the database statement template 350_2 to obtain a first database statement 370_2, ..., the target database parameters 360 are filled into the database statement template 350_n to obtain a first database statement 370_n.
[0073] According to an embodiment of the present disclosure, in response to a user's modification operation on data operation requirement information, a target database statement is generated based on the modified data operation requirement information and a set of database statement templates stored in a first template library, including: generating multiple second database statements matching the modified data operation requirement information based on the modified data operation requirement information and the database statement templates stored in the first template library; displaying the multiple second database statements; and in response to a user's selection operation, determining that the second database statement selected by the user is the target database statement.
[0074] According to an embodiment of the present disclosure, multiple second database statements matching the modified data operation requirement information are generated based on the modified data operation requirement information and the database statement templates stored in the first template library, including: determining multiple database statement templates matching the modified data operation requirement from a database statement template set; determining database parameters matching the modified data operation requirement information from a database parameter set; and filling the database parameters into multiple database statement templates to obtain multiple second database statements corresponding to the multiple database statement templates.
[0075] According to an embodiment of the present disclosure, when displaying multiple second database statements, the modified data operation requirement information may also be displayed simultaneously, so as to facilitate the user to understand the corresponding relationship between the data operation requirement information and the first database statement.
[0076] According to an embodiment of the present disclosure, when it is determined that multiple second database statements do not meet user needs due to the modified data operation requirement information, the user can modify the data operation requirement information again until the generated database statements meet user needs or the reason why the database statements do not meet the needs is not caused by the data operation requirement information.
[0077] According to an embodiment of the present disclosure, when there is a database statement that can meet the user's needs among multiple second database statements, the user can select the second database statement that meets the needs from the multiple second database statements and determine the second database statement that meets the needs as the target database statement.
[0078] According to an embodiment of the present disclosure, the second database statement is regenerated by using the modified data operation requirement information, and the target database statement is determined from the second database statement, thereby improving the accuracy of the target database statement.
[0079] According to an embodiment of the present disclosure, the database statement generation method further includes: in response to a user's modification operation on the database statement, determining the modified database statement as a target database statement.
[0080] According to an embodiment of the present disclosure, the database statement is a first database statement or a second database statement.
[0081] According to an embodiment of the present disclosure, when the data operation requirement information is accurate but the database statement is still inaccurate, the user can directly modify the database statement. Specifically, the user can modify the database statement that best meets the requirement among the multiple first database statements or the multiple second database statements.
[0082] According to an embodiment of the present disclosure, since the first database statement and the second database statement are generated based on the database statement template set and the database parameter set stored in the first template library, when the corresponding database statement template or database parameter is not stored in the database statement template set and the database parameter set, even if the data operation requirement is accurate, an accurate database statement cannot be obtained.
[0083] For example, when the database parameter set lacks a data table identifier of a data table to which the to-be-operated data belongs, the obtained database statement also does not include the data table identifier, and thus an accurate database statement cannot be obtained.
[0084] According to an embodiment of the present disclosure, when the first database statement or the second database statement meets the data operation requirements, the user can also modify the statement logic of the first database statement or the second database statement, so that the modified first database statement or the modified second database statement can operate the database more efficiently and avoid consuming database resources. Specifically, when the user modifies the statement logic, the database statement with the highest matching degree with the current database statement can be displayed to assist the user in making the modification.
[0085] According to the embodiments of the present disclosure, when the data operation requirement information is correct, the user can directly modify the first database statement and the second database statement to improve the accuracy of the target database statement.
[0086] According to an embodiment of the present disclosure, the database statement generation method also includes: in a case where it is determined that the modification operation on the database statement is used to modify the database parameters, obtaining the modified database parameters; matching the modified database parameters with the database parameters in the database parameter set to obtain a matching result; in a case where it is determined that the matching result indicates that the database parameter set does not include the modified database parameters, classifying the modified database parameters using a preset classification model to obtain a parameter category that matches the modified database parameters; and storing the modified database parameters and the parameter category that matches the modified database into the database parameter set.
[0087] According to an embodiment of the present disclosure, the first template library stores a database parameter set, and the database parameter set may include a database identifier, a data table identifier, and a field identifier.
[0088] According to an embodiment of the present disclosure, a user may directly modify database parameters in a database statement to modify the database parameters to database parameters that meet the requirements.
[0089] For example, the user needs to operate on the data in data table 1, but the database statement indicates the operation on the data in data table 2. In this case, the user can modify the data table identifier representing data table 2 in the database statement to the data table identifier representing data table 1.
[0090] According to an embodiment of the present disclosure, when the modified database parameters are matched with the database parameters in the data set, it can be determined whether there are database parameters in the data set that are the same as the modified database parameters to obtain a matching result.
[0091] According to an embodiment of the present disclosure, when it is determined that the matching result characterization database parameter set does not include the modified database parameter, that is, the modified database parameter is a newly added database parameter, the modified database parameter may be stored in the database parameter set.
[0092] According to an embodiment of the present disclosure, before storing the modified database parameters in a database parameter set, the modified database parameters can be classified using a preset classification model to obtain parameter categories corresponding to the modified database parameters. Specifically, the preset classification model can be obtained by training a decision tree model using other database parameters and parameter categories of the database parameters.
[0093] According to an embodiment of the present disclosure, a parameter category can represent category information of a database object represented by a database parameter. Specifically, when the database parameter is a database identifier, the parameter category can represent the purpose of the database or the category of stored data; when the database parameter is a data table identifier, the parameter category can represent the purpose of the data table.
[0094] For example, data tables can be divided into summary tables and statistical tables according to their purpose; databases can be divided into employee information databases, accounting information databases, etc. according to the categories of data stored in the database.
[0095] According to an embodiment of the present disclosure, it is determined whether the modified database parameter is a newly added database parameter, and the newly added database parameter is classified and stored to facilitate subsequent use of the newly added database parameter to generate a database statement.
[0096] According to an embodiment of the present disclosure, target database parameters matching data operation requirement information are determined from a database parameter set, including: determining a target parameter category matching the data operation requirement information from multiple parameter categories; and determining the target database parameters from multiple database parameters corresponding to the target parameter category based on the data operation requirement information.
[0097] According to an embodiment of the present disclosure, a large number of database parameters are stored in the database parameter set, so when the data operation requirement information is matched with the database parameters stored in the database parameter set one by one, the efficiency is low.
[0098] According to the embodiments of the present disclosure, since the parameter category can characterize the purpose of the database object represented by the database parameter, the data operation requirements can be first matched with multiple parameter categories to determine the target parameter category that meets the requirements, and then the target database parameter can be determined from the multiple database parameters that match the target parameter category.
[0099] According to an embodiment of the present disclosure, a target parameter category matching the data operation requirement can be determined from multiple parameter categories corresponding to database identifiers, and then a database identifier that best matches the data operation requirement can be determined as the target database identifier from multiple database identifiers under the target parameter category.
[0100] According to the embodiment of the present disclosure, the target data table identifier and the target field identifier may be determined in sequence using the same method as that for determining the target database identifier, which will not be described in detail herein.
[0101] According to the embodiments of the present disclosure, by matching parameter categories first and then matching specific database parameters, invalid matching is avoided, matching efficiency is improved, and thus the efficiency of generating database statements is improved.
[0102] According to an embodiment of the present disclosure, in response to a user selecting a statement escape operation, the target statement type selected by the user is determined; a second template library corresponding to the target statement type is determined; and an escaped target database statement is generated based on the target database statement and a set of database statement templates stored in the second template library.
[0103] According to an embodiment of the present disclosure, since the first template library corresponds to a preset statement type, the obtained target database statement should also be of the preset statement type. Therefore, when the user needs a database statement of another statement type, the target database statement needs to be escaped.
[0104] According to an embodiment of the present disclosure, a plurality of sentence types may be displayed to a user in the form of a drop-down box in a terminal, and a target sentence type selected by the user may be determined according to a selection operation of the user.
[0105] According to an embodiment of the present disclosure, the second template library may be a template library corresponding to the target statement type. Specifically, the second template library may store a database statement template set corresponding to the target statement type.
[0106] According to an embodiment of the present disclosure, the database statement template set stored in the second template library may include database statement templates of multiple target statement types.
[0107] According to an embodiment of the present disclosure, the target database statement can be used to match the database statement template set stored in the second template library, determine the database statement template with the highest matching degree, and fill the database parameters in the target database statement into the database statement template to obtain the escaped target database statement.
[0108] According to an embodiment of the present disclosure, the target database statement is escaped through the database statement template set stored in the second template library, so that the user does not need to understand the statement syntax of multiple different databases, thereby improving development efficiency.
[0109] Figure 4 The schematic diagram shows an architecture diagram for generating a target database statement according to a specific embodiment of the present disclosure.
[0110] like Figure 4As shown, the user can input text through the front-end page, and the input text can be a natural language text or a database statement. When the back-end processing system uses the judger 410 to determine that the input text is a database statement, it determines that the current mode is the statement check and escape mode, inputs the database statement into the statement processing module 421 of the statement processing engine 420, and uses the second template library 430_1, the second template library 430_2, ..., the second template library 430_n to complete the error correction of the database statement, return the correct target database statement, and display the target database statement on the front end. While displaying the target database statement, the user can also be prompted on the front end through a drop-down box whether to escape, and when the user chooses to escape, the escaped target database statement is displayed on the front end.
[0111] When the judgement device 410 judges that the input text is a natural language text, the retaining wall mode is determined to be a sentence generation mode, the natural language text is input into the natural language processing module 422 of the sentence processing engine 420, the natural language text is converted into a target database sentence of a preset sentence type using the first template library 440, and the target database sentence is returned. While displaying the target database sentence, the user can be prompted on the front end through a drop-down box whether escape is required, and enter the escape mode when the user chooses to escape.
[0112] Based on the above database statement generation method, the present disclosure also provides a database statement generation device. Figure 5 The device is described in detail.
[0113] Figure 5 The structural block diagram of the database statement generating device according to the embodiment of the present disclosure is schematically shown.
[0114] like Figure 5 As shown, the database statement generating device 500 of this embodiment includes a recognition module 510 , a first generating module 520 , a display module 530 and a second generating module 540 .
[0115] The recognition module 510 is used to recognize the input text in response to receiving the input text of the user, and obtain the data operation requirement information of the user. In one embodiment, the recognition module 510 can be used to perform the operation S210 described above, which will not be repeated here.
[0116] The first generation module 520 is used to generate a plurality of first database statements matching the data operation requirement information according to the data operation requirement information and the database statement template set stored in the first template library. In one embodiment, the first generation module 520 can be used to perform the operation S220 described above, which will not be described in detail here.
[0117] The display module 530 is used to display the data operation requirement information and the first database statements. In one embodiment, the display module 530 can be used to perform the operation S230 described above, which will not be described in detail here.
[0118] The second generation module 540 is used to determine that the data operation requirement information causes the plurality of first database statements to not meet the user's requirements, and in response to the user's modification operation on the data operation requirement information, generate a target database statement according to the modified data operation requirement information and the database statement template set stored in the first template library. In one embodiment, the second generation module 540 can be used to perform the operation S240 described above, which will not be described in detail here.
[0119] According to an embodiment of the present disclosure, the first template library stores a database parameter set, and the first generation module 520 includes a template matching submodule, a parameter matching submodule, and a filling submodule.
[0120] The template matching submodule is used to determine multiple database statement templates that match the data operation requirement information from the database statement template set.
[0121] The parameter matching submodule is used to determine the target database parameters that match the data operation requirement information from the database parameter set.
[0122] The filling submodule is used to fill the target database parameters into multiple database statement templates to obtain multiple first database statements corresponding to the multiple database statement templates.
[0123] According to an embodiment of the present disclosure, the second generation module 540 includes a sentence generation submodule, a sentence display submodule, and a sentence determination submodule.
[0124] The statement generation submodule is used to generate a plurality of second database statements matching the modified data operation requirement information according to the modified data operation requirement information and the database statement templates stored in the first template library.
[0125] The statement display submodule is used to display multiple second database statements.
[0126] The statement determination submodule is used to determine, in response to a selection operation of the user, that the second database statement selected by the user is a target database statement.
[0127] According to an embodiment of the present disclosure, the database statement generating device 500 further includes a modification module.
[0128] The modification module is used to determine the modified database statement as a target database statement in response to a modification operation of a user on a database statement, wherein the database statement is a first database statement or a second database statement.
[0129] According to an embodiment of the present disclosure, the first template library stores a database parameter set, and the database statement generating device 500 further includes a parameter acquisition module, a parameter matching module, a parameter classification module and a parameter storage module.
[0130] The parameter acquisition module is used to acquire the modified database parameters when it is determined that the modification operation on the database statement is used to modify the database parameters.
[0131] The parameter matching module is used to match the modified database parameters with the database parameters in the database parameter set to obtain a matching result.
[0132] The parameter classification module is used to classify the modified database parameters using a preset classification model to obtain parameter categories matching the modified database parameters when it is determined that the matching result characterization database parameter set does not include the modified database parameters.
[0133] The parameter storage module is used to store the modified database parameters and the parameter category matching the modified database into the database parameter set.
[0134] According to an embodiment of the present disclosure, the parameter matching module includes a category determination submodule and a parameter determination submodule.
[0135] The category determination submodule is used to determine a target parameter category that matches the data operation requirement information from multiple parameter categories.
[0136] The parameter determination submodule is used to determine the target database parameter from a plurality of database parameters corresponding to the target parameter category according to the data operation requirement information.
[0137] According to an embodiment of the present disclosure, the database statement generating device 500 further includes a type determination module, a template library determination module and an escape module.
[0138] The type determination module is used for determining the target sentence type selected by the user in response to the user selecting a sentence escape operation.
[0139] The template library determination module is used to determine a second template library corresponding to the target sentence type.
[0140] The escape module is used to generate an escaped target database statement according to the target database statement and the database statement template set stored in the second template library.
[0141] According to an embodiment of the present disclosure, any multiple modules of the identification module 510, the first generation module 520, the display module 530, and the second generation module 540 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the identification module 510, the first generation module 520, the display module 530, and the second generation module 540 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, at least one of the identification module 510 , the first generation module 520 , the display module 530 , and the second generation module 540 may be at least partially implemented as a computer program module, and when the computer program module is executed, a corresponding function may be performed.
[0142] Figure 6 A block diagram of an electronic device suitable for implementing a database statement generating method according to an embodiment of the present disclosure is schematically shown.
[0143] like Figure 6 As shown, the electronic device 600 according to an embodiment of the present disclosure includes a processor 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 to a random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a dedicated microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include an onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0144] In RAM 603, various programs and data required for the operation of electronic device 600 are stored. Processor 601, ROM 602 and RAM 603 are connected to each other via bus 604. Processor 601 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 602 and / or RAM 603. It should be noted that the program can also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in one or more memories.
[0145] According to an embodiment of the present disclosure, the electronic device 600 may further include an input / output (I / O) interface 605, which is also connected to the bus 604. The electronic device 600 may further include one or more of the following components connected to the input / output (I / O) interface 605: an input portion 606 including a keyboard, a mouse, etc.; an output portion 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 608 including a hard disk, etc.; and a communication portion 609 including a network interface card such as a LAN card, a modem, etc. The communication portion 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the input / output (I / O) interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage portion 608 as needed.
[0146] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0147] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 602 and / or RAM 603 described above and / or one or more memories other than ROM 602 and RAM 603.
[0148] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the database statement generation method provided by the embodiment of the present disclosure.
[0149] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 601. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0150] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 609, and / or installed from a removable medium 611. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0151] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the processor 601, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, apparatus, module, unit, etc. described above can be implemented by a computer program module.
[0152] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0153] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0154] It will be appreciated by those skilled in the art that the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations or combinations are not explicitly described in the present disclosure. In particular, without departing from the spirit and teachings of the present disclosure, the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0155] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A method for generating a database statement, characterized in that: The method comprises: In response to receiving a user input text, identifying the input text to obtain the user's data operation requirement information; Generate a plurality of first database statements matching the data operation requirement information according to the data operation requirement information and a database statement template set stored in a first template library; displaying the data operation requirement information and the plurality of first database statements; and When it is determined that the multiple first database statements do not meet the needs of the user due to the data operation requirement information, in response to the user's modification operation on the data operation requirement information, a target database statement is generated based on the modified data operation requirement information and the database statement template set stored in the first template library.
2. The method according to claim 1, characterized in that The first template library stores a database parameter set, and the generating of a plurality of first database statements matching the data operation requirement information according to the data operation requirement information and the database statement template set stored in the first template library includes: Determining a plurality of database statement templates matching the data operation requirement information from the database statement template set; Determining a target database parameter that matches the data operation requirement information from the database parameter set; and The target database parameters are filled into the multiple database statement templates to obtain multiple first database statements respectively corresponding to the multiple database statement templates.
3. The method according to claim 1, characterized in that The step of generating a target database statement in response to a user's modification operation on the data operation requirement information and according to the modified data operation requirement information and a database statement template set stored in the first template library includes: generating a plurality of second database statements matching the modified data operation requirement information according to the modified data operation requirement information and the database statement templates stored in the first template library; displaying the plurality of second database statements; and In response to the user's selection operation, a second database statement selected by the user is determined to be the target database statement.
4. The method according to claim 1 or 3, characterized in that: The method further comprises: In response to a modification operation of a user on a database statement, determining the modified database statement as the target database statement, wherein the database statement is the first database statement or the second database statement.
5. The method according to claim 4, characterized in that The first template library stores a database parameter set, and the method further includes: In the case where it is determined that the modification operation on the database statement is used to modify database parameters, obtaining the modified database parameters; Matching the modified database parameters with the database parameters in the database parameter set to obtain a matching result; In a case where it is determined that the matching result indicates that the database parameter set does not include the modified database parameter, classifying the modified database parameter using a preset classification model to obtain a parameter category that matches the modified database parameter; and The modified database parameters and the parameter category matching the modified database are stored in the database parameter set.
6. The method according to claim 5, characterized in that The step of determining the target database parameter that matches the data operation requirement information from the database parameter set includes: Determining a target parameter category matching the data operation requirement information from a plurality of parameter categories; and According to the data operation requirement information, a target database parameter is determined from a plurality of database parameters corresponding to the target parameter category.
7. The method according to claim 1, characterized in that The method further comprises: In response to the user selecting a sentence escape operation, determining a target sentence type selected by the user; Determining a second template library corresponding to the target sentence type; and An escaped target database statement is generated according to the target database statement and the database statement template set stored in the second template library.
8. A database statement generating device, characterized in that: The device comprises: The recognition module is used to recognize the input text in response to receiving the input text of the user, and obtain the data operation requirement information of the user; A first generating module, configured to generate a plurality of first database statements matching the data operation requirement information according to the data operation requirement information and a database statement template set stored in a first template library; a display module, configured to display the data operation requirement information and the plurality of first database statements; and The second generation module is used to generate a target database statement based on the modified data operation requirement information and the database statement template set stored in the first template library in response to the user's modification operation on the data operation requirement information when it is determined that the multiple first database statements do not meet the user's needs due to the data operation requirement information.
9. An electronic device, comprising: one or more processors; a memory for storing one or more computer programs, It is characterized in that the one or more processors execute the one or more computer programs 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 or instruction stored thereon, characterized in that: When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
11. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Data processing method, server, storage medium and program product
CN120144612A