Database query method and device, equipment and storage medium

By receiving a database query request containing template identification and query configuration information, obtaining the target query template and generating the target query statement, the problem of increasing development costs caused by different query conditions of different business parties is solved, and the general processing of query requests of different business parties is realized, and the development costs are reduced.

CN119557329APending Publication Date: 2025-03-04BEIJING YOUZHUJU NETWORK TECH CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202411610396.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-12
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

Since the query conditions of different business parties are different, the existing technology requires each requesting party to develop query logic code that meets their respective query conditions, resulting in a gradual increase in development costs.

Method used

Provide a database query method, by receiving a database query request containing template identification and query configuration information, obtaining a target query template from the template library based on the template identification, and generating a target query statement for the target database based on the target query template and query configuration information, and finally executing the statement to obtain the query result.

Benefits of technology

This method can generalize the processing of database query requests from different business parties, reducing development costs and avoiding the need to develop query logic code separately for each business party.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119557329A_ABST
    Figure CN119557329A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to a database query method and device, equipment and a storage medium, and the method comprises the steps that a database query request comprising template identification and query configuration information is received, the template identification is used for identifying a target query template, and the query configuration information comprises information for query parameter configuration in the target query template; obtaining a target query template from a template library based on the template identifier; generating a target query statement of the target database based on the target query template and the query configuration information; and executing the target query statement for the target database to obtain a query result corresponding to the database query request. Therefore, according to the database query method provided by the embodiment of the invention, when the database query requests from different business parties are received, the corresponding target query statements can be generated based on the query configuration information in the database query requests and the target query templates corresponding to the template identifiers, and the target query statements are used for processing the database query requests.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of database query, and in particular to a database query method, device, equipment and storage medium. Background Art

[0002] Database query refers to the process of requesting data that meets the query conditions from the database. At present, since the query conditions of different business parties are different, it is necessary to develop query logic codes that meet the query conditions for each requester, so as to process the database query requests from different requesters by executing their respective query logic codes.

[0003] Obviously, as more and more business parties are connected, the development cost of the above-mentioned method of developing query logic codes that meet the respective query conditions for different request parties is getting higher and higher. Summary of the invention

