Data query method and device based on automatic statement conversion, equipment and medium

By implementing automatic statement conversion in big data middle platform technology, the problem of data query between different databases is solved, the learning cost is reduced and query efficiency is improved, and the popularization of data middle platform technology is promoted.

CN119441263APending Publication Date: 2025-02-14CHINA PING AN LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411638998.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-15
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

In big data middle platform technology, data exists in different databases and requires different statements to be used for data query, resulting in high learning costs for users and low query efficiency, which hinders the promotion of data middle platform technology.

Method used

By obtaining the first query statement, determining its table name and database name, splicing the table names to be matched, matching the corresponding data table, and using the pre-trained statement conversion model to generate the second query statement, realizing the different statements and different databases between different statements and different databases data query.

Benefits of technology

It reduces the learning cost of users, improves the efficiency of data query, and promotes the promotion of data middle platform technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119441263A_ABST
    Figure CN119441263A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of big data and digital medical treatment. The invention discloses a data query method and device based on automatic statement conversion, equipment and a medium. The method comprises the steps of obtaining a first query statement; determining a table name in the first query statement according to the first query statement; obtaining a table name in the first query statement and a database name corresponding to the first query statement to obtain a to-be-matched table name; matching a data table corresponding to the to-be-matched table name in a to-be-matched database, and replacing the data table corresponding to the first query statement with the data table corresponding to the to-be-matched table name; generating a second query statement according to the first query statement based on a pre-trained statement conversion model; and querying data in a data table corresponding to the to-be-matched table name according to the second query statement. Data query among different statements and different databases is realized, the learning cost of a user is reduced, and the data query efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of big data and digital medical technology, and more specifically, to a data query method, device, equipment and medium based on automatic statement conversion. Background Art

[0002] With the continuous in-depth application of big data technology, data middle platform technology has been increasingly popularized in various Internet companies. Data middle platform technology involves multiple databases, multiple statements, multiple grammars and their mapping relationships, but users (business, testing, development) are usually only familiar with a small part of the multiple databases, multiple statements, multiple grammars and their mapping relationships, which has caused obstacles to the promotion of data middle platform technology and increased the learning cost of users. For example, in the medical field, a large amount of medical imaging data (such as CT, MRI, X-rays), data on the occurrence, spread and control of diseases, clinical trial data, and drug use data will be generated. These data can support disease auxiliary diagnosis, health management, remote consultation and other functions. However, these data exist in different databases and need to use different statements for data query, which brings great inconvenience to users. Summary of the invention

[0003] In view of the above situation, the embodiments of the present application provide a data query method, apparatus, device and medium based on automatic statement conversion, which aims to solve the above problem or at least partially solve the above problem.

[0004] In a first aspect, the present application provides a data query method based on automatic statement conversion, comprising: Get the first query statement; According to the first query statement, determine the table name in the first query statement; Obtaining the table name in the first query statement and the database name corresponding to the first query statement to obtain the table name to be matched; Matching a data table corresponding to the to-be-matched table name in a to-be-matched database, and replacing the data table corresponding to the first query statement with the data table corresponding to the to-be-matched table name; Based on the pre-trained sentence conversion model, generate a second query sentence according to the first query sentence; According to the second query statement, data is queried in the data table corresponding to the table name to be matched.

[0005] Preferably, after obtaining the first query statement, the method includes: Obtaining the grammatical rules of the first query statement, and determining whether the grammar of the first query statement is correct according to the grammatical rules of the first query statement; When the syntax of the first query statement is correct, determining a database table name corresponding to the first query statement; When the syntax of the first query statement is incorrect, a syntax error prompt message is generated.

[0006] Preferably, determining the table name in the first query statement according to the first query statement includes: According to the first query statement, determining a special keyword in the first query statement and a position of the special keyword; Determine the position of the character string to be identified according to the position of the special keyword; According to the position of the to-be-recognized string, obtaining the to-be-recognized string at the position of the to-be-recognized string; Based on a preset table name recognition rule, the table name in the first query statement is determined according to the character string to be recognized.

