Network data query method, system, electronic device and storage medium

By creating a mapping relationship between the queryer and the query engine, complex writing problems under different database query requirements are solved, flexible and efficient data query is realized, and maintenance costs and resource utilization are reduced.

CN119474142BActive Publication Date: 2025-08-22SHENZHOU LINGYUN (BEIJING) TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510051127.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-13
Publication Date
2025-08-22
Estimated Expiration
2045-01-13

AI Technical Summary

Technical Problem

In the prior art, in order to meet the data query needs of different databases, developers need to write structured statements for each database, which makes the writing process complex, time-consuming and difficult to maintain, and additional judgments and adaptation to the differences of each database, increasing the development difficulty.

Method used

By creating a queryer to parse user query requests, generate query statements based on pre-configured mapping relationships, and use the query engine to interact with the database, reducing the usage of system resources and code volume, realizing a flexible data query process.

Benefits of technology

It simplifies the data query process, improves query speed, reduces maintenance costs, and does not need to write database query statements one by one, reducing system resource usage and code volume.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119474142B_ABST
    Figure CN119474142B_ABST
Patent Text Reader

Abstract

The present invention discloses a network data query method, system, electronic device, and storage medium, and relates to the field of database technology. The network traffic data query method provided by the present invention includes: in response to receiving a user query request based on an application program interface, creating a query engine, and parsing the query parameters in the user query request based on the query engine to obtain the parsed query parameters; based on a query engine, generating a query statement according to a pre-configured mapping relationship and the parsed query parameters, and sending the generated query statement to the database to obtain the target data. In the solution of the present invention, the entire network traffic data query process is very convenient, the query response speed is fast, and there is no need to compile query statements for each database one by one, thereby reducing maintenance costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of database technology, and in particular to a network data query method, system, electronic equipment and storage medium. Background Art

[0002] In the case of diversified business systems, the same network traffic data will exist in different databases depending on the business system. The definition of the same network traffic data in different databases may be different.

[0003] In the existing technology, in order to meet users' data query needs for different databases, developers need to write a set of structured statements for different databases. Since the function definition and implementation of each database are different, the entire structured statement writing process is very complicated, difficult and time-consuming, and not easy to maintain.

[0004] In addition, developers need to make additional judgments and definitions regarding the differences between databases to meet users' data query requirements for different databases, further increasing the difficulty of development and adaptation. Summary of the Invention

[0005] In view of this, the present invention proposes a network data query method, system, electronic device and storage medium, which solves the problem that developers need to write a set of structured statements for each database in order to meet data query requirements for different databases.

[0006] In one aspect, an embodiment of the present invention provides a method for querying network traffic data, the method comprising:

[0007] In response to receiving a user query request based on the application program interface, creating a query device, and parsing query parameters in the user query request based on the query device to obtain parsed query parameters;

[0008] Based on the query engine, a query statement is generated according to the pre-configured mapping relationship and the parsed query parameters, and the generated query statement is sent to the database to obtain the target data.

[0009] In some embodiments, a query engine generates a query statement based on a pre-configured mapping relationship and parsed query parameters, and sends the generated query statement to a database to obtain target data, including:

[0010] The processing unit based on the query engine maps the parsed query parameters according to a pre-configured mapping relationship to obtain mapped query parameters;

[0011] Based on the interpretation unit of the query engine, a query statement is generated according to the mapped query parameters, and the generated query statement is sent to the database to obtain the target data.

[0012] In some embodiments, in response to receiving a user query request based on an application program interface, before creating a query engine, the method further includes:

[0013] Based on the query engine, several tables, several fields and several algorithms are defined, and in response to database access, the mapping relationship between the tables in the query engine and the tables in the database is configured, the mapping relationship between the fields in the query engine and the fields in the database is configured, and the algorithms corresponding to the fields in the query engine and the fields in the database are configured.

[0014] In some implementations, mapping the parsed query parameters according to a preconfigured mapping relationship to obtain mapped query parameters includes:

[0015] The parsed query parameters are mapped according to the pre-configured mapping relationship to obtain the table in the database to be queried, the fields in the table in the database to be queried, and the algorithm based on the correspondence between the fields in the table defined by the query engine and the fields in the table in the database to be queried.

[0016] In some implementations, generating a query statement based on the mapped query parameters includes:

[0017] Generate SQL statements based on the mapped query parameters and object-relational mapping framework.

[0018] In some implementations, the query parameter in the user query request is parsed by the query engine to obtain the parsed query parameter, including:

[0019] The query parameters are parsed based on the query engine to obtain the database to be queried, the table to be queried, the fields in the table to be queried, and the conditions to be queried.

[0020] In some embodiments, after the query engine sends the generated query statement to the database to obtain the target data, the method further includes:

[0021] The query engine returns the target data received from the database to the client interface through the query device.

[0022] On the other hand, an embodiment of the present invention further provides a network traffic data query method, which includes executing the following steps based on a database:

[0023] Receive a query statement generated by the query engine based on the pre-configured mapping relationship and the parsed query parameters;

[0024] Query the target data according to the query statement and send the queried target data to the query engine.

[0025] On the other hand, an embodiment of the present invention further provides a network traffic data query system, the network traffic data query system comprising:

[0026] An application program interface configured to create a query device in response to receiving a user query request, and parse query parameters in the user query request based on the query device to obtain parsed query parameters;

[0027] The query engine is configured to generate a query statement according to the pre-configured mapping relationship and the parsed query parameters, and send the generated query statement to the database to obtain the target data.

[0028] On the other hand, an embodiment of the present invention further provides an electronic device comprising: at least one processor; and a memory, the memory storing a computer program that can be run on the processor, characterized in that when the processor executes the program, the steps of the method of any of the above embodiments are performed.

[0029] On the other hand, an embodiment of the present invention further provides a computer storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method of any of the above embodiments are performed.

[0030] The present invention has at least the following beneficial effects:

[0031] The present invention provides a network data query method, system, electronic device and storage medium. Through the network data query method, system, electronic device and storage medium provided by the present invention, a user query request received based on an application program interface can be created after the user query request is received. The query device is created when in use and can be destroyed after use. It is flexible to use and reduces the occupation of system resources. Based on the created query device, the parameters in the user query request can be parsed to obtain the parsed query parameters, so that the query engine can generate a corresponding query statement based on the parsed query parameters and in combination with a pre-configured mapping relationship, so that the database can query the target data through the query statement. The entire network traffic data query process is very convenient and the query speed is fast. There is no need to write query statements for each database one by one, which reduces maintenance costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can be obtained based on these drawings without paying any creative work.

[0033] Figure 1 A flowchart of a network traffic data query method provided by an embodiment of the present invention;

[0034] Figure 2 A flowchart of a network traffic data query method provided by an embodiment of the present invention;

[0035] Figure 3 A schematic diagram of the structure of a network traffic data query system provided by an embodiment of the present invention;

[0036] Figure 4 A schematic diagram of the structure of a network traffic data query system provided by an embodiment of the present invention;

[0037] Figure 5 A schematic structural diagram of an electronic device provided by an embodiment of the present invention;

[0038] Figure 6 A schematic diagram of the structure of a computer storage medium provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0039] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the embodiments of the present invention are further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings.

[0040] It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are for distinguishing two non-identical entities with the same name or non-identical parameters. It can be seen that "first" and "second" are only for the convenience of expression and should not be understood as limitations on the embodiments of the present invention. Subsequent embodiments will not explain this one by one.

[0041] The present invention is described in detail below with reference to the embodiments and accompanying drawings.

[0042] The first aspect of the embodiment of the present invention provides a network traffic data query method, such as Figure 1 As shown, the network traffic data query method may include steps S10 and S11.

[0043] S10 . In response to receiving a user query request based on an application program interface, creating a query controller, and parsing query parameters in the user query request based on the query controller to obtain parsed query parameters.

[0044] The user query request is initiated by the user on the client interface and may include parameters to be queried, such as traffic information within a period of time, number of data packets, user information, etc., which are not specifically limited here.