[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a database query method, device, equipment and storage medium.

[0005] In a first aspect, an embodiment of the present disclosure provides a database query method, the method comprising:

[0006] Receive a database query request; wherein the database query request includes a template identifier and query configuration information, the template identifier is used to identify a target query template, the target query template is used to generate a target query statement of a target database, and the query configuration information includes information for query parameter configuration in the target query template;

[0007] Acquire the target query template from a template library based on the template identifier; wherein the template library includes at least one predefined query template;

[0008] Based on the target query template and the query configuration information, generating a target query statement for the target database;

[0009] The target query statement is executed on the target database to obtain a query result corresponding to the database query request.

[0010] In an optional implementation, the target query template includes a predefined data type corresponding to the first query parameter, and generating a target query statement for the target database based on the target query template and the query configuration information includes:

[0011] Determining whether the configuration information corresponding to the first query parameter in the query configuration information belongs to the data type corresponding to the first query parameter;

[0012] If it is determined that the configuration information corresponding to the first query parameter belongs to the data type, adding the configuration information corresponding to the first query parameter to the target query template to obtain a processed query template;

[0013] A target query statement for the target database is generated based on the processed query template.

[0014] In an optional implementation manner, the target query template includes a placeholder corresponding to the first query parameter, and adding the configuration information corresponding to the first query parameter to the target query template to obtain a processed query template includes:

[0015] The configuration information corresponding to the first query parameter is used to replace the placeholder corresponding to the first query parameter in the target query template to obtain a processed query template.

[0016] In an optional implementation manner, generating a target query statement of the target database based on the target query template and the query configuration information includes:

[0017] Determine the database type of the target database corresponding to the target query template;

[0018] A target query statement corresponding to the database type is generated based on the target query template and the query configuration information.

[0019] In an optional implementation manner, the method further includes:

[0020] In response to an access operation to a first database, a query template of the first database is acquired, and the query template of the first database is added to the template library.

[0021] In an optional implementation manner, the database query request further includes a service identifier, and before acquiring the target query template from the template library based on the template identifier, the step further includes:

[0022] Determining whether the pre-configured authentication information includes a correspondence between the service identifier and the template identifier; wherein the authentication information includes a pre-configured service identifier of a service node having access rights to the query template corresponding to the template identifier;

[0023] Correspondingly, acquiring the target query template from a template library based on the template identifier includes:

[0024] If it is determined that the authentication information includes a correspondence between the service identifier and the template identifier, the target query template is acquired from a template library based on the template identifier.

[0025] In an optional implementation manner, before acquiring the target query template from the template library based on the template identifier, the method further includes:

[0026] In response to the database query request, determining whether the database query request meets a preset current limiting condition;

[0027] Correspondingly, acquiring the target query template from a template library based on the template identifier includes:

[0028] If the database query request does not meet the preset current limiting condition, the target query template is obtained from a template library based on the template identifier.

[0029] In an optional implementation manner, after executing the target query statement on the target database to obtain the query result corresponding to the database query request, the method further includes:

[0030] The query result is formatted to obtain a query result in a target format, and the query result in the target format is returned in response to the database query request.

[0031] In a second aspect, the present disclosure provides a database query device, the device comprising:

[0032] A receiving module, configured to receive a database query request; wherein the database query request includes a template identifier and query configuration information, the template identifier is used to identify a target query template, the target query template is used to generate a target query statement for a target database, and the query configuration information includes information configured for query parameters in the target query template;

[0033] A first acquisition module, configured to acquire the target query template from a template library based on the template identifier; wherein the template library includes at least one predefined query template;

[0034] A generating module, configured to generate a target query statement of the target database based on the target query template and the query configuration information;

[0035] The execution module is used to execute the target query statement on the target database to obtain the query result corresponding to the database query request.

[0036] In a third aspect, an embodiment of the present disclosure further provides an electronic device, comprising: a processor; a memory for storing executable instructions of the processor; the processor is used to read the executable instructions from the memory and execute the instructions to implement a database query method as provided in an embodiment of the present disclosure.

[0037] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is used to execute the database query method provided by the embodiment of the present disclosure.

[0038] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has the following advantages:

[0039] In the database query method provided by the embodiment of the present disclosure, a database query request including a template identifier and query configuration information is received, wherein the template identifier is used to identify a target query template, and the query configuration information includes information for query parameter configuration in the target query template; the target query template is obtained from a template library based on the template identifier; a target query statement for a target database is generated based on the target query template and the query configuration information; the target query statement is executed on the target database to obtain a query result corresponding to the database query request.

[0040] The database query method provided by the embodiment of the present disclosure can, when receiving database query requests from different business parties, generate corresponding target query statements based on the query configuration information in the database query request and the target query template corresponding to the template identifier, for processing the database query request. It can be seen that the present disclosure can process database query requests from different business parties through a universal database query method. Compared with the method of developing query logic codes that meet the respective query conditions for different requesting parties, the database query method provided by the embodiment of the present disclosure can reduce development costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.

[0042] Figure 1 A flowchart of a database query method provided by an embodiment of the present disclosure;

[0043] Figure 2 A flowchart of a database query process provided by an embodiment of the present disclosure;

[0044] Figure 3 A schematic diagram of the structure of a database query device provided by an embodiment of the present disclosure;

[0045] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0046] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0047] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0048] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0049] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0050] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0051] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0052] Currently, since query conditions of different business parties are different, it is necessary to develop query logic codes that meet the respective query conditions for each requester, so as to process database query requests from different requesters by executing the respective query logic codes.

[0053] Obviously, as more and more business parties are connected, the development cost of the above method of developing query logic codes that meet the respective query conditions for different request parties is getting higher and higher.

[0054] Therefore, an embodiment of the present disclosure provides a database query method, specifically, receiving a database query request including a template identifier and query configuration information, wherein the template identifier is used to identify a target query template, and the query configuration information includes information for query parameter configuration in the target query template; obtaining the target query template from a template library based on the template identifier; generating a target query statement for a target database based on the target query template and the query configuration information; executing the target query statement on the target database to obtain a query result corresponding to the database query request.

[0055] The database query method provided by the embodiment of the present disclosure can, when receiving database query requests from different business parties, generate corresponding target query statements based on the query configuration information in the database query request and the target query template corresponding to the template identifier, for processing the database query request. It can be seen that the present disclosure can process database query requests from different business parties through a universal database query method. Compared with the method of developing query logic codes that meet the respective query conditions for different requesting parties, the database query method provided by the embodiment of the present disclosure can reduce development costs.