[0007] Preferably, the acquiring the table name in the first query statement and the database name corresponding to the first query statement to obtain the table name to be matched includes: Obtaining a database name corresponding to the first query statement and a table name in the first query statement; Based on a preset table naming rule, the database name corresponding to the first query statement and the table name in the first query statement are concatenated into a table name to be matched.

[0008] Preferably, matching the data table corresponding to the to-be-matched table name in the to-be-matched database, and replacing the data table corresponding to the first query statement with the data table corresponding to the to-be-matched table name, includes: When a data table corresponding to the to-be-matched table name is matched in the to-be-matched database, the data table corresponding to the to-be-matched table name is used to replace the data table corresponding to the first query statement; When no data table corresponding to the table name to be matched is found in the database to be matched, data tables similar to the table name to be matched are queried, and data tables similar to the table name to be matched are sorted according to similarity to generate query prompt information.

[0009] Preferably, the method further comprises: According to the query prompt information, a data table with a similar name to the table to be matched is determined to replace the data table corresponding to the first query statement based on the instruction.

[0010] Preferably, the pre-trained sentence conversion model generates a second query sentence according to the first query sentence, including: Obtaining the first query statement grammar rule and the to-be-matched table name determined by the first query statement; Based on a preset prompt template, according to the first query statement grammar rule and the to-be-matched table name, a prompt text is generated; Based on a pre-trained sentence conversion model, the second query sentence is generated according to the prompt text.

[0011] In a second aspect, a data query device based on automatic statement conversion is provided, comprising: An acquisition module, used for acquiring a first query statement; A first determining module, configured to determine a table name in the first query statement according to the first query statement; A second determination module is used to obtain the table name in the first query statement and the database name corresponding to the first query statement to obtain the table name to be matched; A replacement module, used for matching a data table corresponding to the to-be-matched table name in the to-be-matched database, and replacing the data table corresponding to the first query statement with the data table corresponding to the to-be-matched table name; A generation module, configured to generate a second query statement according to the first query statement based on a pre-trained statement conversion model; A query module is used to query data in a data table corresponding to the table name to be matched according to the second query statement.

[0012] In a third aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the data query method based on automatic statement conversion as described in the first aspect are implemented.

[0013] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data query method based on automatic statement conversion as described in the first aspect are implemented.

[0014] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects: This application obtains the table name to be matched based on the first query statement and its corresponding database name, matches the data table corresponding to the table name to be matched in the database to be matched, generates the second query statement based on the first query statement based on the pre-trained statement conversion model, and queries data in the data table corresponding to the table name to be matched based on the second query statement. Data query between different statements and different databases is realized, which reduces the learning cost of users, improves the efficiency of data query, and is conducive to the promotion of data middle platform technology. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 It is a schematic diagram of an application environment of a data query method based on automatic statement conversion in one embodiment of the present invention; Figure 2 It is a flow chart of a data query method based on automatic statement conversion in one embodiment of the present invention; Figure 3 It is a structural schematic diagram of a data query device based on automatic sentence conversion in one embodiment of the present invention; Figure 4 is a schematic diagram of a structure of a computer device in one embodiment of the present invention; Figure 5 It is another structural schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION

[0016] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0017] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that such use is interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the term "including" and its variants are to be interpreted as open-ended terms meaning "including but not limited to".

[0018] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.

[0019] As described above, currently when data exists in different databases and different statements are needed to query data, it brings great inconvenience to users. In order to solve this technical problem, the embodiment of the present application provides a data query method based on automatic statement conversion.