[0045] The parsed query parameters may include the database to be queried in subsequent steps, the name of the table to be queried, fields, paging, query conditions, etc.

[0046] The query can be created after receiving a user request and revoked after returning the corresponding target data. It is not only flexible to use, but also saves system resources. There is no need to implement business logic in each interface, which reduces the amount of code and has low maintenance costs.

[0047] A query can be understood as the parameters that process user requests. In some examples, depending on business requirements, queryers can include the following four types: detail queryers, time series queryers, statistics queryers, and top queryers. Each type of queryer defines a set of common parameters used by that type of queryer, as well as custom parameters for situations where the common parameters are not covered. For example, when a user sends a request to query detail information, the API creates a detail queryer for this request and sets the user-submitted parameters into the common parameters. Once all these parameters are processed, the queryer is handed over to the processing engine for parsing. A queryer is created for this query only; when the user completes the data query, the queryer created for this request is destroyed. Regardless of how many detail information the frontend needs to query, a detail queryer can be created within the API request to perform the query. This eliminates the need to implement business logic in each API, reduces code size, and lowers maintenance costs. If processing data for a single detail information, it only needs to be processed once within the queryer, significantly reducing processing time.

[0048] After receiving a user query request, the client interface calls the API and creates a query controller based on the API. Different query controllers can be created for different user requests, allowing multiple user queries to be satisfied simultaneously. The query controller then parses the query parameters in the user request to obtain the parsed query parameters.

[0049] S11. Based on the query engine, a query statement is generated according to the pre-configured mapping relationship and the parsed query parameters, and the generated query statement is sent to the database to obtain the target data.

[0050] The query engine can be thought of as an underlying framework. Within the query engine, rules can be defined (for example, defining database tables, fields, algorithms, SQL translation, and other operations) to integrate multiple data sources and achieve unified interpretation and querying of different databases.

[0051] The pre-configured mapping relationships include mapping relationships between user-defined tables in the query engine and tables in the database, mapping relationships between fields in the query engine and fields in each table in the database, and algorithms corresponding to fields in the query engine and fields in each table in the database.

[0052] After the query engine obtains the parsed query parameters, it can generate a corresponding query statement based on the pre-configured mapping relationship. The query statement can be a SQL statement or other query statement.

[0053] In an embodiment of the present invention, a query engine can be created based on user query requests received through an application program interface (API). This query engine is created upon use and destroyed afterward, providing flexibility and reducing system resource usage. The created query engine can then parse the parameters in the user query request to obtain parsed query parameters. The query engine can then generate a corresponding query statement based on the parsed query parameters and preconfigured mapping relationships, allowing the database to query the target data using this query statement. This makes the entire network traffic data query process extremely convenient and fast, eliminating the need to compile query statements for each database individually, thus reducing maintenance costs.

[0054] In some embodiments of the present invention, Figure 1 In step S10 shown, the query parameters in the user query request are parsed based on the query device to obtain the parsed query parameters, which may include: parsing the query parameters based on the query device to obtain the database to be queried, the table to be queried, the fields in the table to be queried, and the conditions to be queried.

[0055] It should be noted that the table to be queried here refers to the table defined in the query engine.

[0056] Specifically, a user sends a query request to the query engine through the client interface. This query request is first received by a unified application programming interface (API). Upon receiving the user's query request, the API creates a query engine, which parses the query request and determines the parameters to be included in the query. These parameters can include the database to be queried, the table to be queried, the metric to be queried, the query condition to be queried, paging, and other parameters, but are not specifically limited here.

[0057] Through the table to be queried, the subsequent query engine can obtain the basic information structure of the table to be queried, for example, the library to be queried, the table name, object, field and other information.

[0058] Through the indicator to be queried, the subsequent query engine can determine the corresponding algorithm based on the indicator.

[0059] The query engine determines the table to be queried through the query engine, and can know which fields in the table to be queried are used to generate the value of this indicator.

