SQL (Structured Query Language) statement generation method, device and equipment based on large model, and storage medium
By using big models to generate SQL statements in low-code platforms and translating them, the problem of inefficient writing SQL statements by business experts manually is solved, and efficient SQL statement generation and multi-source data processing is achieved.
Patent Information
- Application Number
- CN202411666206.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-03-04
AI Technical Summary
In the prior art, business experts need to manually write SQL statements, which leads to inefficiency and a lot of manpower and material resources.
Using a large-model-based SQL statement generation method, a SQL statement is generated by inputting natural language problems and prompt words into a large-model, and a mapping table is used to translate it into a SQL statement executable by a low-code platform.
It reduces the consumption of manpower and material resources, improves the generation efficiency of SQL statements, and is suitable for scenarios with multi-source heterogeneous data, with good universality.
Smart Images

Figure CN119556917A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing, and in particular to a method, device, equipment, and storage medium for generating SQL statements based on a large model. Background Art
[0002] As the digitalization process of enterprises accelerates, various departments and business systems within the enterprise have accumulated a large amount of data, which may be stored in different database management systems. Therefore, enterprises not only need to process internal data, but also may need to integrate external data. These external data come from various sources and formats, which increases the complexity of data processing. Low-code platforms can easily connect and integrate with various data sources of enterprises, quickly build data analysis and reporting applications, provide accurate and timely data support for enterprise management, and help enterprises make more informed decisions.
[0003] In the example technology, the SQL statements for execution by the low-code platform are manually written in advance by business experts. The writing process requires business experts to accurately understand the business logic, which consumes a lot of manpower and material resources and has low statement generation efficiency. Summary of the invention
[0004] The embodiments of the present application provide a SQL generation method, device and storage medium based on a large model, so as to reduce the consumption of manpower and material resources and improve the efficiency of SQL statement generation.
[0005] In the first aspect, an embodiment of the present application provides a method for generating SQL statements based on a big model, including: constructing a prompt word according to a first natural language question; the first natural language question is used to request to perform an operation on a first object, and the first object is obtained by the low-code platform from a source system; the first natural language question and the prompt word are input into the big model to obtain an SQL statement output by the big model; wherein the SQL statement output by the big model includes the object information of the first object in the source system; according to a mapping table, the SQL statement output by the big model is translated to obtain an SQL statement executable by the low-code platform; the mapping table includes the correspondence between the object information of each object in the source system and the object information of the object in the database of the low-code platform.
[0006] In one possible implementation, the second natural language question is input into a pre-established table data synchronization model to obtain key information of the second natural language question, and the second natural language question is used to request an operation to be performed on the second object; the table data synchronization model is used to parse the second natural language question, output the field corresponding to the second natural language question, and search the corresponding data table in the database of the source system according to the key information, and determine the relevant fields of the field corresponding to the second natural language question according to the data table; generate a data retrieval SQL statement according to the relevant fields, and execute the data retrieval SQL statement by calling the data retrieval interface of the low-code platform to obtain the second object from the source system and record the object information of the second object under the low-code platform; establish a correspondence between the object information of the second object under the source system and the object information of the second object under the low-code platform, and add the correspondence to the mapping table.
[0007] In one possible implementation, the SQL statement output by the large model is parsed to obtain object information of the first object in the source system; according to the object information of the first object in the source system, based on a mapping table, the object information of the first object in the low-code platform is determined; the object information of the first object in the source system in the SQL statement output by the large model is replaced with the object information of the first object in the low-code platform to obtain an SQL statement executable by the low-code platform.
[0008] In one possible implementation, the SQL statements executable by the low-code platform are submitted to the database under the low-code platform for execution, and the execution results are recorded in the execution log.
[0009] In one possible implementation, the command line and execution command of the database of the low-code platform are packaged and integrated to obtain an interface under the low-code platform, and the interface is used to call each database under the low-code platform; the SQL statement executable by the low-code platform is submitted to the database under the low-code platform for execution, specifically including: submitting the SQL statement executable by the low-code platform to the interface to call the database under the low-code platform to execute the SQL statement.
[0010] In one possible implementation, the execution result in the execution log is obtained, and the execution result includes execution success and execution failure. If the execution result is execution failure, the step of constructing prompt words according to the first natural language question is re-executed. If the execution result is execution success, the SQL statement, prompt words and first natural language question executable by the low-code platform are fed back to the big model and stored in the first database.
[0011] In one possible implementation, based on the first natural language question and the prompt word, a corresponding SQL statement executable by the low-code platform is searched in the first database; the first natural language question and the prompt word are input into the big model, specifically including: if the corresponding SQL statement is not found, the first natural language question and the prompt word are input into the big model.
[0012] In one possible implementation, if the corresponding SQL statement is found, the SQL statement executable by the low-code platform is submitted to the database under the low-code platform for execution.
[0013] In the second aspect, an embodiment of the present application provides a low-code platform, including: a construction module, used to construct a prompt word according to a first natural language question; the first natural language question is used to request to perform an operation on a first object, and the first object is obtained by the low-code platform from a source system; a generation module, used to input the first natural language question and the prompt word into a large model to obtain an SQL statement output by the large model; wherein the SQL statement output by the large model includes the object information of the first object in the source system; a translation module, used to translate the SQL statement output by the large model according to a mapping table to obtain an SQL statement executable by the low-code platform; the mapping table includes the correspondence between the object information of each object in the source system and the database of the object in the low-code platform.
[0014] In one possible implementation, the generation module inputs the first natural language question and prompt word into the big model, and before obtaining the SQL statement output by the big model, it is also used to: input the second natural language question into a pre-established table data synchronization model to obtain key information of the second natural language question, where the second natural language question is used to request an operation to be performed on the second object; the table data synchronization model is used to parse the second natural language question, output the field corresponding to the second natural language question, search the corresponding data table in the database of the source system based on the key information, and determine the relevant fields of the field corresponding to the second natural language question based on the data table; generate a data retrieval SQL statement based on the relevant fields, and execute the data retrieval SQL statement by calling the data retrieval interface of the low-code platform to obtain the second object from the source system and record the object information of the second object under the low-code platform; establish a correspondence between the object information of the second object under the source system and the object information of the second object under the low-code platform, and add the correspondence to the mapping table.
[0015] In a possible implementation, the translation module will translate the corresponding SQL statements according to the mapping table to obtain SQL statements executable by the low-code platform, and is specifically used for: parsing the SQL statements output by the large model to obtain the object information of the first object in the source system; determining the object information of the first object in the low-code platform based on the mapping table according to the object information of the first object in the source system; replacing the object information of the first object in the source system in the SQL statement output by the large model with the object information of the first object in the low-code platform to obtain SQL statements executable by the low-code platform.
[0016] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor;
[0017] Memory stores computer-executable instructions;
[0018] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the above first aspect and / or various possible implementations of the first aspect.
[0019] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the first aspect above and / or various possible implementations of the first aspect.
[0020] The embodiment of the present application provides a method, device, equipment, and storage medium for generating SQL statements based on a big model. First, a prompt word is constructed according to a first natural language question; wherein the first natural language question is used to request to perform an operation on a first object, and the first object is obtained by the low-code platform from a source system; the first natural language question and the prompt word are input into the big model to obtain an SQL statement output by the big model; wherein the SQL statement output by the big model includes the object information of the first object in the source system; according to the mapping table, the SQL statement output by the big model is translated to obtain an SQL statement executable by the low-code platform; the mapping table includes the corresponding relationship between the object information of each object in the source system and the database of the object in the low-code platform. In this solution, by combining the low-code platform with the big model, you only need to input the question in the low-code platform, and the big model can automatically generate accurate SQL statements, reducing the consumption of manpower and material resources, and improving the efficiency of generating SQL statements. At the same time, the present invention can be applied to scenarios with multi-source heterogeneous data and has good universality. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0022] Figure 1A schematic diagram of the process of a SQL statement generation method based on a large model provided in this application;
[0023] Figure 2 A schematic diagram of the structure of a low-code platform provided for this application;
[0024] Figure 3 A schematic diagram of the structure of the electronic device provided in this application.
[0025] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0026] Here, exemplary embodiments will be described in detail, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application.
[0027] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0028] The terms "first", "second", etc. in the specification and claims of this application and the above drawings are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise indicated. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, for example, they can be implemented in an order other than those given in the diagrams or descriptions of the embodiments of this application.
[0029] In addition, the terms "including" and "having" and any variations thereof are intended to cover but not exclude inclusion, for example, a product or device comprising a series of components is not necessarily limited to those components explicitly listed, but may include other components not explicitly listed or inherent to these products or devices. The term "module" as used in this application refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic or combination of hardware and / or software code that can perform the functions associated with the element.
[0030] First, the terms involved in this application are explained:
[0031] Low-code: Low-code is a software development method that aims to create software applications through a graphical interface and a small amount of coding. Its core feature is that it greatly simplifies the application development process, through a visual interface and intuitive operations such as drag and drop, so that non-professional developers can also quickly build and deploy applications.
[0032] Domain indicator library: a collection of indicators used to store and manage various indicators in a specific domain.
[0033] Interface: It is an important means to achieve data connection, system integration, function expansion and user interface construction.
[0034] Command line: A way to interact with a computer operating system or software by entering text commands.
[0035] Execution log: A document that records various events and operations that occur during the operation of a system or program.
[0036] Field: In the low-code platform, fields are an important part of data storage, user interface, and business logic. They define the structure and properties of data and play a key role in data input, storage, display, and processing.
[0037] Haitong Securities' main businesses include wealth management, asset management, trading and institutions, financial leasing, etc. A large amount of data will be generated in these businesses. Finding specific data from the massive data is not only complicated but also time-consuming. Therefore, this solution proposes a SQL statement generation method based on a large model. First, synchronize the external system data to the database of the low-code platform in the low-code platform to build a mapping table. Then enter the natural language question in the low-code platform to build the prompt word. Enter the natural language question and prompt word into the large model to generate SQL statements, translate the SQL statements, and finally execute the SQL statements to get the results. With this method, there is no need to search in a lot of data, and SQL statements can be directly generated in the low-code platform for searching.
[0038] In the related technology, in the low-code platform, generating SQL statements based on large models to query data requires business experts to understand the business logic to write SQL statements. Many indicators require business experts to write SQL to extract, and existing indicators cannot be used; this makes the generated SQL statements extremely complex, so that the report cannot obtain accurate data.
[0039] The technical solution provided by the present application is intended to solve the above problems of the prior art. In the embodiment of the present application, a prompt word is first constructed according to the first natural language question; wherein the first natural language question is used to request to perform an operation on the first object, and the first object is obtained by the low-code platform from the source system; the first natural language question and the prompt word are input into the big model to obtain the SQL statement output by the big model; wherein the SQL statement output by the big model includes the object information of the first object under the source system; according to the mapping table, the SQL statement output by the big model is translated to obtain the SQL statement executable by the low-code platform; the mapping table includes the object information of each object under the source system and the correspondence between the object in the database of the low-code platform. In this way, there is no need for business experts to understand the business logic. They only need to input the question in the low-code platform, and the big model can automatically generate accurate SQL statements, which reduces the consumption of manpower and material resources and improves the efficiency of generating SQL statements. At the same time, the present invention can be applied to scenarios with multi-source heterogeneous data and has good universality.
[0040] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0041] Embodiment 1
[0042] Figure 1 The process diagram of a SQL statement generation method based on a large model provided in this application is as follows: Figure 1 As shown, the method includes:
[0043] S101. Construct a prompt word based on a first natural language question; the first natural language question is used to request to perform an operation on a first object, and the first object is obtained by the low-code platform from a source system.
[0044] S102. Input the first natural language question and the prompt word into the big model to obtain an SQL statement output by the big model; wherein the SQL statement output by the big model includes object information of the first object in the source system.
[0045] S103. According to the mapping table, the SQL statements output by the large model are translated to obtain SQL statements executable by the low-code platform; the mapping table includes the correspondence between the object information of each object in the source system and the object information of the object in the database of the low-code platform.
[0046] The source system refers to the original source system of the data. Object information refers to the format information of the SQL statement output by the large model in the source system, including but not limited to syntax, function information, and location information. Specifically, prompts include: database type, relationship between tables (table name and field name), description of the scenario: what fields need to be used, filtering conditions, grouping conditions, aggregate fields, etc. Prompts can help select the correct tables, fields, and conditions when generating SQL statements, thereby improving the accuracy of generated SQL statements.
[0047] In combination with actual scenarios, when SQL statements need to be generated, first construct prompt words based on natural language questions; then input the natural language questions and prompt words into the big model, and the big model outputs SQL statements; finally, according to the mapping table, translate the SQL statements to obtain executable SQL statements under the low-code platform.
[0048] As an example, the big model for generating SQL statements includes SQL generation components and SQL translation components. For example, the SQL generation component of the big model generates SQL statements based on natural language questions and prompt words, and then the SQL rewriting component parses the generated SQL statements and translates them according to the mapping table to generate executable SQL statements under the low-code platform.
[0049] In some examples, before inputting the first natural language question and the prompt word into the big model and obtaining the SQL statement output by the big model, the method further includes:
[0050] The second natural language question is input into a pre-established table data synchronization model to obtain key information of the second natural language question, where the second natural language question is used to request to perform an operation on the second object; the table data synchronization model is used to parse the second natural language question, output a field corresponding to the second natural language question, search for a corresponding data table in a database of the source system according to the key information, and determine a related field of the field corresponding to the second natural language question according to the data table;
[0051] Generate a data retrieval SQL statement according to relevant fields, execute the data retrieval SQL statement by calling the data retrieval interface of the low-code platform, obtain the second object from the source system, and record the object information of the second object under the low-code platform;
[0052] Establish a correspondence between the object information of the second object in the source system and the object information of the second object in the low-code platform, and add the correspondence to the mapping table.
[0053] In actual applications, table data synchronization in the low-code platform can centralize data from multiple data sources into one database, so that the generated SQL statements can easily access data from multiple data sources. Specifically, the table data synchronization model parses the input natural language questions, obtains the corresponding fields and key information, searches for relevant fields in the database of the source system based on the key information and corresponding fields, generates data retrieval statements based on the relevant fields, calls the data retrieval port of the low-code platform to execute the statement to read the data, and stores it in the database of the low-code platform; then, a mapping table is constructed based on the correspondence between the object information of the data in the source system and the low-code platform. Among them, the format of the mapping table includes but is not limited to: <source database name, source database ID, source database table name, source database field, low-code database name, low-code database field name>; the database name refers to the database name; the source database ID refers to a specific code or number used to identify the source database.
[0054] As an example, the pre-established table data synchronization model is established by the low-code platform calling the interface of the newly created model and calling the scheduled task trigger interface. Specifically, the parameters passed in by the interface include but are not limited to data source, library name, table name, and field; the table data synchronization model has four states: success, failure, execution, and termination. It has a certain retry mechanism to ensure that the table data synchronization task can be automatically retried under abnormal circumstances, reducing failures caused by system jitter. Among them, the triggering of scheduled tasks can automatically execute the table data synchronization task and update the data in real time; the frequencies supported by scheduled triggers are daily, monthly, and yearly, and the frequency can also be customized according to needs.
[0055] For example, a user enters a natural language question "Find the order numbers and customer names of all orders with an amount greater than 1,000 yuan"; the table data synchronization model is used to parse and extract key information: the "order" entity, the "order number" and "customer name" attributes, and the "amount greater than 1,000 yuan" condition. In the source system database, the data table can be confirmed to be the "order table" based on the "order" entity. Based on the order table, it can be determined that the "order number" attribute can match the "order number" field in the "order table". The "customer name" attribute can find the corresponding "customer name" field in the "customer table" through the association between the "order table" and the "customer table". The "amount greater than 1,000 yuan" condition can use the "amount" field in the "order table". Generate a data retrieval statement based on the corresponding fields, read the data corresponding to the natural language question by calling the data retrieval interface, and store it in the database of the low-code platform. Then, a mapping table is constructed based on the corresponding relationship between the fields in the source system and the low-code platform.
[0056] In some examples, in S103, according to the mapping table, the SQL statements output by the large model are translated to obtain SQL statements executable by the low-code platform, which may specifically include:
[0057] Parse the SQL statement output by the large model to obtain the object information of the first object in the source system;
[0058] According to the object information of the first object in the source system, based on the mapping table, determine the object information of the first object in the low-code platform;
[0059] Replace the object information of the first object in the source system in the SQL statement output by the large model with the object information of the first object in the low-code platform to obtain an SQL statement executable by the low-code platform.
[0060] Specifically, the SQL statements output by the large model are parsed, including syntax parsing, lexical parsing, and parsing of table names and field names. The purpose of translating the SQL statements output by the large model is to generate statements that can be run in the low-code built-in database to avoid syntax errors or failure to execute in the database.
[0061] In some examples, SQL statements executable by the low-code platform are submitted to the database under the low-code platform for execution, and the execution results are recorded in the execution log. The execution log can record information such as execution time and resource consumption. In addition, after performance optimization, the result records in the execution log can be compared to evaluate the effect of performance optimization.
[0062] Specifically, this performance optimization is to tune SQL statements, including syntax correction, logic adjustment, index suggestions, etc., and perform tuning according to specific situations to improve performance. For example, when the execution time is long, you can remove unnecessary complex logic and condition combinations, and only retain key conditions that have a practical impact on the results. Avoid using complex functions, such as changing "WHERE column1 = UPPER ('value')" to "WHERE column1 = 'VALUE', and avoid using the UPPER function in the conditions.
[0063] In some examples, the command line and execution command of the database of the low-code platform are packaged and integrated to obtain the interface under the low-code platform, which is used to call various databases under the low-code platform; the SQL statement executable by the low-code platform is submitted to the database under the low-code platform for execution, specifically including: submitting the SQL statement executable by the low-code platform to the interface to call the database under the low-code platform to execute the SQL statement. By packaging and integrating it, a unified interface can be used to perform database operations without having to deal with complex command lines and different execution methods.
[0064] In some examples, a read execution result in an execution log is obtained, where the execution result includes execution success and execution failure;
[0065] If the execution result is execution failure, re-execute the step of constructing prompt words according to the first natural language question;
[0066] If the execution result is successful, the SQL statement, prompt word and first natural language question executable by the low-code platform are fed back to the big model and stored in the first database.
[0067] Among them, the successfully executed SQL statements, natural language questions, and prompt words are fed back to the big model and stored in the first database. The purpose is that when the big model encounters the same problem again, it can directly use the SQL statement in the database. In addition, a domain indicator library is constructed to summarize and classify the SQL statements corresponding to the indicators and store them in the database; the input natural language questions can also be searched from it. If the corresponding SQL statement can be found, it can be used directly without using the model to generate it. The construction of the domain indicator library can be selected according to specific needs. For example, the financial industry can construct a financial domain indicator library, which includes: the definition of terms in the financial field, the calculation rules of the indicators, and the SQL statements of the indicators.
[0068] In actual applications, the types of execution results are not limited, such as successful execution with data, successful execution but no data, and failed execution; the SQL statement generated by the large model can also display the score to let the large model know the situation of the generated SQL statement. For example, when the execution result obtained is a failed execution, the score is 0, and the SQL statement is re-executed; when the execution result obtained is a successful execution with data, the score is excellent, and the natural language question, score, and SQL statement are fed back to the large model and stored in the first database; when the execution result obtained is a successful execution but no data, the score is qualified, and the natural language question, score, and SQL statement are fed back to the large model and stored in the first database. In addition, in addition to the scoring of the large model, manual scoring can also be performed; specifically, the result of successful execution is also sent to the list to be confirmed, and the user can modify the score according to the result of the successful execution and feed the score back to the large model.
[0069] In some examples, before inputting the first natural language question and the prompt word into the large model, the method further includes:
[0070] According to the first natural language question and the prompt word, searching the first database for a corresponding SQL statement executable by the low-code platform;
[0071] Input the first natural language question and prompt words into the big model, including:
[0072] If the corresponding SQL statement is not found, the first natural language question and the prompt word are input into the large model.
[0073] In some examples, after searching the first database for a corresponding SQL statement executable by the low-code platform according to the first natural language question and the prompt word, the method further includes:
[0074] If the corresponding SQL statement is found, the SQL statement executable by the low-code platform will be submitted to the database under the low-code platform for execution.
[0075] First, the SQL statement that corresponds to the natural language question and is executable on the low-code platform is searched in the first database. If it is found, it can be used directly to avoid repeated code writing and save time. In addition, the data structure and field meaning of the data in the first database will be exported and synchronized for maintenance on a regular basis to ensure the consistency and timeliness of the data structure and field meaning. When adjusting the SQL statement, performance optimization can be performed based on the data structure and field meaning.
[0076] The embodiment of the present application provides a method for generating SQL statements based on a large model. First, a prompt word is constructed according to a first natural language question; wherein the first natural language question is used to request to perform an operation on a first object, and the first object is obtained by the low-code platform from a source system; the first natural language question and the prompt word are input into the large model to obtain an SQL statement output by the large model; wherein the SQL statement output by the large model includes the object information of the first object in the source system; according to the mapping table, the SQL statement output by the large model is translated to obtain an SQL statement executable by the low-code platform; the mapping table includes the corresponding relationship between the object information of each object in the source system and the database of the object in the low-code platform. In this way, there is no need for business experts to understand the business logic. Only the question needs to be input into the low-code platform, and the large model can automatically generate accurate SQL statements, which reduces the consumption of manpower and material resources and improves the efficiency of generating SQL statements. At the same time, the present invention can be applied to scenarios with multi-source heterogeneous data and has good universality.
[0077] Figure 2 A schematic diagram of the structure of a low-code platform provided for this application, such as Figure 2 As shown, the device comprises:
[0078] S201. A construction module, used to construct a prompt word according to a first natural language question; the first natural language question is used to request to perform an operation on a first object, and the first object is obtained by the low-code platform from a source system.
[0079] S202, a generation module, used to input the first natural language question and the prompt word into the big model, and obtain the SQL statement output by the big model; wherein the SQL statement output by the big model includes the object information of the first object in the source system.
[0080] S203. A translation module is used to translate the SQL statements output by the large model according to a mapping table to obtain SQL statements executable by the low-code platform; the mapping table includes the correspondence between the object information of each object in the source system and the object information of the object in the database of the low-code platform.
[0081] In some examples, the generation module inputs the first natural language question and the prompt word into the big model, and before obtaining the SQL statement output by the big model, is also used to:
[0082] The second natural language question is input into a pre-established table data synchronization model to obtain key information of the second natural language question, where the second natural language question is used to request to perform an operation on the second object; the table data synchronization model is used to parse the second natural language question, output a field corresponding to the second natural language question, search for a corresponding data table in a database of the source system according to the key information, and determine a related field of the field corresponding to the second natural language question according to the data table;
[0083] Generate a data retrieval SQL statement according to relevant fields, execute the data retrieval SQL statement by calling the data retrieval interface of the low-code platform, obtain the second object from the source system, and record the object information of the second object under the low-code platform;
[0084] Establish a correspondence between the object information of the second object in the source system and the object information of the second object in the low-code platform, and add the correspondence to the mapping table.
[0085] As an example, the pre-established table data synchronization model is established by the low-code platform calling the interface of the newly created model and calling the scheduled task trigger interface. Specifically, the parameters passed in by the interface include but are not limited to data source, library name, table name, and field; the table data synchronization model has four states: success, failure, execution, and termination. It has a certain retry mechanism to ensure that the table data synchronization task can be automatically retried under abnormal circumstances, reducing failures caused by system jitter. Among them, the triggering of scheduled tasks can automatically execute the table data synchronization task and update the data in real time; the frequencies supported by scheduled triggers are daily, monthly, and yearly, and the frequency can also be customized according to needs.
[0086] In some examples, in S203, according to the mapping table, the translation module translates the SQL statements output by the large model to obtain SQL statements executable by the low-code platform, specifically for:
[0087] Parse the SQL statement output by the large model to obtain the object information of the first object in the source system;
[0088] According to the object information of the first object in the source system, based on the mapping table, determine the object information of the first object in the low-code platform;
[0089] Replace the object information of the first object in the source system in the SQL statement output by the large model with the object information of the first object in the low-code platform to obtain an SQL statement executable by the low-code platform.
[0090] Specifically, the SQL statements output by the large model are parsed, including syntax parsing, lexical parsing, and parsing of table names and field names. The purpose of translating the SQL statements output by the large model is to generate statements that can be run in the low-code built-in database to avoid syntax errors or failure to execute in the database.
[0091] A low-code platform provided by an embodiment of the present application first constructs a prompt word according to a first natural language question; wherein the first natural language question is used to request to perform an operation on a first object, and the first object is obtained by the low-code platform from a source system; the first natural language question and the prompt word are input into a large model to obtain an SQL statement output by the large model; wherein the SQL statement output by the large model includes the object information of the first object in the source system; according to a mapping table, the SQL statement output by the large model is translated to obtain an SQL statement executable by the low-code platform; the mapping table includes the corresponding relationship between the object information of each object in the source system and the database of the object in the low-code platform. In this way, there is no need for business experts to understand the business logic, and only the question needs to be input into the low-code platform, and the large model can automatically generate accurate SQL statements, which reduces the consumption of manpower and material resources and improves the efficiency of generating SQL statements. At the same time, the present invention can be applied to scenarios with multi-source heterogeneous data and has good universality.
[0092] It should be noted that a low-code platform provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effects are similar, so this embodiment will not be repeated here.
[0093] Figure 3 This is a schematic diagram of the structure of the electronic device provided in this application. Figure 3 As shown, the electronic device 30 provided in this embodiment includes: at least one processor 301 and a memory 302. Optionally, the device 30 also includes a communication component 303. The processor 301, the memory 302 and the communication component 303 are connected via a bus 304.
[0094] In a specific implementation process, at least one processor 301 executes the computer-executable instructions stored in the memory 302, so that at least one processor 301 executes the above method.
[0095] The specific implementation process of the processor 301 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0096] In the above embodiments, it should be understood that the processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the invention can be directly implemented as a hardware processor, or can be implemented by a combination of hardware and software modules in the processor.
[0097] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (NVM), such as at least one disk storage.
[0098] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of this application is not limited to only one bus or one type of bus.
[0099] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above method is implemented.
[0100] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0101] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0102] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0103] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention, which follow the general principles of the present invention and include common knowledge or customary technical means in the art not disclosed by the present invention, are not limited to the precise structure described above and shown in the drawings, and may be modified and changed in various ways without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A method for generating SQL statements based on a large model, characterized in that: Applied to a low-code platform, the method includes: Constructing a prompt word according to a first natural language question; the first natural language question is used to request to perform an operation on a first object, and the first object is obtained by the low-code platform from a source system; Inputting the first natural language question and the prompt word into the big model to obtain an SQL statement output by the big model; wherein the SQL statement output by the big model includes object information of the first object in the source system; According to the mapping table, the SQL statements output by the large model are translated to obtain SQL statements executable by the low-code platform; the mapping table includes the correspondence between the object information of each object in the source system and the object information of the object in the database of the low-code platform.
2. The method according to claim 1, characterized in that Before inputting the first natural language question and the prompt word into the big model and obtaining the SQL statement output by the big model, the method further includes: Inputting the second natural language question into a pre-established table data synchronization model to obtain key information of the second natural language question, where the second natural language question is used to request to perform an operation on the second object; the table data synchronization model is used to parse the second natural language question, output a field corresponding to the second natural language question, search a corresponding data table in a database of a source system according to the key information, and determine a related field of the field corresponding to the second natural language question according to the data table; Generate a data retrieval SQL statement according to the relevant fields, execute the data retrieval SQL statement by calling the data retrieval interface of the low-code platform, obtain the second object from the source system, and record the object information of the second object under the low-code platform; Establish a correspondence between the object information of the second object in the source system and the object information of the second object in the low-code platform, and add the correspondence to the mapping table.
3. The method according to claim 1, characterized in that According to the mapping table, the corresponding SQL statement is translated to obtain an SQL statement executable by the low-code platform, including: Parsing the SQL statement output by the large model to obtain object information of the first object in the source system; According to the object information of the first object in the source system, based on the mapping table, determine the object information of the first object in the low-code platform; The object information of the first object in the source system in the SQL statement output by the large model is replaced with the object information of the first object in the low-code platform to obtain an SQL statement executable by the low-code platform.
4. The method according to any one of claims 1 to 3, characterized in that: The method comprises: Submit the SQL statements executable by the low-code platform to the database under the low-code platform for execution, and record the execution results in the execution log.
5. The method according to claim 4, characterized in that The method comprises: The command line and execution command of the database of the low-code platform are packaged and integrated to obtain an interface under the low-code platform, and the interface is used to call each database under the low-code platform; Submitting the SQL statement executable by the low-code platform to the database under the low-code platform for execution specifically includes: Submit the SQL statement executable by the low-code platform to the interface to call the database under the low-code platform to execute the SQL statement.
6. The method according to claim 4, characterized in that The method further comprises: Obtaining the execution result in the execution log, wherein the execution result includes execution success and execution failure; If the execution result is execution failure, re-execute the step of constructing prompt words according to the first natural language question; If the execution result is successful, the SQL statement executable by the low-code platform, the prompt word and the first natural language question are fed back to the big model and stored in the first database.
7. The method according to claim 6, characterized in that Before inputting the first natural language question and the prompt word into the large model, the method further includes: According to the first natural language question and the prompt word, searching the first database for a corresponding SQL statement executable by the low-code platform; The step of inputting the first natural language question and the prompt word into the large model specifically includes: If no corresponding SQL statement is found, the first natural language question and the prompt word are input into the large model.
8. The method according to claim 7, after searching the first database for a corresponding SQL statement executable by the low-code platform according to the first natural language question and the prompt word, further comprises: If the corresponding SQL statement is found, the SQL statement executable by the low-code platform will be submitted to the database under the low-code platform for execution.
9. A low-code platform, characterized in that: include: A construction module, used for constructing a prompt word according to the first natural language question; The first natural language question is used to request to perform an operation on a first object, where the first object is obtained by the low-code platform from a source system; A generation module, used for inputting the first natural language question and the prompt word into a large model to obtain an SQL statement output by the large model; wherein the SQL statement output by the large model includes object information of the first object in the source system; A translation module is used to translate the SQL statements output by the large model according to a mapping table to obtain SQL statements executable by the low-code platform; the mapping table includes the correspondence between the object information of each object in the source system and the object information of the object in the database of the low-code platform.
10. The low-code platform according to claim 9, characterized in that: The generation module inputs the first natural language question and the prompt word into the large model, and before obtaining the SQL statement output by the large model, is further used to: Inputting the second natural language question into a pre-established table data synchronization model to obtain key information of the second natural language question, where the second natural language question is used to request to perform an operation on the second object; the table data synchronization model is used to parse the second natural language question, output a field corresponding to the second natural language question, search a corresponding data table in a database of a source system according to the key information, and determine a related field of the field corresponding to the second natural language question according to the data table; Generate a data retrieval SQL statement according to the relevant fields, execute the data retrieval SQL statement by calling the data retrieval interface of the low-code platform, obtain the second object from the source system, and record the object information of the second object under the low-code platform; Establish a correspondence between the object information of the second object in the source system and the object information of the second object in the low-code platform, and add the correspondence to the mapping table.
11. The low-code platform according to claim 9, characterized in that: The translation module translates the corresponding SQL statement according to the mapping table to obtain an SQL statement executable by the low-code platform, specifically for: Parsing the SQL statement output by the large model to obtain object information of the first object in the source system; According to the object information of the first object in the source system, based on the mapping table, determine the object information of the first object in the low-code platform; The object information of the first object in the source system in the SQL statement output by the large model is replaced with the object information of the first object in the low-code platform to obtain an SQL statement executable by the low-code platform.
12. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 8.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 8 when executed by a processor.
Citation Information
Cited By
Intelligent Shell command generation method and system in Linux environment
CN122132080A