[0020] The data query method based on automatic statement conversion provided by the embodiment of the present invention can be applied in the following aspects: Figure 1In an application environment, the device communicates with the server through a network. The server can obtain a first query statement through the device; determine the table name in the first query statement according to the first query statement; obtain the table name in the first query statement and the database name corresponding to the first query statement to obtain the table name to be matched; match the data table corresponding to the table name to be matched in the database to be matched, and replace the data table corresponding to the first query statement with the data table corresponding to the table name to be matched; generate a second query statement according to the first query statement based on a pre-trained statement conversion model; query data in the data table corresponding to the table name to be matched according to the second query statement. The present application obtains the table name to be matched according to the first query statement and its corresponding database name, matches the data table corresponding to the table name to be matched in the database to be matched, generates a second query statement according to the first query statement based on a pre-trained statement conversion model, and queries data in the data table corresponding to the table name to be matched according to the second query statement. Data query between different statements and different databases is realized, which reduces the learning cost of users, improves the efficiency of data query, and is conducive to the promotion of data middle platform technology.

[0021] The device side may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices. The server side may be implemented by an independent server or a server cluster consisting of multiple servers. The present invention is described in detail below through specific embodiments.

[0022] See also Figure 2 As shown, Figure 2 A flow chart of a data query method based on automatic statement conversion provided by an embodiment of the present invention includes the following steps: S10: Obtain a first query statement; specifically, the first query statement is a statement before conversion, the first query statement and the converted statement are of different types and located in different databases. For example, the first query statement is a SQL statement, located in a first database, and specifically the first database is a relational database.

[0023] Further, after obtaining the first query statement in step S10, the method includes: S11: Acquire the grammatical rules of the first query statement, and determine whether the grammar of the first query statement is correct according to the grammatical rules of the first query statement; S12: When the syntax of the first query statement is correct, determine the database table name corresponding to the first query statement according to the first query statement; When the syntax of the first query statement is incorrect, a syntax error prompt message is generated.

[0024] Specifically, different statements have different grammatical rules. For example, the grammar corresponding to the sql statement includes but is not limited to mysql, pgsql, sqlServer, oracle, etc. In this embodiment, different grammatical rules corresponding to different statements are pre-set. After the first query statement is input, the grammatical rule corresponding to the first query statement can be selected based on the user instruction. For example, when it is necessary to query and analyze the patient's medical data, including treatment effects and drug reactions, data query is required. When the first query statement input is "sql: Select * from act_test_check limit 1;", the oracle grammar rule is selected based on the user instruction. At this time, the server checks the first query statement based on the oracle grammar rule, and a grammatical error prompt message will be displayed: [ORA-00933: SQL command did not end correctly, please adjust the statement]. When the first query statement input is "sql: Select * from act_test_check;", the oracle grammar rule is selected based on the user instruction. The server checks the first query statement based on the oracle grammar rule, determines that the grammar is correct, and automatically proceeds to step S20.

[0025] S20: Determine a table name in the first query statement according to the first query statement; Specifically, according to the grammatical rules of the query statements, table name extraction rules in the query statements under different grammatical rules are pre-set.

[0026] Specifically, step S20 includes: S21: determining, according to the first query statement, a special keyword in the first query statement and a position of the special keyword; Specifically, a special keyword database is pre-set, the first query statement is segmented, multiple fields and the position of each field are obtained, multiple fields are traversed, each field is queried in the special keyword database, and the queried field is the special keyword of the first query statement, and then the position of the special keyword is obtained. For example, the special keywords in the SQL statement include FROM, JOIN, LEFT JOIN, RIGHT JOIN, INNER JOIN, OUTER JOIN, etc. These special keywords are usually followed by table names or subqueries. After the special keyword is determined, the position of the special keyword can be determined.

[0027] S22: Determine the position of the character string to be identified according to the position of the special keyword; Specifically, the position of the character string to be identified is the position next to the position of the special keyword.

[0028] S23: according to the position of the to-be-recognized string, obtaining the to-be-recognized string at the position of the to-be-recognized string; Specifically, the character string to be recognized at the next position of the position of the special keyword is obtained.

[0029] S24: Based on a preset table name recognition rule, determine the table name in the first query statement according to the character string to be recognized.

[0030] Specifically, if the string to be identified consists of letters, numbers, and underscores, does not start with a number, and is not a SQL syntax keyword, then the string to be identified is a table name.

[0031] Alternatively, if the string to be identified is not a SQL syntax keyword, a left bracket, or other special characters, it is considered to be a table name.

[0032] S30: Obtain the table name in the first query statement and the database name corresponding to the first query statement to obtain the table name to be matched; Specifically, according to a preset table naming rule, the table name in the first query statement and the database name corresponding to the first query statement are concatenated into a table name to be matched.

[0033] Specifically, step S30 includes: S31: Obtain a database name corresponding to the first query statement and a table name in the first query statement; S32: Based on a preset table naming rule, concatenate the database name corresponding to the first query statement and the table name in the first query statement into a table name to be matched.

[0034] Specifically, the pre-set table naming rules are formulated according to the table name naming rules of the corresponding database after the statement conversion. For example, the first query statement is a SQL statement, and the corresponding database is a relational database; the statement after the first query statement is converted is a hive SQL statement, and the corresponding database is an ODS layer source database; then, the pre-set table naming rules are the table name naming rules in the ODS layer source database, for example, the table name to be matched is: jt_ods_relational database name. The table name in the first query statement.

[0035] S40: matching a data table corresponding to the to-be-matched table name in the to-be-matched database, and replacing the data table corresponding to the first query statement with the data table corresponding to the to-be-matched table name; Specifically, step S40 includes: When a data table corresponding to the table name to be matched is found in the database to be matched, the data table corresponding to the first query statement is replaced with the data table corresponding to the table name to be matched; here it is 100% The similarity.

[0036] When the data table corresponding to the table name to be matched is not matched in the database to be matched, the data table similar to the table name to be matched is queried, and the data tables similar to the table name to be matched are sorted according to the similarity, and query prompt information is generated. Specifically, the table name to be matched and the table name in the database to be matched are matched one by one. When matching, the table name to be matched and the table name in the database to be matched are respectively divided into multiple fields, each field is matched respectively, and the matching degree is calculated. According to the matching degree, the data table similar to the table name to be matched is obtained, and the queried data tables similar to the table name to be matched are sorted from high to low according to the similarity, and query prompt information is generated and displayed to the user.

[0037] The query prompt information includes a data table similar to the table name to be matched that is queried according to similarity from high to low, whether the table does not exist, etc.

[0038] Further, according to the query prompt information, a data table similar to the table name to be matched is determined based on the instruction to replace the data table corresponding to the first query statement. Specifically, the user can select one of the data tables similar to the table name to be matched that are queried from high to low in terms of similarity to replace the data table corresponding to the first query statement. If the user clicks on an option that does not exist, the conversion is exited and a prompt is given that there is no corresponding mapping table in the ODS layer.

[0039] S50: Based on the pre-trained sentence conversion model, a second query sentence is generated according to the first query sentence. The pre-trained sentence conversion model can automatically realize sentence conversion, and also realizes the optimization of the enemy query sentence, ensuring the efficient operation performance of the second query sentence.

[0040] Specifically, step S50 includes: S51: Acquire the grammatical rule of the first query statement and the name of the table to be matched determined by the first query statement; S52: Generate a prompt text based on a preset prompt template, according to the first query statement grammar rule and the table name to be matched; S53: Based on the pre-trained sentence conversion model, generate the second query sentence according to the prompt text.

[0041] Specifically, in this embodiment, the pre-trained sentence conversion model is trained based on a natural language model, such as BLOOM, GPT-J, GPT-2, etc. The pre-trained sentence conversion model in this embodiment is a large language model based on the Transformer architecture. The training data comes from various online SQL projects in actual business. It is trained through large-scale parallel computing, aiming to understand the syntax of various types of SQL projects, so as to convert and optimize various types of SQL statements.

[0042] Specifically, a prompt template is a predefined text framework used to quickly generate standardized responses or messages in a specific context or scenario. In this implementation, a sql statement is converted into a hive sql statement, for example: Please help convert (grammar field) sql: Select * from (table name field); statement into a usable and optimized hive sql statement. Specifically, the first query statement grammar rule is filled into the "grammar field", and the table name to be matched is filled into the "table name field" to generate a prompt text. For example, when the first query statement is: "sql: Select * from act_test_check;", the first query statement grammar rule is: oracle grammar, the table name in the first query statement is: act_test_check, and the table name to be matched is: jt_ods_relational database name. act_test_check, and the generated prompt text is: "Please help convert the oracle syntax sql: Select * from jt_ods_relational database name. act_test_check; statement into a usable and optimized hive sql statement".

[0043] S60: Query data in a data table corresponding to the table name to be matched according to the second query statement.

[0044] In one embodiment, the second query statement may be used to directly query data in a corresponding database. For example, the second query statement may directly query required data in an ods layer source database.

[0045] Alternatively, in one embodiment, the second query statement can be displayed in the user interface, and the user manually enters the second query statement into the corresponding database to perform data query, for example, copying the second query statement in the user interface and pasting the second query statement into the ODS layer source database to query the required data.

[0046] It can be seen that in the above scheme, the present application obtains the table name to be matched according to the first query statement and its corresponding database name, and matches the data table corresponding to the table name to be matched in the database to be matched, generates the second query statement according to the first query statement based on the pre-trained statement conversion model, and queries data in the data table corresponding to the table name to be matched according to the second query statement. Data query between different statements and different databases is realized, which reduces the learning cost of users, improves the efficiency of data query, and is conducive to the promotion of data middle platform technology.

[0047] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

[0048] In one embodiment, a data query device based on automatic statement conversion is provided, and the data query device based on automatic statement conversion corresponds one-to-one to the data query method based on automatic statement conversion in the above embodiment. Figure 3 As shown, the data query device based on automatic statement conversion includes an acquisition module 101, a first determination module 102, a second determination module 103, a replacement module 104, a generation module 105, and a query module 106. The functional modules are described in detail as follows: An acquisition module 101 is used to acquire a first query statement; A first determining module 102, configured to determine a table name in the first query statement according to the first query statement; The second determination module 103 is used to obtain the table name in the first query statement and the database name corresponding to the first query statement to obtain the table name to be matched; A replacement module 104 is used to match a data table corresponding to the to-be-matched table name in the to-be-matched database, and replace the data table corresponding to the first query statement with the data table corresponding to the to-be-matched table name; A generating module 105, configured to generate a second query statement according to the first query statement based on a pre-trained statement conversion model; The query module 106 is used to query data in the data table corresponding to the table name to be matched according to the second query statement.

[0049] The acquisition module 101 is further used to: The first query statement grammar rule is obtained.

[0050] The data query device based on automatic statement conversion also includes a checking module 107, which is used to: Determining whether the syntax of the first query statement is correct according to the syntax rule of the first query statement; When the syntax of the first query statement is correct, determining a database table name corresponding to the first query statement; When the syntax of the first query statement is incorrect, a syntax error prompt message is generated.

[0051] The first determining module 102 is further configured to: According to the first query statement, determining a special keyword in the first query statement and a position of the special keyword; Determine the position of the character string to be identified according to the position of the special keyword; According to the position of the to-be-recognized string, obtaining the to-be-recognized string at the position of the to-be-recognized string; Based on a preset table name recognition rule, the table name in the first query statement is determined according to the character string to be recognized.

[0052] The second determining module 103 is further configured to: Obtaining a database name corresponding to the first query statement and a table name in the first query statement; Based on a preset table naming rule, the database name corresponding to the first query statement and the table name in the first query statement are concatenated into a table name to be matched.

[0053] The replacement module 104 is also used to: When a data table corresponding to the to-be-matched table name is matched in the to-be-matched database, the data table corresponding to the to-be-matched table name is used to replace the data table corresponding to the first query statement; When no data table corresponding to the table name to be matched is found in the database to be matched, data tables similar to the table name to be matched are queried, and data tables similar to the table name to be matched are sorted according to similarity to generate query prompt information.

[0054] The replacement module 104 is also used to: According to the query prompt information, a data table with a similar name to the table to be matched is determined to replace the data table corresponding to the first query statement based on the instruction.

[0055] The generating module 105 is further used for: Obtaining the first query statement grammar rule and the to-be-matched table name determined by the first query statement; Based on a preset prompt template, according to the first query statement grammar rule and the to-be-matched table name, a prompt text is generated; Based on a pre-trained sentence conversion model, the second query sentence is generated according to the prompt text.

[0056] The present invention provides a data query device based on automatic statement conversion. The present application obtains a table name to be matched according to a first query statement and its corresponding database name, matches a data table corresponding to the table name to be matched in the database to be matched, generates a second query statement according to the first query statement based on a pre-trained statement conversion model, and queries data in the data table corresponding to the table name to be matched according to the second query statement. Data query between different statements and different databases is realized, the learning cost of users is reduced, the efficiency of data query is improved, and it is conducive to the promotion of data middle platform technology.

[0057] For the specific definition of the data query device based on automatic statement conversion, please refer to the definition of the data query method based on automatic statement conversion mentioned above, which will not be repeated here. The various modules in the above-mentioned data query device based on automatic statement conversion can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0058] Specifically, in this embodiment, a data query tool based on automatic sentence conversion is also provided, on which the data query device based on automatic sentence conversion as described above is provided, and the data query method based on automatic sentence conversion as described above is adopted. The tool has a user input interface, in which a first query sentence is input, and a grammatical rule of the first query sentence is selected from a drop-down list box. The tool also has a user interface, in which a second query sentence is displayed. The tool also includes a model interface, through which a pre-trained sentence conversion model is connected.

[0059] In this embodiment, users do not need to master hive sql syntax and some complex sql optimization writing methods. The tool can automatically convert sql statements to hive sql statements by combining the self-built LLM large language model (pre-trained statement conversion model), and optimize hive sql statements through debugged prompt templates, ensuring the efficient operation performance of hive sql statements, improving user work efficiency and greatly reducing learning costs. At the same time, users do not need to understand the ODS layer mapping table corresponding to the relational database table, which reduces the user's use cost and improves work efficiency.

[0060] Specifically, the present application is not limited to the conversion of SQL statements to Hive SQL statements. The conversion between any different statements and the data query applied in different databases are all within the protection scope of the present application.

[0061] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external device end through a network connection. When the computer program is executed by the processor, the functions or steps of a data query method based on automatic statement conversion on the server side are realized.

[0062] In one embodiment, a computer device is provided. The computer device may be a device end, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server through a network connection. When the computer program is executed by the processor, the functions or steps of a data query method based on automatic statement conversion on the device side are realized.

[0063] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: Get the first query statement; According to the first query statement, determine the table name in the first query statement; Obtaining the table name in the first query statement and the database name corresponding to the first query statement to obtain the table name to be matched; Matching a data table corresponding to the to-be-matched table name in a to-be-matched database, and replacing the data table corresponding to the first query statement with the data table corresponding to the to-be-matched table name; Based on the pre-trained sentence conversion model, generate a second query sentence according to the first query sentence; According to the second query statement, data is queried in the data table corresponding to the table name to be matched.

[0064] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: Get the first query statement; According to the first query statement, determine the table name in the first query statement; Obtaining the table name in the first query statement and the database name corresponding to the first query statement to obtain the table name to be matched; Matching a data table corresponding to the to-be-matched table name in a to-be-matched database, and replacing the data table corresponding to the first query statement with the data table corresponding to the to-be-matched table name; Based on the pre-trained sentence conversion model, generate a second query sentence according to the first query sentence; According to the second query statement, data is queried in the data table corresponding to the table name to be matched.

[0065] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can refer to the relevant descriptions on the server side and the device side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.

[0066] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0067] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0068] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.

Claims

1. A data query method based on automatic statement conversion, characterized in that: include: Get the first query statement; According to the first query statement, determine the table name in the first query statement; Obtaining the table name in the first query statement and the database name corresponding to the first query statement to obtain the table name to be matched; Matching a data table corresponding to the to-be-matched table name in a to-be-matched database, and replacing the data table corresponding to the first query statement with the data table corresponding to the to-be-matched table name; Based on the pre-trained sentence conversion model, generate a second query sentence according to the first query sentence; According to the second query statement, data is queried in the data table corresponding to the table name to be matched.

2. The method according to claim 1, characterized in that After obtaining the first query statement, the method includes: Obtaining the grammatical rules of the first query statement, and determining whether the grammar of the first query statement is correct according to the grammatical rules of the first query statement; When the syntax of the first query statement is correct, determining a database table name corresponding to the first query statement; When the syntax of the first query statement is incorrect, a syntax error prompt message is generated.

3. The method according to claim 1, characterized in that The determining, according to the first query statement, a table name in the first query statement includes: According to the first query statement, determining a special keyword in the first query statement and a position of the special keyword; Determine the position of the character string to be identified according to the position of the special keyword; According to the position of the to-be-recognized string, obtaining the to-be-recognized string at the position of the to-be-recognized string; Based on a preset table name recognition rule, the table name in the first query statement is determined according to the character string to be recognized.

4. The method according to claim 1, characterized in that: The acquiring the table name in the first query statement and the database name corresponding to the first query statement to obtain the table name to be matched includes: Obtaining a database name corresponding to the first query statement and a table name in the first query statement; Based on a preset table naming rule, the database name corresponding to the first query statement and the table name in the first query statement are concatenated into a table name to be matched.

5. The method according to claim 1, characterized in that The step of matching a data table corresponding to the to-be-matched table name in the to-be-matched database and replacing the data table corresponding to the first query statement with the data table corresponding to the to-be-matched table name includes: When a data table corresponding to the to-be-matched table name is matched in the to-be-matched database, the data table corresponding to the to-be-matched table name is used to replace the data table corresponding to the first query statement; When no data table corresponding to the table name to be matched is found in the database to be matched, data tables similar to the table name to be matched are queried, and data tables similar to the table name to be matched are sorted according to similarity to generate query prompt information.

6. The method according to claim 5, characterized in that The method further comprises: According to the query prompt information, a data table with a similar name to the table to be matched is determined to replace the data table corresponding to the first query statement based on the instruction.

7. The method according to claim 1, characterized in that The pre-trained sentence conversion model is used to generate a second query sentence according to the first query sentence, including: Obtaining the first query statement grammar rule and the to-be-matched table name determined by the first query statement; Based on a preset prompt template, according to the first query statement grammar rule and the to-be-matched table name, a prompt text is generated; Based on a pre-trained sentence conversion model, the second query sentence is generated according to the prompt text.

8. A data query device based on automatic statement conversion, characterized in that: include: An acquisition module, used for acquiring a first query statement; A first determining module, configured to determine a table name in the first query statement according to the first query statement; A second determination module is used to obtain the table name in the first query statement and the database name corresponding to the first query statement to obtain the table name to be matched; A replacement module, used for matching a data table corresponding to the to-be-matched table name in the to-be-matched database, and replacing the data table corresponding to the first query statement with the data table corresponding to the to-be-matched table name; A generation module, configured to generate a second query statement according to the first query statement based on a pre-trained statement conversion model; A query module is used to query data in a data table corresponding to the table name to be matched according to the second query statement.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the data query method based on automatic statement conversion as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the data query method based on automatic statement conversion as described in any one of claims 1 to 7 are implemented.