[0060] For example, a metric can be queried using a single column in a table or calculated using multiple columns. For example, a user requests total utilization, which corresponds to client traffic, server traffic, time, and bandwidth in Table A in Database 1. The query engine uses preconfigured mappings to determine the corresponding algorithm: total utilization = (client traffic + server traffic) * 8 / time / bandwidth.

[0061] Currently, big data is stored in separate tables and databases. Therefore, the query conditions vary depending on the table being queried. For example, if a user requests user information, the query conditions for this user information may include name, gender, age, mobile phone number, and other information. If a user requests traffic information, the query conditions for this traffic information may include source port, end IP address, destination port, destination IP address, traffic volume, packet size, and other information.

[0062] In some embodiments of the present invention, Figure 1 Before step S10 shown, the method may further include: defining a number of tables, a number of fields, and a number of algorithms based on the query engine, and in response to database access, configuring a mapping relationship between tables in the query engine and tables in the database, configuring a mapping relationship between fields in the query engine and fields in the database, and configuring algorithms corresponding to fields in the query engine and fields in the database.

[0063] The query engine's configuration unit allows you to configure mapping compatibility with third-party databases connected to the query engine. This unit also includes pre-defined, configurable, and universal APIs for connecting to third-party databases. Mapping configuration can include basic configuration, table mapping, field mapping, and algorithm mapping.

[0064] The embodiment of the present invention can perform real-time mapping on the connected database without developing code, dynamically introduce the database into the query engine, and complete the entire process without restarting the service.

[0065] In some examples, in the basic configuration, you can configure the IP address, driver, library name, user name, password, etc. of the third-party database.

[0066] In some examples, an optional connection pool can be configured in the basic configuration to expand the scope of queries.

[0067] In some examples, the API provides a complete table mapping for table mapping. For example, a table named A is defined for traffic querying. When the query engine's processing unit receives a query request for table A from the query server, it uses the table mapping relationship to find the specific table name in the database to be queried.

[0068] After the table mapping is completed, field mapping will be performed. In some examples, for field mapping, some basic fields will also be defined in Table A of the query engine, such as traffic, number of packets, etc., so that the processing unit of the subsequent query engine can quickly identify them. For example, a user requests to query the number of packets of network traffic data. The number of packets of the network traffic data is generally divided into the number of client packets and the number of server packets. The number of client packets defined in the query engine is clientPkts, and the number of client packets defined in the database is initPkts. Through field mapping in the query engine, the initPkts of the database is mapped to clientPkts. The query engine can quickly find the initPkts field through the clientPkts parsed by the query engine.

[0069] In some examples, the fields defined in the query engine's configuration unit may be the same as the fields defined in the database. In this case, there is no need to map the fields defined in the query engine's configuration unit with the fields defined in the database, which further simplifies the information that needs to be configured and makes maintenance more convenient.

[0070] In some examples, for the mapping of algorithms, algorithms can be divided into simple algorithms and aggregate algorithms.

[0071] Simple algorithms can be arithmetic operations, such as addition, subtraction, multiplication, and division.

[0072] For example, if the query engine determines that the parameter to be queried is the total traffic field, and the query engine's corresponding database fields are the client traffic field and the server traffic field, then the algorithm determined by the mapping relationship between the total traffic field in the query engine and the traffic fields in the corresponding database is addition. Therefore, the query engine can calculate total traffic = client traffic + server traffic, that is, totalBytes = clientBytes + serverBytes. If the algorithm for client traffic in a third-party database is defined as clientBytes = initIPv4Bytes + initIPv6Bytes, and the algorithm for server traffic is defined as serverBytes = respIPv4Bytes + respIPv6Bytes, then after the query engine completes the field mapping, the final algorithm determined is clientBytes = initIPv4Bytes + initIPv6Bytes, and serverBytes = respIPv4Bytes + respIPv6Bytes.

[0073] When the query engine's processing unit determines the corresponding algorithm based on the total traffic field, it finds the corresponding algorithm through the mapping relationship of total traffic, totalBytes = initIPv4Bytes + initIPv6Bytes + respIPv4Bytes + respIPv6Bytes.

[0074] The aggregation algorithm can be a statistical operation algorithm, such as summation or averaging. For example, if a user requests to query the total traffic for one minute, the mapping logic in the above example remains unchanged, and the algorithm mapping relationship for the total traffic for one minute is totalBytes = SUM(initIPv4Bytes + initIPv6Bytes + respIPv4Bytes + respIPv6Bytes).

[0075] By configuring mapping relationships in the query engine, the query engine can adapt to different databases more quickly, reducing the large amount of code required to add a new data source. This greatly reduces the coupling of the code, making the code more concise and easier to maintain.

[0076] In some embodiments of the present invention, Figure 1 In step S11, based on the query engine, a query statement is generated according to the pre-configured mapping relationship and the parsed query parameters, and the generated query statement is sent to the database to obtain the target data, which may include the following steps: Figure 2 Steps S21 and S22 are shown.

[0077] S21 . The query engine-based processing unit maps the parsed query parameters according to a pre-configured mapping relationship to obtain mapped query parameters.

[0078] Specifically, the parsed query parameters may include: the database to be queried, the table to be queried, the fields in the table to be queried, and the conditions to be queried. Here, the table to be queried refers to parameters such as the table defined in the query engine.

[0079] The mapped query parameters may include: the table in the database to be queried, the fields in the table in the database to be queried, and parameters such as the algorithm corresponding to the fields in the table of the configuration engine and the fields in the table in the database to be queried.

[0080] In a specific implementation, the parsed query parameters are mapped according to a pre-configured mapping relationship, and the table in the database to be queried, the fields in the table in the database to be queried, and the algorithm corresponding to the fields in the table based on the query engine and the fields in the table in the database to be queried can be obtained.

[0081] S22. The interpretation unit based on the query engine generates a query statement according to the mapped query parameters, and sends the generated query statement to the database to obtain the target data.

[0082] Specifically, SQL statements can be generated based on the mapped query parameters and the object-relational mapping framework (ORM framework for short).

[0083] In some examples, the processing unit of the query engine is used to obtain parameters such as the database to be queried, the table in the database to be queried, the fields in the table in the database to be queried, and the algorithm used for calculation based on the parameters parsed by the query and the mapping configured in the configuration unit of the query engine, and pass these obtained parameters to the interpretation unit of the query engine. After the interpretation unit of the query engine obtains these parameters, it will enclose these parameters in the ORM framework, generate SQL statements through the ORM framework, and send the SQL statements to the corresponding database for data query.

[0084] In some examples, if the processing unit of the query engine finds the mapped database field from the configuration unit of the query according to the parameters parsed by the query, if the corresponding database field is not found, it can directly generate an SQL statement based on the database table, the fields defined by the query engine, and the algorithm defined by the database, and send the SQL statement to the corresponding database for data query.

[0085] In some embodiments of the present invention, Figure 1After step S11 shown, the method may further include: returning the target data received from the database to the client interface via the query engine through the query device.

[0086] Specifically, the database may receive a query statement generated by the query engine according to the pre-configured mapping relationship and the parsed query parameters; query target data according to the query statement, and send the queried target data to the query engine.

[0087] For example, the database can receive SQL statements sent by the query engine, and after finding the corresponding data according to the SQL statements, return the data to the query engine through the query engine. After the query engine obtains the data, it returns it to the client interface for display.

[0088] Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a network traffic data query system, such as Figure 3 As shown, the network traffic data query system 30 includes:

[0089] The application program interface 31 is configured to create a query unit 33 in response to receiving a user query request, and parse the query parameters in the user query request based on the query unit 33 to obtain the parsed query parameters;

[0090] The query engine 32 is configured to generate a query statement according to the pre-configured mapping relationship and the parsed query parameters, and send the generated query statement to the database to obtain target data.

[0091] In this embodiment of the present invention, a query engine can be flexibly created based on an application programming interface (API) in response to received user query requests. This query engine can be destroyed after use, providing flexibility and reducing system resource usage. The created query engine can then parse the parameters in the user query request to obtain parsed query parameters. The query engine can then generate a corresponding query statement based on the parsed query parameters and preconfigured mapping relationships, allowing the database to query the target data using this query statement. This makes the entire network traffic data query process extremely convenient and fast, eliminating the need to compile query statements for each database individually, thus reducing maintenance costs.

[0092] In one example, if Figure 4As shown, the current query engine is connected to a total of four third-party databases: MySql, ClickHouse, PostgreSQL, and MongoDB, and mapping relationships with these four databases are configured separately. The user client interface is connected to the query engine through an application programming interface (API). When a user sends a query request to the service backend through the client interface, the API first receives the query request. After receiving the user query request, the API creates a query controller, which parses the user query request and determines the parameters to be included in the query. For example, the parameters to be queried are: the database to be queried is a MySql database, the table to be queried is a user information table (such as Table A), the fields to be queried include name, gender, age, grade, Chinese language scores, math scores, and English scores, and the query condition is people older than XX years old. It should be noted that the tables and fields to be queried here refer to the tables and fields defined in the query engine.

[0093] The processing unit of the query engine generates SQL statements based on the parameters parsed by the query engine and the mapping configured in the configuration unit of the query engine, as well as parameters such as the tables in the database to be queried, the fields in the tables in the database to be queried, and the algorithm used for calculation, and sends the SQL statements to the corresponding database for data query.

[0094] The database receives the SQL statement sent by the query engine, finds the corresponding data, and returns the data to the query engine through the query engine. After the query engine obtains the data, it returns it to the client interface for display.

[0095] Based on the same inventive concept, according to another aspect of the present invention, Figure 5 As shown, an embodiment of the present invention further provides an electronic device 500, which includes a processor 510 and a memory 520. The memory 520 stores a computer program 521 that can be run on the processor. When the processor 510 executes the program, the steps of the above method are performed.

[0096] The memory, as a non-volatile storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs, and modules, such as the program instructions / modules corresponding to the compression method in the embodiments of the present application. The processor executes the non-volatile software programs, instructions, and modules stored in the memory to execute various functional applications and data processing of the device, thereby implementing the compression method in the above method embodiments.

[0097] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system and application programs required for at least one function; the data storage area may store data created based on the use of the device, etc. In addition, the memory may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory may optionally include a memory remotely located relative to the processor, and these remote memories may be connected to the local module via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0098] Based on the same inventive concept, according to another aspect of the present invention, Figure 6 As shown, an embodiment of the present invention further provides a computer storage medium 600 , which stores a computer program 610 for executing the above method when executed by a processor.

[0099] Finally, it should be noted that those skilled in the art will understand that all or part of the processes in the above-described method embodiments can be implemented using a computer program to instruct the relevant hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes in the above-described method embodiments. The program storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM). The above-described computer program embodiments can achieve the same or similar effects as any of the corresponding aforementioned method embodiments.

[0100] It will also be appreciated by those skilled in the art that the various exemplary logic blocks, modules, circuits and algorithmic steps described in conjunction with the disclosure herein can be implemented as electronic hardware, computer software or a combination of the two. In order to clearly illustrate this interchangeability of hardware and software, a general description has been given of the functions of various schematic components, blocks, modules, circuits and steps. Whether this function is implemented as software or hardware depends on specific applications and the design constraints imposed on the entire system. Those skilled in the art can implement the function in various ways for each specific application, but this implementation decision should not be interpreted as causing a departure from the disclosed scope of the embodiments of the present invention.

[0101] The above are exemplary embodiments disclosed in the present invention, but it should be noted that various changes and modifications can be made without departing from the scope of the disclosure of the embodiments of the present invention as defined in the claims. The functions, steps and / or actions of the method claims according to the disclosed embodiments described herein do not need to be performed in any particular order. The serial numbers of the embodiments disclosed in the above embodiments of the present invention are for description only and do not represent the advantages and disadvantages of the embodiments. In addition, although the elements disclosed in the embodiments of the present invention can be described or required in individual form, they can also be understood as multiple unless expressly limited to the singular.

[0102] It should be understood that, as used herein, the singular forms "a" and "an" are intended to include the plural forms as well, unless the context clearly supports an exception. It should also be understood that, as used herein, "and / or" is intended to include any and all possible combinations of one or more of the associated listed items.

[0103] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to limit the scope of the disclosure of the present invention (including the claims) to these examples. Within the spirit of the present invention, the technical features of the above embodiments or different embodiments may be combined, and many other variations exist in different aspects of the above embodiments, which are not provided in detail for the sake of clarity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A network traffic data query method, characterized in that: include: In response to receiving a user query request based on the application program interface, creating a query engine, and parsing query parameters in the user query request based on the query engine to obtain parsed query parameters; wherein the parsed query parameters include a database to be queried, a table to be queried, and fields in the table to be queried; Based on the query engine, the parsed query parameters are mapped according to a pre-configured mapping relationship to obtain mapped query parameters; wherein the pre-configured mapping relationship includes: a mapping relationship between a table customized in the query engine and a table in the database, a mapping relationship between a field of the query engine and a field of each table in the database, and an algorithm corresponding to the field of the query engine and the field of each table in the database; the mapped parameters include a table in the database to be queried, a field in the table of the database to be queried, and an algorithm based on the correspondence between the field in the table defined by the query engine and the field in the table of the database to be queried; the algorithm includes a simple algorithm and an aggregation algorithm, the simple algorithm includes arithmetic operations, and the aggregation algorithm includes statistical operations; Based on the query engine, a query statement is generated according to the mapped query parameters, and the generated query statement is sent to the database to obtain target data.

2. The method according to claim 1, characterized in that Before creating the query device in response to receiving a user query request based on the application program interface, the method further includes: Based on the query engine, several tables, several fields and several algorithms are defined, and in response to database access, the mapping relationship between the tables in the query engine and the tables in the database is configured, the mapping relationship between the fields in the query engine and the fields in the database is configured, and the algorithms corresponding to the fields in the query engine and the fields in the database are configured.

3. The method according to claim 1, characterized in that Generate query statements based on the mapped query parameters, including: Generate SQL statements based on the mapped query parameters and object-relational mapping framework.

4. The method according to any one of claims 1 to 3, characterized in that Also includes: In response to the target data query being completed, the created query controller is destroyed.

5. The method according to any one of claims 1 to 3, characterized in that After the query engine sends the generated query statement to the database to obtain the target data, the method further includes: The query engine returns the target data received from the database to the client interface through the query device.

6. A network traffic data query system, characterized in that: include: An application program interface configured to, in response to receiving a user query request, create a query engine, and parse query parameters in the user query request based on the query engine to obtain parsed query parameters, wherein the parsed query parameters include a database to be queried, a table to be queried, and fields in the table to be queried; A query engine configured to map parsed query parameters according to a preconfigured mapping relationship to obtain mapped query parameters; wherein the preconfigured mapping relationship includes: a mapping relationship between a table customized in the query engine and a table in a database, a mapping relationship between fields in the query engine and fields in each table in the database, and an algorithm corresponding to the fields in the query engine and fields in each table in the database; the mapped parameters include a table in the database to be queried, a field in the table in the database to be queried, and an algorithm based on the correspondence between the fields in the table defined by the query engine and the fields in the table in the database to be queried; the algorithm includes a simple algorithm and an aggregation algorithm, the simple algorithm including an arithmetic operation, and the aggregation algorithm including a statistical operation; The query engine is configured to generate a query statement according to the mapped query parameters and send the generated query statement to the database to obtain the target data.

7. An electronic device comprising: at least one processor; as well as A memory storing a computer program that can be run on the processor, wherein the processor performs the steps of the method according to any one of claims 1 to 5 when executing the program.

8. A storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are performed.

Citation Information

Patent Citations

  • Data query method and device, electronic equipment and readable storage medium

    CN115705330A

  • Data query statement generation method and device, equipment, storage medium and product

    CN116431657A

  • Data dynamic query method and system based on pluggable connector

    CN116910081A