[0056] Based on this, an embodiment of the present disclosure provides a database query method, which is introduced below in conjunction with a specific embodiment.

[0057] Figure 1 The following is a flow chart of a database query method provided by an embodiment of the present disclosure. The method can be executed by a database query device, wherein the device can be implemented by software and / or hardware and can generally be integrated in an electronic device. Figure 1 As shown, the method includes:

[0058] S101: receiving a database query request.

[0059] The database query request includes a template identifier and query configuration information, wherein the template identifier is used to identify a target query template, the target query template is used to generate a target query statement for a target database, and the query configuration information includes information on query parameter configuration in the target query template.

[0060] The database query method provided in the embodiment of the present disclosure can be applied to any system or service that supports database query, such as a retrieval system, etc. Exemplarily, the query service in the retrieval system can use the database query method provided in the embodiment of the present disclosure to process database query requests from different business parties or different business nodes to obtain query results corresponding to the database query requests.

[0061] In the embodiment of the present disclosure, the database query request may include a template identifier and query configuration information, wherein the template identifier is used to identify a target query template, and the target query template may be, for example, a query template implemented based on a target programming language.

[0062] The target query template is used to generate a target query statement for a target database, where the target database refers to a database that the retrieval system has access to, and may include, for example, a relational database, a non-relational database, a graph database, etc. Specifically, a relational database usually stores data based on a table structure, and a graph database stores data based on a graph structure.

[0063] In the disclosed embodiment, the query configuration information includes information for query parameter configuration in the target query template. The query parameters in the target query template can be configured based on the customized requirements of the business party. For example, assuming that the target query template predefines a query parameter for querying the average score of a class, a placeholder can be used to represent the query parameter. After the business party configures the corresponding field information for the query parameter, the query configuration information can be obtained, such as querying the average score of Class A.

[0064] In actual applications, after receiving the customized query template, the business party can display the query parameters in the target query template to the user through the parameter configuration page, and after receiving the user's configuration information for the query parameters (i.e., query configuration information), send a database query request to the query service based on the template identifier and query configuration information of the target query template.

[0065] S102: Acquire the target query template from a template library based on the template identifier; wherein the template library includes at least one predefined query template.

[0066] In practical applications, at least one query template may be pre-defined in the template library, or at least one query template may be pre-configured for different business parties. Each query template corresponds to a template identifier for uniquely identifying the query template.

[0067] In the embodiment of the present disclosure, after receiving a database query request carrying a template identifier and query configuration information, a query template corresponding to the template identifier is determined from at least one query template in a template library as a target query template.

[0068] In an optional implementation, in response to the access operation of the first database, the query template of the first database can be obtained and the query template of the first database can be added to the template library. The first database can be any type of database.

[0069] For example, assuming that the query service has been connected to a relational database or a Mongo database, that is, the query service already supports queries on the above-mentioned types of databases, there is no need to perform repetitive development when subsequently connecting to the above-mentioned types of databases. Instead, the query template of the first database can be obtained in a configured manner, thereby improving the database access efficiency.

[0070] S103: Generate a target query statement of the target database based on the target query template and the query configuration information.

[0071] In actual applications, since the query configuration information is the information configured by the business party for the query parameters in the target query template, it can only be used to characterize the business party's query requirements for the target database, but cannot be directly used to request the target database. Therefore, after obtaining the target query template based on the template identifier in the database query request, an executable target query statement can also be generated based on the target query template and the query configuration information.

[0072] Specifically, the target query template is first rendered using the query configuration information to obtain a configuration file containing the target query template and the query configuration information, such as a text type configuration file; the configuration file is then converted to obtain an executable target query statement, so that the query result corresponding to the database query request can be obtained by subsequently executing the target query statement.

[0073] In an optional implementation, since different types of databases support different query statements, for example, relational databases generally support queries based on standard SQL syntax, and MongoDB generally supports queries based on JSON query syntax, etc., when generating a target query statement for a target database, the database type of the target database also needs to be considered. Specifically, after obtaining a target query template based on a template identifier in a database query request, first determine the database type of the target database corresponding to the target query template, and then generate a target query statement corresponding to the database type based on the target query template and query configuration information.

[0074] Exemplarily, after obtaining the target query template, the database type of the target database configured in the target query template is first determined. Assuming that the database type of the target database is a relational database, in the process of generating a target query statement based on the target query template and query configuration information, the standard SQL query syntax can be used to generate a corresponding target query statement for the target database, that is, an SQL statement.

[0075] S104: Execute the target query statement on the target database to obtain a query result corresponding to the database query request.

[0076] In the disclosed embodiment, after a target query statement for a target database is generated, the target query statement is executed for the target database to query the data in the target database and obtain a query result corresponding to the database query request.

[0077] In an optional implementation, after obtaining the query result corresponding to the database query request, the query result may be formatted to obtain a query result in a target format, that is, a query result in a unified format, and the query result in the target format is returned for the database query request.

[0078] In the database query method provided by the embodiment of the present disclosure, a database query request including a template identifier and query configuration information is first received, wherein the template identifier is used to identify a target query template, and the query configuration information includes information for configuring query parameters in the target query template; then, the target query template is obtained from a template library based on the template identifier; then, based on the target query template and the query configuration information, a target query statement for the target database is generated; and further, the target query statement is executed on the target database to obtain a query result corresponding to the database query request.

[0079] The database query method provided by the embodiment of the present disclosure, when receiving database query requests from different business parties, can generate corresponding target query statements based on the query configuration information in the database query request and the target query template corresponding to the template identifier, for processing the database query request. It can be seen that the present disclosure can process database query requests from different business parties through a universal database query method. Compared with the method of processing database query requests from different business parties by developing processing logic codes for each business party respectively, the database query method provided by the embodiment of the present disclosure can reduce development costs.

[0080] In an optional implementation, the target query template further includes a predefined data type corresponding to the first query parameter, wherein the first query parameter may be any query parameter defined in the target query template.

[0081] In actual applications, by specifying a specific data type for the first query parameter in the target query template, the business party can configure field information for the first query parameter according to the data type corresponding to the first query parameter to obtain configuration information of the specified data type.

[0082] In the embodiment of the present disclosure, since the target query template includes a pre-defined data type corresponding to the first query parameter, before generating the target query statement of the target database, the data type of the configuration information corresponding to the first query parameter can also be verified, and when it is determined that the configuration information corresponding to the first query parameter passes the data type verification, the configuration information corresponding to the first query parameter is added to the target query template to obtain a processed query template.

[0083] Specifically, first determine whether the configuration information corresponding to the first query parameter in the query configuration information belongs to the data type corresponding to the first query parameter; if it is determined that the configuration information corresponding to the first query parameter belongs to the data type corresponding to the first query parameter, add the configuration information corresponding to the first query parameter to the target query template to obtain a processed query template; then generate a target query statement for the target database based on the processed query template.

[0084] Since the embodiment of the present disclosure pre-specifies the corresponding data type for the first query parameter in the query configuration information, after receiving the database query request containing the query configuration information, it is first determined whether the data type of the configuration information corresponding to the first query parameter belongs to the data type defined in the target query template. If it is determined that the configuration information corresponding to the first query parameter belongs to the data type defined in the target query template, it means that the configuration information corresponding to the first query parameter passes the data type verification. At this time, the configuration information corresponding to the first query parameter is added to the target query template.

[0085] In an optional implementation, if it is determined that the configuration information corresponding to the first query parameter does not belong to the data type defined in the target query template, that is, the configuration information corresponding to the first query parameter does not pass the data type verification, a prompt message to reconfigure the first query parameter can be sent to the business party.

[0086] In the disclosed embodiment, after adding configuration information corresponding to the first query parameter of the specified data type to the target query template to obtain the processed query template, a target query statement of the target database is generated based on the processed query template.

[0087] In an optional implementation, the target query template also includes a placeholder corresponding to the first query parameter, so the processed query template can be obtained by replacing the placeholder. Specifically, the placeholder corresponding to the first query parameter in the target query template is replaced with the configuration information corresponding to the first query parameter to obtain the processed query template.

[0088] In an embodiment of the present disclosure, when it is determined that the configuration information corresponding to the first query parameter belongs to the data type defined in the target query template, the configuration information corresponding to the first query parameter is added to the target query template by replacing the placeholder corresponding to the first query parameter with the configuration information corresponding to the first query parameter to obtain a processed query template to generate a target query statement for the target database.

