CN117743374A - Database text query method, device and equipment based on data examples - Google Patents

Database text query method, device and equipment based on data examples Download PDF

Info

Publication number
CN117743374A
CN117743374A CN202410102399.8A CN202410102399A CN117743374A CN 117743374 A CN117743374 A CN 117743374A CN 202410102399 A CN202410102399 A CN 202410102399A CN 117743374 A CN117743374 A CN 117743374A
Authority
CN
China
Prior art keywords
data
target
database
library
field value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410102399.8A
Other languages
Chinese (zh)
Inventor
叶栽森
王子豪
王子
陈志刚
穆玉芝
张健
韩伟
徐雪帆
周正茂
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Daguan Data Co ltd
Original Assignee
Daguan Data Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Daguan Data Co ltd filed Critical Daguan Data Co ltd
Priority to CN202410102399.8A priority Critical patent/CN117743374A/en
Publication of CN117743374A publication Critical patent/CN117743374A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a database text query method, device and equipment based on a data example. A database text query method based on data examples, comprising: determining library table information according to a full data table of a target database, and determining a data example table according to a field value space of the full data table; creating large model prompt words according to the library table information, the data example table and the user query input data; inputting the large model prompt word into a target large model to obtain a target SQL sentence; and querying the target database according to the target SQL statement to obtain query result data. The technical scheme of the embodiment of the invention can meet the complex and changeable data query requirements of users on the database, and the accuracy of the data query result is high.

Description

