Database data analysis method and device, equipment and medium
Task disassembly and SQL statement generation are carried out through a large language model, and database data analysis is automatically completed, solving the problems of low efficiency and poor accuracy caused by manual writing of SQL statements in the existing technology, and achieving efficient and accurate data analysis.
Patent Information
- Application Number
- CN202510199731.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-24
- Publication Date
- 2025-06-17
AI Technical Summary
In the prior art, database data analysis requires users to manually write SQL statements, resulting in low efficiency, poor accuracy and prone to human errors.
By receiving user input to query problems, using a large language model for task disassembly and SQL statement generation, the target data analysis results in the database are automatically determined.
Improves the efficiency of SQL statement generation, reduces the occurrence of human errors, and ensures the accuracy and efficiency of data analysis.
Smart Images

Figure CN120162350A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data analysis technology, and in particular to a method, device, equipment and medium for database data analysis. Background Art
[0002] Currently, when analyzing database data, usually users manually write corresponding SQL statements according to the problems to be queried, and then export the data after analyzing the problems corresponding to the queries in the database according to the written SQL statements. However, these processes not only require users to have a certain basic knowledge of SQL programming, but also are time-consuming and laborious, and are prone to human errors, thus affecting the efficiency and accuracy of data analysis. Therefore, there is an urgent need for an efficient and accurate method for database data analysis. Summary of the Invention
[0003] This application provides a method, device, equipment and medium for database data analysis to solve the problem of low efficiency and accuracy in obtaining data analysis results by manually writing SQL statements.
[0004] In a first aspect, this application provides a method for database data analysis, and the method includes:
[0005] Receiving a problem to be queried input by a user of a front-end device;
[0006] Inputting the problem to be queried and a preset task decomposition prompt word into a large language model, and decomposing the problem to be queried based on the large language model to obtain a plurality of sub-problems to be queried;
[0007] Inputting the plurality of sub-problems to be queried and a preset SQL statement generation prompt word into the large language model, and generating a first SQL statement corresponding to each sub-problem to be queried based on the large language model;
[0008] Inputting each first SQL statement and the problem to be queried into the large language model, and generating a second SQL statement based on the large language model;
[0009] Determining a target data analysis result corresponding to the problem to be queried in the database according to the second SQL statement.
[0010] Further, determining a target data analysis result corresponding to the problem to be queried in the database according to the second SQL statement includes:
[0011] Inputting the problem to be queried and a preset data table selection prompt word into the large language model, and based on the large language model, determining a target database corresponding to the problem to be queried, a target data table corresponding to the problem to be queried in the target database, and target field information corresponding to the problem to be queried in the target data table;
[0012] Use the target database as the first query object, the target data table as the second query object, and the target field information as the third query object to perform queries in sequence to determine the target data corresponding to the problem to be queried.
[0013] Determine the target data analysis result in the database corresponding to the problem to be queried according to the second SQL statement and the target data.
[0014] Further, before determining the target data analysis result in the database corresponding to the problem to be queried, the method further includes:
[0015] If the first failure reason information is received; wherein, the failure reason information is used to indicate that the determination of the data analysis result fails; input the first failure reason information, the second SQL statement, and the preset SQL statement repair prompt words into the large language model, and repair the second SQL statement based on the large language model; until the target data analysis result in the database corresponding to the problem to be queried is determined according to the repaired second SQL statement and the target data.
[0016] Further, the method further includes:
[0017] Input the problem to be queried, the second SQL statement, and the preset data verification prompt words into the large language model, and generate data verification steps based on the large language model.
[0018] Input the data verification steps and the preset SQL statement generation prompt words into the large language model to generate the third SQL statement corresponding to the data verification steps.
[0019] Determine the verification data analysis result in the database corresponding to the data verification steps according to the third SQL statement.
[0020] If the target data analysis result is the same as the verification data analysis result, display the data analysis result on the front-end device.
[0021] Further, the method further includes:
[0022] If the target data analysis result is not the same as the verification data analysis result, input the received second failure reason information, the second SQL statement, and the preset SQL statement repair prompt words into the large language model, and repair the second SQL statement based on the large language model; until the verification data analysis result determined according to the repaired second SQL statement is the same as the target data analysis result determined according to the repaired second SQL statement.
[0023] Further, the front-end device displaying the data analysis result includes:
[0024] Input the problem to be queried and the target data analysis result into the large language model, and determine a target chart containing the target data analysis result based on the large language model; display the target chart on the front-end device.
[0025] Further, the method further includes:
[0026] Use the repaired second SQL statement as the target SQL statement corresponding to the problem to be queried.
[0027] According to a preset query period, determine the target data analysis result of the problem to be queried corresponding to the current time in the database according to the target SQL statement.
[0028] Further, if the target data analysis result is different from the verification data analysis result, the method further includes:
[0029] Output a prompt message indicating that the verification of the data analysis result fails.
[0030] In a second aspect, the present application provides a device for database data analysis, and the device includes:
[0031] A receiving module, configured to receive a problem to be queried input by a user of a front-end device;
[0032] A processing module, configured to input the problem to be queried and a preset task decomposition prompt word into the large language model, decompose the problem to be queried based on the large language model to obtain a plurality of sub-problems to be queried; input the plurality of sub-problems to be queried and a preset SQL statement generation prompt word into the large language model, and generate a first SQL statement corresponding to each sub-problem to be queried based on the large language model; input each first SQL statement and the problem to be queried into the large language model, and generate a second SQL statement based on the large language model; and determine the target data analysis result of the problem to be queried in the database according to the second SQL statement.
[0033] Further, the processing module is specifically configured to input the problem to be queried and a preset data table selection prompt word into the large language model, and based on the large language model, determine the target database corresponding to the problem to be queried, the target data table in the target database corresponding to the problem to be queried, and the target field information in the target data table corresponding to the problem to be queried; use the target database as the first query object, the target data table as the second query object, and the target field information as the third query object to perform queries in sequence to determine the target data corresponding to the problem to be queried; and determine the target data analysis result in the database corresponding to the problem to be queried according to the second SQL statement and the target data.
[0034] Further, the processing module is further configured to, if receiving first failure reason information; where the failure reason information is used to represent the failure to determine the data analysis result; input the first failure reason information, the second SQL statement, and a preset SQL statement repair prompt word into the large language model, and repair the second SQL statement based on the large language model; until the target data analysis result in the database corresponding to the problem to be queried is determined according to the repaired second SQL statement and the target data.
[0035] Further, the processing module is further configured to input the problem to be queried, the second SQL statement, and a preset data verification prompt word into the large language model, and generate data verification steps based on the large language model; input the data verification steps and a preset SQL statement generation prompt word into the large language model to generate a third SQL statement corresponding to the data verification steps; determine the verification data analysis result in the database corresponding to the data verification steps according to the third SQL statement; if the target data analysis result is the same as the verification data analysis result, display the data analysis result on the front-end device.
[0036] Further, the processing module is further configured to, if the target data analysis result is different from the verification data analysis result, input the received second failure reason information, the second SQL statement, and the preset SQL statement repair prompt word into the large language model, and repair the second SQL statement based on the large language model; until the verification data analysis result determined according to the repaired second SQL statement is the same as the target data analysis result determined according to the repaired second SQL statement.
[0037] Further, the processing module is specifically configured to input the problem to be queried and the target data analysis result into the large language model, and determine a target chart including the target data analysis result based on the large language model; display the target chart on the front-end device.
[0038] Further, the processing module is further configured to use the repaired second SQL statement as the target SQL statement corresponding to the problem to be queried; and according to a preset query period, determine the target data analysis result of the problem to be queried corresponding to the current time in the database according to the target SQL statement.
[0039] Further, the processing module is further configured to output a prompt message indicating that the verification of the data analysis result fails.
[0040] In a third aspect, the present application provides an electronic device, which includes a processor, and the processor is configured to implement the method for database data analysis as described in any one of the above when executing a computer program stored in a memory.
[0041] In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program, and the computer program implements the method for database data analysis as described in any one of the above when executed by a processor.
[0042] In a fifth aspect, the present application provides a computer program product, which includes: computer program code, and when the computer program code runs on a computer, the computer is caused to execute the method for database data analysis as described in any one of the above.
[0043] In the embodiments of the present application, the data analysis result can be determined by only inputting the problem to be queried. Compared with manually writing SQL statements by a person and querying database data according to the written SQL statements to obtain the data analysis result, the present application not only ensures the use by users who do not have the basic knowledge of SQL programming, but also improves the generation efficiency of SQL statements, and at the same time avoids the problem of the decrease in data analysis accuracy caused by human errors when writing SQL statements manually. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application, and those of ordinary skill in the art can also obtain other drawings based on these drawings without creative efforts.
[0045] Figure 1 FIG. is a schematic diagram of a process for database data analysis provided by an embodiment of the present application;
[0046] Figure 2 FIG. is a schematic diagram of a process for determining a data analysis result provided by an embodiment of the present application;
[0047] Figure 3A schematic diagram of the process of data verification provided by an embodiment of the present application;
[0048] Figure 4 A schematic diagram of the structure of a device for database data analysis provided by an embodiment of the present application;
[0049] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0050] To make the objectives and implementation manners of the present application clearer, the following will clearly and completely describe the exemplary implementation manners of the present application with reference to the accompanying drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only a part of the embodiments of the present application, rather than all of the embodiments.
[0051] It should be noted that the brief description of the terms in the present application is only for the convenience of understanding the subsequent described implementation manners, rather than intending to limit the implementation manners of the present application. Unless otherwise specified, these terms should be understood in their ordinary and general meanings.
[0052] The terms "first", "second", "third", etc. in the description and claims of the present application and the above accompanying drawings are used to distinguish similar or like objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise noted. It should be understood that such terms can be interchanged under appropriate circumstances.
[0053] The terms "include" and "have" and any variations thereof are intended to cover but not exclude inclusion. For example, a product or device including a series of components does not necessarily have to be limited to all the clearly listed components, but may include other components that are not clearly listed or are inherent to these products or devices.
[0054] The term "module" refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or a combination of hardware or / and software code that can perform functions related to the element.
[0055] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
[0056] For the sake of convenience of explanation, the above description has been made in conjunction with specific embodiments. However, the above exemplary discussion is not intended to be exhaustive or to limit the embodiments to the specific forms disclosed above. According to the above teachings, various modifications and variations can be obtained. The selection and description of the above embodiments are for better explaining the principles and practical applications, so that those skilled in the art can better use the embodiments and various different modified embodiments suitable for specific use considerations.
[0057] For the convenience of understanding this application, some professional terms in the art will be briefly explained below. For example, large model agents are an important development direction in the field of artificial intelligence. It combines advanced large language models (LLMs) and other artificial intelligence technologies to create intelligent systems capable of performing complex tasks. Large model agents usually consist of the following key components: Planning, Memory, Tools, and Action. The planning module is responsible for thinking and decision-making, the memory module is responsible for information storage and recall, the tool module allows the agent to call external tools and resources, and the action module is responsible for performing actual actions.
[0058] Problems existing in the current prior art: (1) Insufficient ability to select databases, data tables, and field information in the database: Traditional large models for converting natural language to SQL statements require a large amount of data training and have insufficient generalization ability. And when using traditional large models to generate SQL statements, the descriptions of database tables in the database, as well as the types and meanings of table fields, need to be used as prompt words (Prompts) for the large model to select the correct database tables and corresponding fields and generate the corresponding SQL statements. However, when there are too many database tables and corresponding fields, using all the information as a Prompt results in too long an input, and the large model is prone to losing important information. (2) Insufficient accuracy in automatically generating SQL statements: When the user's question involves multi-step complex queries, the accuracy rate of generating SQL statements in one go by inputting prompt words for learning is relatively low. (3) After generating a query statement for the database, data is queried, the data analysis result is determined, and it is output and displayed to the user. However, if the user does not understand SQL statements, they may have doubts about the result, and a data verification strategy is needed to verify the data and improve the credibility of the data.
[0059] Example 1:
[0060] Figure 1 A process schematic diagram for database data analysis provided by an embodiment of this application, and this process includes the following steps:
[0061] S101: Receive the query problem input by the user of the front-end device.
[0062] The database data analysis method provided by the embodiments of this application is applied to an electronic device, which can be a computer (Personal Computer, PC), a server, etc.
[0063] The front-end device can be an electronic device held by a user, such as the user's mobile phone, in which an application for database data analysis is installed, or it can be a fixed electronic device, such as a computer, a server, etc.
[0064] The problem to be queried refers to the problem that the user needs to query. For example, the problem to be queried A: view the year-on-year and month-on-month total gas consumption of Company W in each month of 2023; the problem to be queried B: what is the temperature in City Q today, etc.
[0065] S102: Input the problem to be queried and the preset task decomposition prompt words into the large language model, and decompose the problem to be queried based on the large language model to obtain multiple sub-problems to be queried.
[0066] The large language model can be a generative large model (Chatgpt). This model is trained with a large amount of data and has a strong zero-shot ability. By inputting the prompt words of different tasks for learning, it can realize functions such as task decomposition and SQL statement generation tasks.
[0067] The prompt words can be guiding texts or directive codes, which are used to let the large language model clarify the target direction of work. The task decomposition prompt words are the prompt words used to guide the large language model to decompose the input problem to be queried into multiple sub-problems to be queried.
[0068] The preset task decomposition prompt words can be the task decomposition prompt words generated by the Generative Pretrained Transformer (GPT) according to the input problem to be queried, or the task decomposition prompt words manually written by humans according to the problem to be queried.
[0069] Input the problem to be queried and the preset task decomposition prompt words into the large language model, and decompose the problem to be queried based on the large language model to obtain multiple sub-problems to be queried. For example, if the problem to be queried A is to view the year-on-year and month-on-month total gas consumption of Company W in each month of 2023, input the problem to be queried A and the preset task decomposition prompt words into the large language model, and decompose the problem to be queried A based on the large language model to obtain multiple sub-problems to be queried. For example: the sub-problem to be queried B1 is to calculate the total gas consumption of Company W in each month of 2023; the sub-problem to be queried B2 is to calculate the total gas consumption of Company W in each month of 2022; the sub-problem to be queried B3 is to calculate the year-on-year of each month of Company W in 2023; the sub-problem to be queried B4 is to calculate the month-on-month of each month of Company W in 2023.
[0070] In this application, by setting different types of prompt words, the large language model is made to play a specific role to complete corresponding tasks. A role can be understood as a Prompt for a specific task + a large language model. That is to say, different roles can be understood as different agents. For example, the task decomposition role is an agent that decomposes a task into target tasks; the SQL statement generation role is an agent that generates SQL statements; the SQL statement repair role is an agent that repairs existing SQL statements, etc.
[0071] S103: Input multiple sub-questions to be queried and a preset SQL statement generation prompt word into the large language model, and generate a first SQL statement corresponding to each sub-question to be queried based on the large language model.
[0072] Structured Query Language (SQL statement) is a database query and programming language used to access data and query, update, and manage database systems.
[0073] The SQL statement generation prompt word is a prompt word used to guide the large language model to generate a first SQL statement corresponding to each sub-question to be queried. The preset SQL statement generation prompt word can be a SQL statement generation prompt word generated by the Generative Pretrained Transformer GPT according to the input sub-question to be queried, or a SQL statement generation prompt word manually written by a person according to the sub-question to be queried.
[0074] The following is an example of a SQL statement generation prompt word Prompt:
[0075]
[0076]
[0077] S104: Input each first SQL statement and the sub-question to be queried into the large language model, and generate a second SQL statement based on the large language model.
[0078] Input the first SQL statement corresponding to each sub-question to be queried generated in step 103 and the sub-question to be queried into the large language model, and generate a second SQL statement based on the large language model. That is, the large language model determines a complete second SQL statement according to the first SQL statement corresponding to each sub-question to be queried and the sub-question to be queried input. The second SQL statement contains the sub-question to be queried and information about all sub-questions corresponding to the sub-question to be queried.
[0079] S105: Determine the target data analysis result corresponding to the sub-question to be queried in the database according to the second SQL statement.
[0080] The data analysis result refers to the answer to the user input question. The database stores the data for solving the problem to be queried. According to the second SQL statement, the target data analysis result corresponding to the problem to be queried in the database is determined.
[0081] In the embodiment of the present application, compared with manually writing SQL statements and querying database data according to the written SQL statements to obtain data analysis results, in the present application, the data analysis result can be determined by only inputting the problem to be queried, which not only ensures the use of users without basic knowledge of SQL programming, but also improves the generation efficiency of SQL statements, and at the same time avoids the problem of decreased data analysis accuracy caused by human errors when writing SQL statements manually.
[0082] In addition, by disassembling the problem to be queried, the limitation of the input length of the prompt words in the traditional large model is overcome, and the problem that when there are too many databases, data tables and corresponding fields, all information is used as prompt words, resulting in too long input prompt words and the large model losing important information is avoided, thereby improving the accuracy of generating SQL statements.
[0083] Embodiment 2:
[0084] The correct selection of the database corresponding to the problem to be queried, the data table corresponding to the problem to be queried in the database, and the field information corresponding to the problem to be queried in the data table largely determines the success of the data analysis task. Therefore, in order to accurately obtain the target data analysis result, the embodiment of the present application also explains the determination of the target data analysis result corresponding to the problem to be queried in the database according to the second SQL statement to ensure the accuracy of the target data analysis corresponding to the problem to be queried in the database according to the second SQL statement.
[0085] Figure 2 It is a schematic diagram of a process for determining a data analysis result provided by an embodiment of the present application. The process includes the following steps:
[0086] S201: Input the problem to be queried and the preset data table selection prompt words into the large language model. Based on the large language model, determine the target database corresponding to the problem to be queried, the target data table corresponding to the problem to be queried in the target database, and the target field information corresponding to the problem to be queried in the target data table.
[0087] The data table selection prompt word is a prompt word used to guide the large language model to determine the target data in the database for solving the problem to be queried for the problem to be queried.
[0088] The database includes multiple data sub - libraries. Each data sub - library has multiple data tables, and each data table has multiple field information. For example, database A stores data sub - library a, data sub - library b, and data sub - library c. Among them, data sub - library a stores data tables a1, a2, and a3. And data tables a1, a2, and a3 store multiple field information respectively.
[0089] In a possible implementation manner, according to the initial SQL statements used when constructing the database, obtain the data sub - library names of each data sub - library and the description information of each data sub - library, the data table names of each data table in each data sub - library and the description information of each data table, the field names of each field information in each data table and the field types and field description information of each field information. Input the obtained information such as the data sub - library names of each data sub - library and the description information of each data sub - library, the data table names of each data table in each data sub - library and the description information of each data table, the field names of each field information in each data table and the field types and field description information of each field information into the Generative Pretrained Transformer GPT to construct data table selection prompt words.
[0090] The following is an example of a data table selection prompt word Prompt:
[0091]
[0092] Input the question to be queried and the preset data table selection prompt words into the large - language model. Based on the large - language model, determine the target database corresponding to the question to be queried, the target data table in the target database corresponding to the question to be queried, and the target field information in the target data table corresponding to the question to be queried.
[0093] S202: Use the target database as the first query object, the target data table as the second query object, and the target field information as the third query object, and perform queries in sequence to determine the target data corresponding to the question to be queried.
[0094] When determining the target data corresponding to the question to be queried, use the target database as the first query object, the target data table as the second query object, and the target field information as the third query object, and perform queries in sequence. That is to say, use the target database as the top layer, the target data table as the second layer, and the target field information as the third layer. First, determine the target database corresponding to the question to be queried, that is, first determine the data sub - library in the database corresponding to the question to be queried. Then, based on the target database, determine the target data table in the target database corresponding to the question to be queried, that is, the data table in the data sub - library corresponding to the question to be queried. Finally, based on the target data table, determine the target field information in the target data table corresponding to the question to be queried, that is, the field information in the data table corresponding to the question to be queried.
[0095] In a possible implementation, the data sub-library can be selected as the top layer, the data table as the second layer, and the field information as the third layer. Each layer is equipped with a large language model. Generate a data table selection prompt A for each data sub-library name obtained in step 201 and the description information of each data sub-library, and use the data table selection prompt A as the prompt for the top layer; generate a data table selection prompt B for the data table names and the description information of each data table in each data sub-library obtained in step 201, and use the data table selection prompt B as the prompt for the second layer; generate a data table selection prompt C for the field names of each field information and the field types and field description information of each field information in each data table obtained in step 201, and use the data table selection prompt C as the prompt for the third layer. Input the user-entered query problem into the large language model of each layer, and in combination with the data table selection prompt of each layer, make selections layer by layer to determine the target data corresponding to the query problem.
[0096] S203: Determine the target data analysis result corresponding to the query problem in the database according to the second SQL statement and the target data.
[0097] According to the target data for the query problem obtained in step 202 and the second SQL statement generated for the query problem in step 104, determine the target data analysis result corresponding to the query problem in the database.
[0098] In the embodiment of the present application, input the query problem and the preset data table selection prompt into the large language model. Based on the large language model, determine the target database corresponding to the query problem, the target data table corresponding to the query problem in the target database, and the target field information corresponding to the query problem in the target data table. Use the target database as the first query object, the target data table as the second query object, and the target field information as the third query object, and perform queries in sequence to determine the target data corresponding to the query problem. Searching for the target field information in the database in a specified order ensures the accuracy of determining the target data analysis corresponding to the query problem in the database according to the second SQL statement.
[0099] Embodiment 3:
[0100] Before determining the target data analysis result corresponding to the query problem in the database according to the second SQL statement, there may be a problem that the generation of the target data analysis result fails. When the generation of the target data analysis result fails, the system will execute the following process, specifically:
[0101] If the first failure reason information is received; wherein, the failure reason information is used to represent that the determination of the data analysis result fails; input the first failure reason information, the second SQL statement, and the preset SQL statement repair prompt words into the large language model, and repair the second SQL statement based on the large language model; until the target data analysis result corresponding to the problem to be queried in the database is determined based on the repaired second SQL statement and the target data.
[0102] The first failure reason information refers to the reason information for the failure of the task of determining the target data analysis result corresponding to the problem to be queried in the database according to the second SQL statement. For example, the second SQL statement has a syntax error, resulting in the failure of determining the target data analysis result corresponding to the problem to be queried in the database. Among them, the first failure reason information is used to represent that the determination of the data analysis result fails.
[0103] The SQL statement repair prompt words are prompt words used to guide the large language model to repair or adjust the target SQL statement according to the failure reason information. The preset SQL statement repair prompt words are the SQL statement repair prompt words generated by the pre-trained transformer GPT according to the first failure reason information.
[0104] Input the first failure reason information, the second SQL statement, and the preset SQL statement repair prompt words into the large language model, repair the second SQL statement based on the large language model to obtain the repaired second SQL statement. Determine the target data analysis result corresponding to the problem to be queried in the database based on the repaired second SQL statement and the target data.
[0105] If the task of determining the target data analysis result corresponding to the problem to be queried in the database based on the repaired second SQL statement and the target data fails again, that is, the first failure reason information is received again. For example, the first failure reason information V1, where the first failure reason information V1 represents the reason information for the failure of the task of determining the target data analysis result corresponding to the problem to be queried in the database according to the repaired second SQL statement, then input the first failure reason information V1, the repaired second SQL statement, and the preset SQL statement repair prompt words into the large language model, and repair the repaired second SQL statement again based on the large language model until the target data analysis result corresponding to the problem to be queried in the database is determined based on the repaired second SQL statement and the target data.
[0106] The above repair process may be that the target data analysis result corresponding to the problem to be queried in the database can be determined based on the repaired second SQL statement and the target data after one repair, or it may be that the target data analysis result corresponding to the problem to be queried in the database can be determined based on the repaired second SQL statement and the target data after multiple repairs.
[0107] Example 4:
[0108] In order to convince users of the determined target data analysis result, after determining the target data analysis result and before displaying the target data analysis result on the front-end device, the present application also performs data verification on the determined target data analysis result to ensure that the target data analysis result is more persuasive.
[0109] Figure 3 The following is a schematic diagram of a data verification process provided by an embodiment of the present application. This process includes the following steps:
[0110] S301: Input the problem to be queried, the second SQL statement, and the preset data verification prompt words into the large language model, and generate data verification steps based on the large language model.
[0111] The second SQL statement refers to an SQL statement that can determine the target data analysis result corresponding to the problem to be queried in the database through the second SQL statement and the target data. That is, the second SQL statement may be a repaired SQL statement or an unrepaired SQL statement.
[0112] The data verification prompt words are prompt words used to guide the large language model to generate data verification steps corresponding to the problem to be queried according to the problem to be queried and the SQL statement. The preset data verification prompt words are data verification steps generated by the pre-trained transformer GPT according to the problem to be queried.
[0113] Input the problem to be queried, the second SQL statement, and the preset data verification prompt words into the large language model, and generate data verification steps based on the large language model. Among them, the generated data verification steps may be one verification step or multiple verification steps.
[0114] For example, if the problem to be queried A is to view the year-on-year and month-on-month total gas consumption of Company W in each month of 2023, input the problem to be queried A, the second SQL statement corresponding to the problem to be queried A, and the preset data verification prompt words into the large language model. The data verification steps generated based on the large language model are: Data verification step A: Calculate the total gas consumption in May and June of 2022 and 2023, and Data verification step B: Calculate the year-on-year and month-on-month of the total gas consumption in June 2023.
[0115] Another example, if the problem to be queried C is to view how many people there are in Class 1, Grade 9 of M Middle School, input the problem to be queried C, the second SQL statement corresponding to the problem to be queried C, and the preset data verification prompt words into the large language model. The data verification steps generated based on the large language model are: Obtain the number of boys and girls in Class 1, Grade 9 of M Middle School, and add the number of boys and girls.
[0116] S302: Input the data verification step and the preset SQL statement generation prompt into the large language model to generate the third SQL statement corresponding to the data verification step.
[0117] The preset SQL statement generation prompt is the same as the SQL statement generation prompt used in step 103 above, and will not be elaborated here.
[0118] Input the data verification step and the preset SQL statement generation prompt into the large language model to generate the third SQL statement corresponding to the data verification step. If there are multiple data verification steps for the corresponding query problem generated in step 301, input each data verification step and the preset SQL statement generation prompt into the large language model respectively to generate the third SQL statement corresponding to each data verification step.
[0119] S303: Determine the verification data analysis result corresponding to the data verification step in the database according to the third SQL statement.
[0120] Before obtaining the verification data analysis result corresponding to the data verification step according to the third SQL statement, determine the verification data to be used based on each verification step in the data verification step, that is, the verification data is part of the target data in step 202 above. For example, if the query problem A is to view the year-on-year and month-on-month total gas consumption of Company W in each month of 2023, input the query problem A, the second SQL statement corresponding to the query problem A, and the preset data verification prompt into the large language model. Based on the large language model, the data verification steps generated are: Data verification step A: Calculate the total gas consumption in May and June 2022 and 2023; Data verification step B: Calculate the year-on-year and month-on-month of the total gas consumption in June 2023. Input the problem of data verification step A and the preset data table selection prompt into the large language model. Based on the large language model, obtain the target data of data verification step A, that is, the total gas consumption of Company W in May and June 2022 and 2023. That is to say, the verification data only needs the total gas consumption data in May and June, which is part of the target data in step 202 above. According to the third SQL statement and the verification data, obtain the verification data analysis result corresponding to the data verification step.
[0121] In a possible implementation, in addition to saving the verification data analysis result, the system also saves the data analysis result generated corresponding to each data verification step. For example, if the query problem C is to view how many people there are in Class 1, Grade 9 of M Middle School, the data verification steps generated based on the large language model are: Obtain the number of boys and girls in Class 1, Grade 9 of M Middle School, and add the number of boys and girls. Then the system will save the number of boys X, the number of girls Y, and the total number X + Y in Class 1, Grade 9 of M Middle School. That is, the verification data analysis result is the number of boys X, the number of girls Y, and the total number X + Y.
[0122] S304: If the target data analysis result is the same as the verification data analysis result, display the data analysis result on the front-end device.
[0123] If the verification data analysis result obtained in step 303 is the same as the target data analysis result in step 203, the verification passes, that is, display the data analysis result on the front-end device.
[0124] Optionally, display the target data analysis result and the verification data analysis result on the front-end device at the same time. For example, when the problem C to be queried is to view how many people there are in Class 1, Grade 9 of M Middle School, after determining the target data analysis result, display the target data analysis result as Z people on the front-end device; the verification data analysis result is the number of boys X, the number of girls Y, and the total number X + Y = Z.
[0125] In the embodiment of the present application, by inputting the problem to be queried, the second SQL statement, and the preset data verification prompt words into the large language model, generate the data verification steps based on the large language model; input the data verification steps and the prompt words for generating the SQL statement preset into the large language model to generate the third SQL statement corresponding to the data verification steps; according to the third SQL statement, determine the verification data analysis result corresponding to the data verification steps in the database, and verify whether the verification data analysis result is the same as the determined target verification result, so that the target data analysis result is more persuasive.
[0126] Embodiment 5:
[0127] To ensure the accuracy of the determined target data analysis result, when the target data analysis result is different from the verification data analysis result, it proves that there is a problem with the generated target data analysis result. At this time, the present application will re-determine the target data analysis result, specifically:
[0128] If the target data analysis result is different from the verification data analysis result, input the received second failure reason information, the second SQL statement, and the preset SQL statement repair prompt words into the large language model, and repair the second SQL statement based on the large language model; until the verification data analysis result determined based on the repaired second SQL statement is the same as the target data analysis result determined based on the repaired second SQL statement.
[0129] If the target data analysis result is different from the verification data analysis result, the received second failure reason information will be received. The second failure reason information refers to the reason information that the target data analysis result corresponding to the problem to be queried in the database is different from the verification data analysis result generated in the data verification process according to the second SQL statement. Among them, the second failure reason information is used to represent the failure of data verification.
[0130] Input the received second failure reason information, the second SQL statement corresponding to the second failure reason information, and the preset SQL statement repair prompt words into the large language model, repair the second SQL statement based on the large language model to obtain the repaired second SQL statement; according to the repaired second SQL statement, determine the target data analysis result corresponding to the problem to be queried in the database again, and the verification data analysis result determined again according to the repaired second SQL statement; determine whether the target data analysis result and the verification data analysis result are the same. If they are the same, display the data analysis result on the front-end device; if they are not the same, continue to repair the repaired second SQL statement in the above steps until the verification data analysis result determined based on the repaired second SQL statement is the same as the target data analysis result determined based on the repair.
[0131] For example, the problem to be queried C is to check how many people there are in Class 1, Grade 1 of M Middle School. According to the second SQL statement L1, the determined target data analysis result is Z1 people, and the corresponding verification data analysis result is the number of boys X1, the number of girls Y1, and the total number X1 + Y1 ≠ Z1. And the second failure reason information V1 is received. Then, input the received second failure reason information V1, the second SQL statement L1, and the preset SQL statement repair prompt words into the large language model, repair the second SQL statement L1 based on the large language model to obtain the repaired second SQL statement L2; according to the repaired second SQL statement L2, determine the target data analysis result to be Z2 people again, and according to the repaired second SQL statement L2, determine the verification data analysis result to be the number of boys X2, the number of girls Y2, and the total number X2 + Y2 = Z2 again. Then, end the repair task and use the second SQL statement L2 as the final second SQL statement.
[0132] If the verification data analysis result determined again according to the repaired second SQL statement L2 is the number of boys X2, the number of girls Y2, and the total number X2 + Y2 ≠ Z2, and the second failure reason information V2 is received, then input the received second failure reason information V2, the second SQL statement L2, and the preset SQL statement repair prompt words into the large language model, repair the second SQL statement L2 based on the large language model to obtain the repaired second SQL statement L3; according to the repaired second SQL statement L3, determine the target data analysis result to be Z3 people again, and according to the repaired second SQL statement L3, determine the verification data analysis result to be the number of boys X3, the number of girls Y3, and the total number X3 + Y3 = Z3 again. Then, end the repair task and use the second SQL statement L3 as the final second SQL statement;
[0133] If the verification data analysis result determined again according to the repaired second SQL statement L3 is the number of male students X3, the number of female students Y3, and the total number X3 + Y3 ≠ Z3, and the second failure reason information V3 is received, then repeat the above steps and continue to repair the second SQL statement L3 until the target data analysis result determined according to the repaired second SQL statement L n is again determined to be Z n persons, and according to the repaired second SQL statement L n is again determined that the verification data analysis result is the number of male students X n , the number of female students Y n and the total number X n + Y n = Z n , then end the repair task and use the second SQL statement L n as the final second SQL statement.
[0134] In a possible implementation manner, when the target data analysis result is different from the verification data analysis result and the second failure reason information is received, the system will also give an alarm prompt and push the abnormal data analysis result to the user in time, so that the user can monitor the data in real time and facilitate the user to make corresponding responses in time. Specifically:
[0135] Output a prompt message indicating that the verification of the data analysis result fails.
[0136] When an abnormal data analysis result occurs, that is, the verification of the data analysis result fails, then output a prompt message for characterization, timely remind the user, and facilitate the user to make corresponding responses in time.
[0137] In the embodiment of the present application, if the target data analysis result is different from the verification data analysis result, input the received second failure reason information, the second SQL statement, and the preset SQL statement repair prompt words into the large language model, and repair the second SQL statement based on the large language model; until the verification data analysis result determined based on the repaired second SQL statement is the same as the target data analysis result determined based on the repaired second SQL statement, so as to ensure the accuracy of the determined target data analysis result, and push the abnormal data analysis result to the user in time, so that the user can monitor the data in real time and facilitate the user to make corresponding responses in time.
[0138] Embodiment 6:
[0139] In order to make complex data information more intuitive and easy to understand, and facilitate the user to understand and analyze, the present application selects a suitable chart through the intelligent agent to display the query result. Specifically:
[0140] Input the problem to be queried and the target data analysis result into the large language model, and determine the target chart containing the target data analysis result based on the large language model; display the target chart on the front-end device.
[0141] A chart refers to a graphical structure that is displayed on the screen and can intuitively display the statistical information attributes (such as temporality, quantity, etc.) and visually display the acquired data information. For example, a line chart, a bar chart, etc.
[0142] Input the problem to be queried and the target data analysis result into the large language model, and determine the target chart based on the large language model. Among them, the target chart can visually display the target data analysis result. And display the target chart containing the target data analysis result on the front-end device.
[0143] Embodiment 7:
[0144] For the convenience of users and to solve the problems of time-consuming labor and high maintenance costs in the deployment of existing database query services, which often require professional technical personnel for configuration and maintenance, this application realizes the automation of query services and reduces the maintenance cost through the intelligent agent to deploy relevant services according to the user's needs. Specifically:
[0145] Use the repaired second SQL statement as the target SQL statement corresponding to the problem to be queried; according to the preset query period, determine the target data analysis result of the problem to be queried corresponding to the current time in the database based on the target SQL statement.
[0146] The repaired second SQL statement refers to the second SQL statement that can successfully generate the target data analysis result according to this SQL statement, and the generated verification data analysis result is the same as the target data analysis result according to this SQL statement, that is, the data verification is also successful. Use this second SQL statement as the target SQL statement corresponding to the problem to be queried, and according to the preset query period, determine the target data analysis result of the problem to be queried corresponding to the current time in the database based on the target SQL statement.
[0147] Among them, the preset query period refers to the query period set according to the actual needs of the user. For example, if the user needs to obtain the temperature of the current day at N o'clock every day, then at N o'clock every day, the system will determine the temperature of the current time in the database based on the target SQL statement.
[0148] Embodiment 8:
[0149] Based on the same inventive concept, an apparatus for database data analysis is provided in an embodiment of this application. Figure 4 For the structural schematic diagram of the apparatus for database data analysis provided in an embodiment of this application, please refer to Figure 4 , the apparatus includes:
[0150] A receiving module 401 for receiving a query problem to be queried input by a user of a front-end device;
[0151] A processing module 402 for inputting the query problem to be queried and a preset task disassembling prompt word into a large language model, disassembling the query problem to be queried based on the large language model to obtain a plurality of sub-query problems to be queried; inputting the plurality of sub-query problems to be queried and a preset SQL statement generation prompt word into the large language model, and generating a first SQL statement corresponding to each sub-query problem to be queried based on the large language model; inputting each first SQL statement and the query problem to be queried into the large language model, and generating a second SQL statement based on the large language model; and determining a target data analysis result corresponding to the query problem in the database according to the second SQL statement.
[0152] In a possible implementation manner, the processing module 402 is specifically configured to input the query problem to be queried and a preset data table selection prompt word into the large language model, and based on the large language model, determine a target database corresponding to the query problem to be queried, a target data table in the target database corresponding to the query problem to be queried, and target field information in the target data table corresponding to the query problem to be queried; use the target database as a first query object, the target data table as a second query object, and the target field information as a third query object to perform queries in sequence to determine target data corresponding to the query problem to be queried; and determine a target data analysis result corresponding to the query problem in the database according to the second SQL statement and the target data.
[0153] In a possible implementation manner, the processing module 402 is further configured to, if receiving first failure cause information; where the failure cause information is used to represent that the determination of the data analysis result fails; input the first failure cause information, the second SQL statement, and a preset SQL statement repair prompt word into the large language model, and repair the second SQL statement based on the large language model; until a target data analysis result corresponding to the query problem in the database is determined based on the repaired second SQL statement and the target data.
[0154] In a possible implementation, the processing module 402 is further configured to input the problem to be queried, the second SQL statement, and a preset data verification prompt word into the large language model, and generate data verification steps based on the large language model; input the data verification steps and a prompt word for generating the preset SQL statement into the large language model to generate a third SQL statement corresponding to the data verification steps; determine a verification data analysis result corresponding to the data verification steps in the database according to the third SQL statement; if the target data analysis result is the same as the verification data analysis result, display the data analysis result on the front-end device.
[0155] In a possible implementation, the processing module 402 is further configured to, if the target data analysis result is different from the verification data analysis result, input the received second failure reason information, the second SQL statement, and the preset SQL statement repair prompt word into the large language model, and repair the second SQL statement based on the large language model; until the verification data analysis result determined based on the repaired second SQL statement is the same as the target data analysis result determined based on the repaired second SQL statement.
[0156] In a possible implementation, the processing module 402 is specifically configured to input the problem to be queried and the target data analysis result into the large language model, and determine a target chart including the target data analysis result based on the large language model; display the target chart on the front-end device.
[0157] In a possible implementation, the processing module 402 is further configured to use the repaired second SQL statement as the target SQL statement corresponding to the problem to be queried; according to a preset query period, determine a target data analysis result of the problem to be queried corresponding to the current time in the database according to the target SQL statement.
[0158] In a possible implementation, the processing module 402 is further configured to output a prompt message indicating that the verification of the data analysis result fails.
[0159] Embodiment 9:
[0160] Based on the same inventive concept, an embodiment of the present application provides an electronic device, which can implement the steps of the method for database data analysis described above. Figure 5 A schematic structural diagram of an electronic device provided by an embodiment of the present application is shown in Figure 5 As shown, it includes: a processor 501, a communication interface 502, a memory 503, and a communication bus 504. Among them, the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504.
[0161] A computer program is stored in the memory 503. When the program is executed by the processor 501, the processor 501 is caused to execute the following steps:
[0162] Receive a query problem input by a user of the front-end device;
[0163] Input the query problem and a preset task decomposition prompt word into a large language model, and decompose the query problem based on the large language model to obtain a plurality of sub-query problems;
[0164] Input the plurality of sub-query problems and a preset SQL statement generation prompt word into the large language model, and generate a first SQL statement corresponding to each sub-query problem based on the large language model;
[0165] Input each first SQL statement and the query problem into the large language model, and generate a second SQL statement based on the large language model;
[0166] Determine a target data analysis result corresponding to the query problem in the database according to the second SQL statement.
[0167] In a possible implementation manner, determining a target data analysis result corresponding to the query problem in the database according to the second SQL statement includes:
[0168] Input the query problem and a preset data table selection prompt word into the large language model, and based on the large language model, determine a target database corresponding to the query problem, a target data table in the target database corresponding to the query problem, and target field information in the target data table corresponding to the query problem;
[0169] Use the target database as a first query object, the target data table as a second query object, and the target field information as a third query object, and perform queries in sequence to determine target data corresponding to the query problem;
[0170] Determine a target data analysis result corresponding to the query problem in the database according to the second SQL statement and the target data.
[0171] In a possible implementation manner, before determining a target data analysis result corresponding to the query problem in the database, the method further includes:
[0172] If the first failure reason information is received; wherein, the failure reason information is used to characterize the failure of determining the data analysis result; input the first failure reason information, the second SQL statement, and a preset SQL statement repair prompt word into the large language model, and repair the second SQL statement based on the large language model; until the target data analysis result corresponding to the problem to be queried in the database is determined based on the repaired second SQL statement and the target data.
[0173] In a possible implementation manner, the method further includes:
[0174] Input the problem to be queried, the second SQL statement, and a preset data verification prompt word into the large language model, and generate data verification steps based on the large language model;
[0175] Input the data verification steps and the preset SQL statement generation prompt word into the large language model to generate a third SQL statement corresponding to the data verification steps;
[0176] Determine the verification data analysis result corresponding to the data verification steps in the database according to the third SQL statement;
[0177] If the target data analysis result is the same as the verification data analysis result, display the data analysis result on the front-end device.
[0178] In a possible implementation manner, the method further includes:
[0179] If the target data analysis result is different from the verification data analysis result, input the received second failure reason information, the second SQL statement, and the preset SQL statement repair prompt word into the large language model, and repair the second SQL statement based on the large language model; until the verification data analysis result determined based on the repaired second SQL statement is the same as the target data analysis result determined based on the repaired second SQL statement.
[0180] In a possible implementation manner, displaying the data analysis result on the front-end device includes:
[0181] Input the problem to be queried and the target data analysis result into the large language model, and determine a target chart containing the target data analysis result based on the large language model; display the target chart on the front-end device.
[0182] In a possible implementation manner, the method further includes:
[0183] Use the repaired second SQL statement as the target SQL statement corresponding to the problem to be queried;
[0184] According to a preset query period, based on the target SQL statement, determine the target data analysis result of the problem to be queried corresponding to the current time in the database.
[0185] In a possible implementation manner, if the target data analysis result is different from the verification data analysis result, the method further includes:
[0186] Output a prompt message for characterizing the failure of data analysis result verification.
[0187] Since the principle of the above electronic device for solving problems is similar to the method of database data analysis, the implementation of the above electronic device can refer to the embodiments of the method, and the repeated parts will not be described again.
[0188] The communication bus mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface 502 is used for communication between the above electronic device and other devices. The memory may include a Random Access Memory (RAM), and may also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.
[0189] The above processor may be a general-purpose processor, including a central processing unit, a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit, a field-programmable gate array or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0190] Embodiment 10:
[0191] Based on the same application concept, an embodiment of the present application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program executable by a processor. When the program runs on the processor, it causes the processor to execute the method for database data analysis as described in any of the foregoing discussions. Since the principle of solving problems by the above computer-readable storage medium is similar to that of the method for database data analysis, the implementation of the above computer-readable storage medium can refer to the implementation of the method, and the repeated parts will not be described again.
[0192] Based on the same application concept, an embodiment of the present application also provides a computer program product. The computer program product includes: computer program code. When the computer program code runs on a computer, it causes the computer to execute the method for database data analysis as described in any of the foregoing discussions. Since the principle of solving problems by the above computer program product is similar to that of the method for database data analysis, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be described again.
[0193] In the embodiment of the present application, the data analysis result can be determined by only inputting the problem to be queried. Compared with manually writing SQL statements and querying database data according to the written SQL statements to obtain the data analysis result, the present application not only ensures the use by users who do not have basic knowledge of SQL programming, but also improves the generation efficiency of SQL statements, and at the same time avoids the problem of the decrease in data analysis accuracy caused by human errors when writing SQL statements manually.
[0194] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0195] The present application is described with reference to the flowcharts and / or block diagrams of the method, device (system), and computer program product according to the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0196] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to work in a particular manner, such that the instructions stored in the computer-readable memory produce a manufacture including an instruction device that implements the functions specified in one or more processes and / or blocks Figure 1 in the flow Figure 1 of one or more processes and / or boxes
[0197] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, so that the instructions executed on the computer or other programmable apparatus provide steps for implementing the functions specified in one or more processes and / or blocks Figure 1 in the flow Figure 1 of one or more processes and / or boxes
[0198] Obviously, those skilled in the art can make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalent technologies, this application is also intended to include these changes and modifications.
Claims
1. A database data analysis method, characterized in that: The method comprises: Receive the query question input by the user of the front-end device; Inputting the question to be queried and preset task decomposition prompt words into a large language model, and decomposing the question to be queried based on the large language model to obtain multiple sub-questions to be queried; Input the plurality of sub-questions to be queried and preset SQL statement generation prompt words into the large language model, and generate a first SQL statement corresponding to each of the sub-questions to be queried based on the large language model; Input each first SQL statement and the question to be queried into the large language model, and generate a second SQL statement based on the large language model; According to the second SQL statement, a target data analysis result corresponding to the question to be queried in the database is determined.
2. The method according to claim 1, characterized in that According to the second SQL statement, determining the target data analysis result corresponding to the query question in the database includes: Inputting the question to be queried and a preset data table selection prompt word into the large language model, and determining, based on the large language model, a target database corresponding to the question to be queried, a target data table corresponding to the question to be queried in the target database, and target field information corresponding to the question to be queried in the target data table; The target database is used as the first query object, the target data table is used as the second query object, and the target field information is used as the third query object, and queries are performed in sequence to determine the target data corresponding to the query question; According to the second SQL statement and the target data, a target data analysis result corresponding to the question to be queried in the database is determined.
3. The method according to claim 2, characterized in that Before determining the target data analysis result corresponding to the query question in the database, the method further includes: If first failure reason information is received; wherein the failure reason information is used to characterize the failure of determining the data analysis result; the first failure reason information, the second SQL statement, and a preset SQL statement repair prompt word are input into the large language model, and the second SQL statement is repaired based on the large language model; until the target data analysis result corresponding to the question to be queried in the database is determined based on the repaired second SQL statement and the target data.
4. The method according to claim 1, characterized in that: The method further comprises: Inputting the query question, the second SQL statement and the preset data verification prompt word into the large language model, and generating a data verification step based on the large language model; Input the data verification step and the preset SQL statement generation prompt word into the large language model to generate a third SQL statement corresponding to the data verification step; Determine, according to the third SQL statement, a verification data analysis result corresponding to the data verification step in the database; If the target data analysis result is the same as the verification data analysis result, the data analysis result is displayed on the front-end device.
5. The method according to claim 4, characterized in that The method further comprises: If the target data analysis result is different from the verification data analysis result, the received second failure reason information, the second SQL statement, and the preset SQL statement repair prompt word are input into the large language model, and the second SQL statement is repaired based on the large language model; until the verification data analysis result determined based on the repaired second SQL statement is the same as the target data analysis result determined based on the repaired second SQL statement.
6. The method according to claim 4, characterized in that Displaying the data analysis result on the front-end device includes: The query question and the target data analysis result are input into the large language model, and a target chart including the target data analysis result is determined based on the large language model; and the target chart is displayed on the front-end device.
7. The method according to claim 5, characterized in that The method further comprises: Using the repaired second SQL statement as a target SQL statement corresponding to the question to be queried; According to the preset query cycle and the target SQL statement, the target data analysis result corresponding to the query question at the current time in the database is determined.
8. The method according to claim 5, characterized in that If the target data analysis result is different from the verification data analysis result, the method further includes: Outputs prompt information indicating failure of data analysis result verification.
9. A device for analyzing database data, characterized in that: The device comprises: A receiving module, used for receiving a query question input by a user of a front-end device; A processing module is used to input the problem to be queried and preset task decomposition prompt words into a large language model, decompose the problem to be queried based on the large language model to obtain multiple sub-problems to be queried; input the multiple sub-problems to be queried and preset SQL statement generation prompt words into the large language model, and generate a first SQL statement corresponding to each sub-problem to be queried based on the large language model; input each first SQL statement and the problem to be queried into the large language model, and generate a second SQL statement based on the large language model; and determine a target data analysis result corresponding to the problem to be queried in a database according to the second SQL statement.
10. An electronic device, characterized in that: The electronic device comprises a processor, and the processor is used to implement the method for analyzing database data as claimed in any one of claims 1 to 8 when executing a computer program stored in a memory.