[0089] In an optional implementation, the database query request also includes a business identifier, wherein the business identifier can be used to identify a business node, specifically, the business node can include a business party, and accordingly, the business identifier can be used to identify the business party. In addition, since a business party can support multiple different business functions, the business node can also include any one of the business functions in the business party, and accordingly, the business identifier can also be used to identify the business function in the business party.

[0090] In the embodiment of the present disclosure, after receiving a database query request including a template identifier, query configuration information and a service identifier, before obtaining a target query template from a template library based on the template identifier in the database query request, it is first determined whether the pre-configured authentication information includes a correspondence between the service identifier and the template identifier; if it is determined that the authentication information includes a correspondence between the service identifier and the template identifier, the target query template is obtained from the template library based on the template identifier.

[0091] The authentication information includes the service identifier of the service node that has access rights to the query template corresponding to the template identifier. Exemplarily, assuming that the authentication information is configured with a correspondence between query template A and service node 1 and service node 2, it means that service node 1 and service node 2 have the right to access query template A, and assuming that the authentication information is configured with a correspondence between query template B and service node 3, it means that service node 3 has the right to access query template B. When a database query request is received, assuming that the database query request includes identification information such as query template B and service node 3, by querying the above authentication information, it can be determined that service node 3 has the right to access query template B, and the target query template is obtained from the template database based on the template identifier.

[0092] In actual applications, if there are many query requests for the target database in a short period of time, the target database may not be able to respond, thus affecting the operation of the entire query service. Therefore, in order to ensure the normal response of the target database, the number of database query requests can also be limited.

[0093] Specifically, when a database query request is received, it is first determined whether the database query request meets the preset flow limiting condition. The preset flow limiting condition may include limiting the query requests per second for each business party, for example, the number of database query requests sent by business party A within one second does not exceed 10, and the preset flow limiting condition may also include limiting the query requests for the entire target database, for example, the number of concurrent query requests for the entire target database does not exceed 1000.

[0094] If the database query request does not meet the preset current limiting condition, the target query template is obtained from the template library based on the template identifier, and the target query statement of the target database is generated based on the target query template and the query configuration information. By executing the target query statement, the query result corresponding to the database query request is obtained.

[0095] The embodiment of the present disclosure limits the number of database query requests, thereby preventing too many query requests from requesting the target database in a short period of time, thereby ensuring the normal response of the target database.

[0096] like Figure 2 As shown, it is a flowchart of a database query processing provided by an embodiment of the present disclosure. Exemplarily, before processing a database query request, at least one query template is pre-defined in a template library, and a business identifier of a business node having access rights to the query template corresponding to the template identifier is pre-configured, and a corresponding preset current limiting condition is configured for the target database.

[0097] When receiving a database query request from a business party, first determine whether the database query request meets the preset flow limiting condition; wherein the database query request includes a template identifier, a business identifier and query configuration information, and the business identifier is used to identify the business party.

[0098] If it is determined that the database query request does not meet the preset flow limiting condition, it is determined whether the pre-configured authentication information contains the correspondence between the business identifier and the target identifier. If it is determined that the authentication information contains the correspondence between the business identifier and the template identifier, it means that the business party corresponding to the business identifier has the authority to access the query template corresponding to the template identifier. At this time, the target query template is obtained from the template library based on the template identifier.

[0099] After obtaining the target query template, the target query template is rendered using the query configuration information to obtain a configuration file that contains both the target query template and the query configuration information, and then the configuration file is converted to obtain an executable target query statement; wherein the target query statement is used to perform query operations on the target database.

[0100] Execute the target query statement on the target database, obtain the query result corresponding to the target query request, format the query result to obtain the query result in the target format, and return the query result in the target format for the database query request, that is, send the query result in the target format to the business party.

[0101] It can be seen that the embodiment of the present disclosure can generate a target query statement based on the query configuration information, the service identifier and the query template corresponding to the template identifier, and obtain the query result corresponding to the database query request by executing the target query statement.

[0102] In order to implement the above embodiment, the present disclosure also proposes a database query device. Figure 3 This is a schematic diagram of the structure of a database query device provided by an embodiment of the present disclosure. The device can be implemented by software and / or hardware and can generally be integrated into an electronic device. Figure 3 As shown, the device comprises:

[0103] The receiving module 301 is used to receive a database query request; wherein the database query request includes a template identifier and query configuration information, the template identifier is used to identify a target query template, the target query template is used to generate a target query statement of a target database, and the query configuration information includes information for query parameter configuration in the target query template;

[0104] A first acquisition module 302 is used to acquire the target query template from a template library based on the template identifier; wherein the template library includes at least one predefined query template;

[0105] A generating module 303, configured to generate a target query statement for the target database based on the target query template and the query configuration information;

[0106] The execution module 304 is used to execute the target query statement on the target database to obtain the query result corresponding to the database query request.

[0107] In an optional implementation manner, the target query template includes a predefined data type corresponding to the first query parameter, and the generating module includes:

[0108] A first determining submodule, configured to determine whether the configuration information corresponding to the first query parameter in the query configuration information belongs to a data type corresponding to the first query parameter;

[0109] an adding submodule, configured to add the configuration information corresponding to the first query parameter to the target query template to obtain a processed query template if it is determined that the configuration information corresponding to the first query parameter belongs to the data type;

[0110] The first generating submodule is used to generate a target query statement of the target database based on the processed query template.

[0111] In an optional implementation manner, the target query template includes a placeholder corresponding to the first query parameter, and the adding submodule is specifically used to:

[0112] The configuration information corresponding to the first query parameter is used to replace the placeholder corresponding to the first query parameter in the target query template to obtain a processed query template.

[0113] In an optional implementation manner, the generating module includes:

[0114] A second determination submodule, used to determine the database type of the target database corresponding to the target query template;

[0115] The second generating submodule is used to generate a target query statement corresponding to the database type based on the target query template and the query configuration information.

[0116] In an optional implementation, the device further includes:

[0117] The second acquisition module is used to acquire the query template of the first database in response to the access operation of the first database, and add the query template of the first database to the template library.

[0118] In an optional implementation manner, the database query request also includes a service identifier, and the device further includes:

[0119] A first determination module, used to determine whether the pre-configured authentication information includes a correspondence between the service identifier and the template identifier; wherein the authentication information includes a pre-configured service identifier of a service node having access rights to the query template corresponding to the template identifier;

[0120] Accordingly, the first acquisition module includes:

[0121] The first acquisition submodule is configured to acquire the target query template from a template library based on the template identifier if it is determined that the authentication information includes a correspondence between the service identifier and the template identifier.

[0122] In an optional implementation, the device further includes:

[0123] A second determination module, configured to determine, in response to the database query request, whether the database query request meets a preset current limiting condition;

[0124] Accordingly, the first acquisition module includes:

[0125] The first acquisition submodule is used to acquire the target query template from the template library based on the template identifier if the database query request does not meet the preset current limiting condition.

[0126] In an optional implementation, the device further includes:

[0127] The formatting processing module is used to format the query result to obtain the query result in a target format, and return the query result in the target format in response to the database query request.

[0128] In the database query device provided by the embodiment of the present disclosure, a database query request including a template identifier and query configuration information is received, wherein the template identifier is used to identify the target query template, and the query configuration information includes information for query parameter configuration in the target query template; the target query template is obtained from the template library based on the template identifier; a target query statement for the target database is generated based on the target query template and the query configuration information; the target query statement is executed for the target database to obtain a query result corresponding to the database query request. The database query method provided by the embodiment of the present disclosure, when receiving database query requests from different business parties, can generate corresponding target query statements based on the query configuration information in the database query request and the target query template corresponding to the template identifier, for processing the database query request. It can be seen that the present disclosure can process database query requests from different business parties through a general database query method. Compared with the method of developing query logic codes that meet respective query conditions for different requesting parties, the database query method provided by the embodiment of the present disclosure can reduce development costs.

[0129] In order to implement the above embodiments, the present disclosure further proposes a computer program product, including a computer program / instruction, which implements the database query method in the above embodiments when executed by a processor.

[0130] In addition, the present disclosure also provides a database query device, see Figure 4 As shown, it may include:

[0131] Processor 401, memory 402, input device 403 and output device 404. The number of processors 401 in the database query device can be one or more. Figure 4 In some embodiments of the present disclosure, the processor 401, the memory 402, the input device 403 and the output device 404 may be connected via a bus or other means, wherein: Figure 4 The example of connecting through bus is taken in the following.

[0132] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and database queries of the database query device by running the software programs and modules stored in the memory 402. The memory 402 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc. In addition, the memory 402 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. The input device 403 can be used to receive input digital or character information, and generate signal input related to user settings and function control of the database query device.

[0133] Specifically in this embodiment, the processor 401 will load the executable files corresponding to the processes of one or more applications into the memory 402 according to the following instructions, and the processor 401 will run the applications stored in the memory 402, thereby realizing the various functions of the above-mentioned database query device.

[0134] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0135] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A database query method, characterized in that: include: Receive a database query request; wherein the database query request includes a template identifier and query configuration information, the template identifier is used to identify a target query template, the target query template is used to generate a target query statement of a target database, and the query configuration information includes information for query parameter configuration in the target query template; Acquire the target query template from a template library based on the template identifier; wherein the template library includes at least one predefined query template; Based on the target query template and the query configuration information, generating a target query statement for the target database; The target query statement is executed on the target database to obtain a query result corresponding to the database query request.

2. The method according to claim 1, characterized in that The target query template includes a data type corresponding to a predefined first query parameter, and generating a target query statement for the target database based on the target query template and the query configuration information includes: Determining whether the configuration information corresponding to the first query parameter in the query configuration information belongs to the data type corresponding to the first query parameter; If it is determined that the configuration information corresponding to the first query parameter belongs to the data type, adding the configuration information corresponding to the first query parameter to the target query template to obtain a processed query template; A target query statement for the target database is generated based on the processed query template.

3. The method according to claim 2, characterized in that The target query template includes a placeholder corresponding to the first query parameter, and the configuration information corresponding to the first query parameter is added to the target query template to obtain a processed query template, including: The configuration information corresponding to the first query parameter is used to replace the placeholder corresponding to the first query parameter in the target query template to obtain a processed query template.

4. The method according to claim 1, characterized in that: The generating a target query statement of the target database based on the target query template and the query configuration information includes: Determine the database type of the target database corresponding to the target query template; A target query statement corresponding to the database type is generated based on the target query template and the query configuration information.

5. The method according to claim 1, characterized in that The method further comprises: In response to an access operation to a first database, a query template of the first database is acquired, and the query template of the first database is added to the template library.

6. The method according to claim 1, characterized in that The database query request also includes a service identifier. Before acquiring the target query template from the template library based on the template identifier, the method further includes: Determining whether the pre-configured authentication information includes a correspondence between the service identifier and the template identifier; wherein the authentication information includes a pre-configured service identifier of a service node having access rights to the query template corresponding to the template identifier; Correspondingly, acquiring the target query template from a template library based on the template identifier includes: If it is determined that the authentication information includes a correspondence between the service identifier and the template identifier, the target query template is acquired from a template library based on the template identifier.

7. The method according to claim 1, characterized in that Before acquiring the target query template from the template library based on the template identifier, the method further includes: In response to the database query request, determining whether the database query request meets a preset current limiting condition; Correspondingly, acquiring the target query template from a template library based on the template identifier includes: If the database query request does not meet the preset current limiting condition, the target query template is obtained from a template library based on the template identifier.

8. The method according to claim 1, characterized in that After executing the target query statement on the target database to obtain the query result corresponding to the database query request, the method further includes: The query result is formatted to obtain a query result in a target format, and the query result in the target format is returned in response to the database query request.

9. A database query device, characterized in that: The device comprises: A receiving module, configured to receive a database query request; wherein the database query request includes a template identifier and query configuration information, the template identifier is used to identify a target query template, the target query template is used to generate a target query statement for a target database, and the query configuration information includes information configured for query parameters in the target query template; A first acquisition module, configured to acquire the target query template from a template library based on the template identifier; wherein the template library includes at least one predefined query template; A generating module, configured to generate a target query statement of the target database based on the target query template and the query configuration information; The execution module is used to execute the target query statement on the target database to obtain the query result corresponding to the database query request.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device implements the method according to any one of claims 1 to 8.

11. A database query device, characterized in that: include: 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 method according to any one of claims 1 to 8 is implemented.

12. A computer program product, characterized in that The computer program product comprises a computer program / instruction, and when the computer program / instruction is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Cited By

  • Data query method and device based on interface generation, equipment and medium

    CN120873072A

  • Data query method, device and equipment based on interface generation and medium

    CN120873072B

  • Data query method and device, computer equipment and storage medium

    CN121301376A