Database text query method, device and equipment based on data examples
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a database text query method, device and equipment based on data examples.
Background
The database is an indispensable data management tool for corporate enterprises, and is generally used for storing unique and industry-related data inside the corporation, and the operation of the database itself has a set of special usage grammars, which results in that only a small part of technicians can directly complete complex query work from the database. It is clearly impossible for a small number of technicians to meet the data query requirements of auditors and corporate high-level across an enterprise. While this problem can be alleviated by accessing a database to custom data analysis software, it is still not well satisfactory in operation.
The large model has strong language understanding capability, and can be used for understanding the complex demands of business personnel to a certain extent, but cannot really complete the working demands of the business personnel in actual work. By way of example, assume that the question posed by business personnel is "what are employees from the Shanghai? If the content is input into the large model after being optimized by a proper instruction, one output result is ' SELECT id, name FROM personnel _info WHERE city= ' Shanghai '; the SQL (Structured Query Language ) statement is automatically queried in the database, but the obtained return result is empty, not because staff from Shanghai are not available in the database, but the data content stored in all the city fields in the database is data representing place names such as Shanghai city, beijing city, zhejiang province and the like, and the correct output result can be obtained only when the Shanghai city is required to be used for limiting questioning. In summary, even by means of a large model, the method cannot adapt to the requirement of users for variable and complex query of data in a database.
Disclosure of Invention
The invention provides a database text query method, device and equipment based on a data example, which are used for solving the problem that the prior large model cannot meet the requirement of a user on complex and changeable data in a database.
According to an aspect of the present invention, there is provided a database text query method based on a data instance, including:
determining library table information according to a full data table of a target database, and determining a data example table according to a field value space of the full data table;
creating large model prompt words according to the library table information, the data example table and the user query input data;
inputting the large model prompt word into a target large model to obtain a target SQL sentence;
and querying the target database according to the target SQL statement to obtain query result data.
According to another aspect of the present invention, there is provided a database text query apparatus based on a data example, including:
the data pre-preparation module is used for determining library table information according to the full data table of the target database and determining a data example table according to the field value space of the full data table;
the large model prompt word creation module is used for creating large model prompt words according to the library table information, the data example table and the user query input data;
the target SQL sentence generation module is used for inputting the large model prompt word into the target large model to obtain a target SQL sentence;
and the query result data acquisition module is used for querying the target database according to the target SQL statement to obtain query result data.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the data instance-based database text query method of any one of the embodiments of the present invention.
According to another aspect of the present invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to implement the database text query method based on data examples according to any one of the embodiments of the present invention when executed.
According to the technical scheme, library table information is determined according to the full-scale data table of the target database, the data example table is determined according to the field value space of the full-scale data table, so that large model prompt words are created according to the library table information, the data example table and the input data of the user query, the large model prompt words are input into the target large model, a target SQL sentence is obtained, the target database is queried according to the target SQL sentence, and query result data is obtained. According to the scheme, based on library table information and the data example table, potential business knowledge of the target database can be fully mined, so that target SQL sentences converted from large model prompt words can be fully utilized, usability of the target SQL sentences can be guaranteed, complex and changeable data query requirements of users can be met to the greatest extent, the problem that complex and changeable data query requirements of the users on the database can not be met based on the large model at present is solved, complex and changeable data query requirements of the users on the database can be met, and data query results are high in accuracy.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a database text query method based on a data example according to a first embodiment of the present invention;
fig. 2 is a flowchart of a database text query method based on a data example according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of a database text query device based on a data example according to a third embodiment of the present invention;
fig. 4 shows a schematic diagram of the structure of an electronic device that may be used to implement an embodiment of the invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the term "object" and the like in the description of the present invention and the claims and the above drawings are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
Fig. 1 is a flowchart of a database text query method based on a data example, which is provided in an embodiment of the present invention, and the embodiment is applicable to a situation that information required by a user is queried from a database accurately and efficiently. As shown in fig. 1, the method includes:
step 110, determining the information of the database table according to the full data table of the target database, and determining the data example table according to the field value space of the full data table.
The target database may be a database that the user needs to query. The full data table may be all of the data tables in the target database. The library table information may be table information of a data table in the target database. The field value space may be used to describe the value space of the corresponding value of the field. The field value space may include a limited space or an infinite space. Illustratively, if the field corresponds to the data value being infinite, continuous, the field value space is determined to be infinite, and if the field corresponds to the data value being finite, discrete, the field value space is determined to be finite. The data example table may be a presentation list of field related data determined from a field value space of the full data table.
In the embodiment of the invention, each table in the full-volume data table of the target database can be scanned and analyzed to obtain the database table information, all data in the full-volume data table are scanned field by field, the numerical value limitation of each data table in the full-volume data table is judged to obtain the field value space of each data table, and thus the data example table is generated according to the field value space of each data table in the full-volume data table as the field of the limited space.
Step 120, creating large model prompt words according to the library table information, the data example table and the user query input data.
The user query input data may be data required for the characterization data query input by the user. The large model hint words may be hint words that are determined based on library table information, data instance tables, and user query input data.
In the embodiment of the invention, after the library table information and the data example table are obtained, user query input data are obtained, and the library table information, the data example table and the user query input data are combined to obtain the large model prompt word.
And 130, inputting the large model prompt word into a target large model to obtain a target SQL sentence.
Wherein the target large model may be a pre-selected one of the large-scale language models. By way of example, the target large model may include, but is not limited to, a Baichuan large model. The target SQL statement may be an SQL statement that the target big model determines based on big model hint words.
In the embodiment of the invention, the large model prompt word can be input into the target large model, so that the large model prompt word is analyzed based on the target large model to obtain the target SQL sentence output by the target large model.
And 140, inquiring the target database according to the target SQL statement to obtain inquiry result data.
The query result data may be data queried from a target database based on a target SQL statement.
In the embodiment of the invention, the target SQL statement can be utilized to perform data query in the target database, so as to obtain query result data, and the query result data is fed back to the user.
According to the technical scheme, library table information is determined according to the full-scale data table of the target database, the data example table is determined according to the field value space of the full-scale data table, so that large model prompt words are created according to the library table information, the data example table and the input data of the user query, the large model prompt words are input into the target large model, a target SQL sentence is obtained, the target database is queried according to the target SQL sentence, and query result data is obtained. According to the scheme, based on library table information and the data example table, potential business knowledge of the target database can be fully mined, so that target SQL sentences converted from large model prompt words can be fully utilized, usability of the target SQL sentences can be guaranteed, complex and changeable data query requirements of users can be met to the greatest extent, the problem that complex and changeable data query requirements of the users on the database can not be met based on the large model at present is solved, complex and changeable data query requirements of the users on the database can be met, and data query results are high in accuracy.
Example two
Fig. 2 is a flowchart of a database text query method based on a data example according to a second embodiment of the present invention, where the present embodiment is implemented based on the foregoing embodiment, and a specific alternative implementation manner of determining the database table information according to the full-size data table of the target database is provided. As shown in fig. 2, the method includes:
step 210, scanning the full data table of the target database according to a preset period in the idle time of the system to obtain the data definition language of the target database.
The system idle time may be an idle period of a service system that performs data processing on data in the target database. The data definition language, data Definition Language, abbreviated DDL.
In the embodiment of the invention, each data table of the full data table of the target database can be scanned and analyzed according to a preset period in the idle time of the system to obtain the data definition language in the target database, so that the offline scanning, analysis and timing updating of the data table are realized.
Step 220, using the data definition language as library table information corresponding to the target database, and determining a data example table according to the field value space of the full data table.
In the embodiment of the invention, the data definition language in the target database can be used as the library table information corresponding to the target database, so that the data example table is determined based on the field value space of the full data table.
In an alternative embodiment of the present invention, determining the data example table according to the field value space of the full data table may include: determining a limited space data table field based on a field value space of the full data table; a data example table is generated from the limited space data table field.
The field of the limited space data table may be a field whose value space is limited space.
In the embodiment of the invention, the field value space of each field of each data table in the full data table can be determined according to the field value space of the full data table, so that the field of the limited space data table matched with each data table is determined according to the field value space of each field of each data table, and then the field value corresponding to the field of the limited space data table matched with each data table and the field value corresponding to the field of the limited space data table are utilized to generate the data example table corresponding to each data table.
In an alternative embodiment of the present invention, before determining the limited space data table field based on the field value space of the full data table, the method may further include: respectively counting the types of data table field values of all data tables in the full data table; and determining the field value space of each data table in the full data table according to the type of the field value of each data table and the field value type threshold value.
The field value of the data table may be a numerical value corresponding to a field in the data table. Illustratively, assume that a piece of text data in the data table is: the field value corresponding to the field city is Shanghai city, and is the city of Shanghai city. The field value category threshold may be a threshold that compares the total number of categories of different data table field values corresponding to a single field in one data table. The field value type threshold may be set to a constant according to the actual application scenario, or may be calculated according to the data amount of the target database (for example, may be 20% of the data amount of the target database).
In the embodiment of the invention, under each data table in the full-scale data table, the type of the data table field value of each field can be counted, the type of the data table field value of each field of each data table is further compared with the field value type threshold value, and when the type of the data table field value of the field is greater than the field value type threshold value, the field value space of the field value space is determined to be infinite space. When the type of the field value of the data table of the field is smaller than or equal to the threshold value of the type of the field value, determining the field value space of the field value space as a limited space, thereby obtaining the field value space of each data table in the full data table.
In a specific example, the numerical value in each field in each data table in the target database is obtained, and then whether each field is to be added into the data example display list is sequentially judged, namely, the type of the field value of the data table of each field is counted, and if the type of the field value of the data table of the field is greater than the field value type threshold value, the data example table is not added. If the category of the data table field value of the field is not greater than the field value category threshold, the field and the corresponding value of the field are added to the data example table.
In an alternative embodiment of the present invention, determining the limited space data table field based on the field value space of the full data table may include: screening the field value space of each data table in the full data table to obtain a field with the field value space of each data table being of a limited space type; and respectively determining the field of the limited space data table corresponding to each data table according to the field value space of each data table as the field of the limited space type.
In the embodiment of the invention, the field value space of each data table in the full data table can be screened according to the value space type to obtain the field with the field value space of the limited space type in each data table, and then the field value space of each data table is the field with the limited space type and is used as the field of the limited space data table corresponding to the corresponding data table.
Step 230, creating large model prompt words according to the library table information, the data example table and the user query input data.
In an alternative embodiment of the present invention, creating large model hint words based on library table information, data instance tables, and user query input data may include: acquiring query non-key data; deleting non-key data in the library table information to obtain library table information to be normalized, and carrying out normalization processing on the library table information to be normalized according to the information type to obtain target library table information; and creating large model prompt words according to the target library table information, the data example table and the user query input data.
Wherein, the non-key data can be unnecessary character strings for generating the target SQL statement in the library table information. Illustratively, the query non-critical data may include, but is not limited to ENGINE, charset and null, etc. The library table information to be normalized may be library table information after the query non-critical data is deleted. The target library table information may be library table information after normalization processing is performed on the library table information to be normalized.
In the embodiment of the invention, the query non-key data can be acquired firstly, so that the query non-key data in the library table information is deleted, the library table information with the query non-key data deleted is used as the library table information to be normalized, and the normalization processing is carried out on the library table information to be normalized according to the information type (such as a data type, a text type, a date time type and the like) to obtain the target library table information. Further, combining the target library table information, the data example table and the user query input data to obtain the large model prompt word.
Illustratively, the library table information is assumed to be as follows:
the query non-key data (ENGINE, charset and null) are deleted, the int and the tinyint (1) are digital types, can be normalized to number, and can normalize char (n), tinytext, text, media text, longtext and the like into text types. The date and time class for the library table information can be normalized to datetime through verification. The target library table information obtained by simplifying the library table information is as follows:
in an alternative embodiment of the present invention, creating the large model hint word based on the target library table information, the data instance table, and the user query input data may include: screening the data example table according to the user query input data to obtain a data example table to be organized; and creating large model prompt words according to the user query input data, the target library table information and the data to be organized example table.
The data example table to be organized may be a data example table matched with user query input data.
In the embodiment of the invention, the data example table can be screened according to the user query input data to obtain the data example table matched with the user query input data, the obtained data example table is used as the data example table to be organized, and the user query input data, the target library table information and the data example table to be organized are combined to generate the large model prompt word.
And 240, inputting the large model prompt word into a target large model to obtain a target SQL sentence.
And 250, inquiring a target database according to the target SQL statement to obtain inquiry result data.
In one particular example, a database text query system for data examples may include a business knowledge offline update module and an online query module.
The business knowledge offline updating module is used for acquiring the library table information from the target database, analyzing the table, the field and the field category in the library table information, and carrying out normalization processing to obtain the target library table information. The business knowledge offline updating module is further configured to obtain values of all fields, namely field values of the data table, from the target database, analyze the values of each field in the target database, extract all or part of data related to the field as a representative if the values of the fields are discrete limited, obtain a data example, further generate a data example table according to the data example corresponding to multiple fields, and record the target database table information together with the data example table, and update the target database table information in idle time of the system instead of the system working time.
The on-line query module is used for acquiring user query input data, integrating service information (target library table information and data example table) with the user query input data, thus inputting a target large model to obtain a target SQL sentence, and further completing query on a target database based on the target SQL sentence. The above operation of the online query module specifically comprises the following steps:
and acquiring service information of the service knowledge offline updating module, integrating the service information into a background word input by a large model, and then adding user query input data to obtain a complete Prompt (large model Prompt word). For example, the target library table information is as follows:
an example table of data to be organized is as follows:
{
"city" ("Shanghai city", "Zhejiang province", "Beijing city")
}
The final combined complete promt is as follows:
the data in the 'personnel_info' table is exemplified as follows:
{
"city" ("Shanghai city", "Zhejiang province", "Beijing city")
}
User query input data: what are employees from Shanghai?
The example data in the 'personnel_info' table shown in the foregoing does not represent all of the data in the target database.
According to the method and the device, the data information of the database can be fully utilized in the process of converting the text into the target SQL sentence by the target large model, and too much text length cannot be newly increased in the actual use process. And business knowledge can be applied to the maximum degree in the process of generating the target SQL statement, so that the usability of the target SQL statement is ensured, the degree of freedom of a user on the question statement can be improved to the maximum degree, and the expression rules of related data in a database are not excessively complied with.
According to the technical scheme, the full data table of the target database is scanned according to a preset period in the idle time of the system to obtain the data definition language of the target database, so that the data definition language is used as the database table information corresponding to the target database, the data example table is determined according to the field value space of the full data table, the large model prompt word is created according to the database table information, the data example table and the user query input data, the large model prompt word is further input into the target large model, the target SQL statement is obtained, the target database is queried according to the target SQL statement, and the query result data is obtained. According to the method and the system, the library table information is determined in the idle time of the system, the normal business processing of the system is not affected, the potential business knowledge of the target database can be fully mined based on the library table information and the data example table, so that the target SQL statement converted by the large model prompt word can be fully utilized, the usability of the target SQL statement is guaranteed, the complex and changeable data query requirement of a user is met to the greatest extent, the problem that the complex and changeable data query requirement of the user on the database cannot be met based on the large model at present is solved, the complex and changeable data query requirement of the user on the database can be met, and the accuracy of the data query result is high.
Example III
Fig. 3 is a schematic structural diagram of a database text query device based on a data example according to a third embodiment of the present invention. As shown in fig. 3, the apparatus includes:
a data pre-preparing module 310, configured to determine library table information according to a full data table of the target database, and determine a data example table according to a field value space of the full data table;
the large model prompt word creating module 320 is configured to create a large model prompt word according to the library table information, the data example table, and the user query input data;
the target SQL sentence generation module 330 is configured to input the big model prompt word into the target big model to obtain a target SQL sentence;
the query result data obtaining module 340 is configured to query the target database according to the target SQL statement, and obtain query result data.
According to the technical scheme, library table information is determined according to the full-scale data table of the target database, the data example table is determined according to the field value space of the full-scale data table, so that large model prompt words are created according to the library table information, the data example table and the input data of the user query, the large model prompt words are input into the target large model, a target SQL sentence is obtained, the target database is queried according to the target SQL sentence, and query result data is obtained. According to the scheme, based on library table information and the data example table, potential business knowledge of the target database can be fully mined, so that target SQL sentences converted from large model prompt words can be fully utilized, usability of the target SQL sentences can be guaranteed, complex and changeable data query requirements of users can be met to the greatest extent, the problem that complex and changeable data query requirements of the users on the database can not be met based on the large model at present is solved, complex and changeable data query requirements of the users on the database can be met, and data query results are high in accuracy.
Optionally, the data pre-preparing module 310 includes a database table information determining unit, configured to scan, in a system idle time, a full data table of the target database according to a preset period, to obtain a data definition language of the target database; and using the data definition language as library table information corresponding to the target database.
Optionally, the data pre-preparing module 310 includes a data example table determining unit, configured to determine a limited space data table field based on a field value space of the full data table; and generating the data example table according to the limited space data table field.
Optionally, the database text query device of the data example further includes a field value space determining module, configured to respectively count types of data table field values of each data table in the full-scale data table; and determining the field value space of each data table in the full data table according to the type of the data table field value of each data table and the field value type threshold value.
Optionally, the data example table determining unit is configured to screen a field value space of each data table in the full-volume data table to obtain a field of which the field value space of each data table is a limited space type; and respectively determining the field of the limited space data table corresponding to each data table according to the field value space of each data table as the field of the limited space type.
Optionally, the large model hint word creating module 320 is configured to obtain query non-key data; deleting the non-key data in the library table information to obtain library table information to be normalized, and carrying out normalization processing on the library table information to be normalized according to information types to obtain target library table information; and creating large model prompt words according to the target library table information, the data example table and the user query input data.
Optionally, the large model prompt word creating module 320 is configured to screen the data example table according to the user query input data to obtain a data example table to be organized; and creating the large model prompt word according to the user query input data, the target library table information and the data to be organized example table.
The database text query device based on the data example provided by the embodiment of the invention can execute the database text query method based on the data example provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example IV
Fig. 4 shows a schematic diagram of the structure of an electronic device that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 4, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as database text query methods based on data examples.
In some embodiments, the database text query method based on data examples may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the data example-based database text query method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the database text query method based on the data examples in any other suitable way (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. A database text query method based on data examples, comprising:
determining library table information according to a full data table of a target database, and determining a data example table according to a field value space of the full data table;
creating large model prompt words according to the library table information, the data example table and user query input data;
inputting the large model prompt word into a target large model to obtain a target structured query language SQL sentence;
and inquiring the target database according to the target SQL statement to obtain inquiry result data.
2. The method of claim 1, wherein determining library table information from the full data table of the target database comprises:
scanning the full data table of the target database according to a preset period in the idle time of the system to obtain the data definition language of the target database;
and using the data definition language as library table information corresponding to the target database.
3. The method of claim 1, wherein determining the data instance table based on the field value space of the full data table comprises:
determining a limited space data table field based on a field value space of the full data table;
and generating the data example table according to the limited space data table field.
4. The method of claim 3, further comprising, prior to said determining a limited space data table field based on a field value space of said full data table:
respectively counting the types of data table field values of all the data tables in the full data table;
and determining the field value space of each data table in the full data table according to the type of the data table field value of each data table and the field value type threshold value.
5. The method of claim 4, wherein determining a limited space data table field based on a field value space of the full data table comprises:
screening the field value space of each data table in the full data table to obtain a field with the field value space of each data table being of a limited space type;
and respectively determining the field of the limited space data table corresponding to each data table according to the field value space of each data table as the field of the limited space type.
6. The method of claim 1, wherein creating large model hint words from the library table information, the data instance table, and user query input data comprises:
acquiring query non-key data;
deleting the non-key data in the library table information to obtain library table information to be normalized, and carrying out normalization processing on the library table information to be normalized according to information types to obtain target library table information;
and creating large model prompt words according to the target library table information, the data example table and the user query input data.
7. The method of claim 6, wherein creating large model hint words from the target library table information, the data instance table, and the user query input data comprises:
screening the data example table according to the user query input data to obtain a data example table to be organized;
and creating the large model prompt word according to the user query input data, the target library table information and the data to be organized example table.
8. A database text query device based on data examples, comprising:
the data pre-preparation module is used for determining library table information according to a full data table of a target database and determining a data example table according to a field value space of the full data table;
the large model prompt word creation module is used for creating large model prompt words according to the library table information, the data example table and the user query input data;
the target SQL sentence generation module is used for inputting the big model prompt word into a target big model to obtain a target SQL sentence;
and the query result data acquisition module is used for querying the target database according to the target SQL statement to obtain query result data.
9. An electronic device, the electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the data instance based database text query method of any of claims 1-7.
10. A computer readable storage medium storing computer instructions for causing a processor to implement the data instance based database text query method of any one of claims 1-7 when executed.
CN202410102399.8A 2024-01-24 2024-01-24 Database text query method, device and equipment based on data examples Pending CN117743374A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410102399.8A CN117743374A (en) 2024-01-24 2024-01-24 Database text query method, device and equipment based on data examples

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410102399.8A CN117743374A (en) 2024-01-24 2024-01-24 Database text query method, device and equipment based on data examples

Publications (1)

Publication Number Publication Date
CN117743374A true CN117743374A (en) 2024-03-22

Family

ID=90254752

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410102399.8A Pending CN117743374A (en) 2024-01-24 2024-01-24 Database text query method, device and equipment based on data examples

Country Status (1)

Country Link
CN (1) CN117743374A (en)

Similar Documents

Publication Publication Date Title
WO2020233330A1 (en) Batch testing method, apparatus, and computer-readable storage medium
CN111722839B (en) Code generation method and device, electronic equipment and storage medium
CN114328574A (en) Data query method and device, electronic equipment and computer-readable storage medium
CN114579104A (en) Data analysis scene generation method, device, equipment and storage medium
CN103678396B (en) A kind of data back up method and device based on data model
CN112084150A (en) Model training method, data retrieval method, device, equipment and storage medium
CN113220710A (en) Data query method and device, electronic equipment and storage medium
CN116775634A (en) Quality inspection method, device, equipment and medium for power generation engineering data
CN116611411A (en) Business system report generation method, device, equipment and storage medium
CN116185389A (en) Code generation method and device, electronic equipment and medium
CN116150394A (en) Knowledge extraction method, device, storage medium and equipment for knowledge graph
CN115455091A (en) Data generation method and device, electronic equipment and storage medium
CN115169316A (en) Data processing template generation method and device, electronic equipment and storage medium
CN117743374A (en) Database text query method, device and equipment based on data examples
CN115687717A (en) Method, device and equipment for acquiring hook expression and computer readable storage medium
CN115510247A (en) Method, device, equipment and storage medium for constructing electric carbon policy knowledge graph
CN115577689A (en) Table component generation method, device, equipment and medium
CN115543428A (en) Simulated data generation method and device based on strategy template
CN113779117A (en) Data monitoring method and device, storage medium and electronic equipment
CN112051996B (en) Modeling method and device based on development platform element unified naming dictionary
CN117331926B (en) Data auditing method and device, electronic equipment and storage medium
CN112307050B (en) Identification method and device for repeated correlation calculation and computer system
CN110874313B (en) Writing tool testing method and device
CN117608575A (en) Application development method, system, equipment and storage medium
CN115981657A (en) Code generation method and device, electronic equipment and readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination