Network data query method and system, electronic equipment and storage medium
By creating a queryer to parse user query requests and generate query statements in combination with pre-configured mapping relationships, the complexity and maintenance difficulty of writing structured statements for different databases in the existing technology is solved, and convenient and efficient network traffic data query is achieved. .
Patent Information
- Application Number
- CN202510051127.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-13
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2045-01-13
AI Technical Summary
In the prior art, developers need to write structured statements for different databases, which makes writing complex, time-consuming and difficult to maintain, and additional judgment and definition are required to adapt to the differences between each database, increasing the development difficulty and adaptation difficulty.
A network data query method is proposed. By creating a queryer to analyze the parameters in the user query request, combining the pre-configured mapping relationship and the query engine to generate query statements, and send them to the database to obtain target data.
It realizes convenient network traffic data query, reduces the use of system resources, reduces maintenance costs, and avoids the cumbersome process of writing database query statements one by one.
Smart Images

Figure CN119474142A_ABST
Abstract
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 according to different business systems. The same network traffic data has different definitions in different databases.
[0003] In the prior art, 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, regarding the differences between databases, developers need to make additional judgments and definitions 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] On the one hand, an embodiment of the present invention provides a network traffic data query method, the network traffic data query method comprising: 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; 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.
[0007] In some implementations, based on a query engine, a query statement is generated according to a pre-configured mapping relationship and the parsed query parameters, and the generated query statement is sent to a database to obtain target data, including: Based on the processing unit of the query engine, the parsed query parameters are mapped according to a pre-configured mapping relationship to obtain mapped query parameters; 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.
[0008] In some implementations, in response to receiving a user query request based on an application program interface, before creating a query device, 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, the mapping relationship between the fields in the query engine and the fields in the database and the algorithms corresponding to the fields in the query engine and the fields in the database are configured.
[0009] In some implementations, mapping the parsed query parameters according to a preconfigured mapping relationship to obtain the mapped query parameters includes: 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 corresponding to the fields in the table defined by the query engine and the fields in the table in the database to be queried.
[0010] In some implementations, generating a query statement according to the mapped query parameters includes: Generate SQL statements based on the mapped query parameters and the object-relational mapping framework.
[0011] In some implementations, the query parameter in the user query request is parsed by the query controller to obtain the parsed query parameter, including: The query parameters are parsed 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.
[0012] In some embodiments, 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.
[0013] On the other hand, an embodiment of the present invention further provides a network traffic data query method, the network traffic data query method comprising executing the following steps based on a database: Receiving a query statement generated by the query engine according to the pre-configured mapping relationship and the parsed query parameters; Query the target data according to the query statement and send the queried target data to the query engine.
[0014] 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: An application program interface configured to create a query device in response to receiving a user query request, and parse the query parameters in the user query request based on the query device to obtain the parsed query parameters; 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.
[0015] 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.
[0016] 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 executed.
[0017] The present invention has at least the following beneficial effects: 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 query device can be created based on a user query request received by an application program interface and after receiving the user query request. The query device is created when in use and can be destroyed after use, which 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 corresponding query statements 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 query process of the entire network traffic data 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 the maintenance cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description 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 creative work.
[0019] Figure 1 A flowchart of a network traffic data query method provided by an embodiment of the present invention; Figure 2 A flowchart of a network traffic data query method provided by an embodiment of the present invention; Figure 3 A schematic diagram of the structure of a network traffic data query system provided by an embodiment of the present invention; Figure 4A schematic diagram of the structure of a network traffic data query system provided by an embodiment of the present invention; Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention; Figure 6 A schematic diagram of the structure of a computer storage medium provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0020] 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 combination with specific embodiments and with reference to the accompanying drawings.
[0021] 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. The subsequent embodiments will not explain this one by one.
[0022] The present invention is described in detail below in conjunction with embodiments and drawings.
[0023] A first aspect of an 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.
[0024] S10. In response to receiving a user query request based on an application program interface, a query device is created, and query parameters in the user query request are parsed based on the query device to obtain parsed query parameters.
[0025] 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, data packet number information, user information, etc., which are not specifically limited here.
[0026] The parsed query parameters may include the database to be queried in subsequent steps, the name of the table to be queried, the field, paging, query conditions, etc.
[0027] 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.
[0028] The query can be understood as the parameters for processing user requests. In some examples, according to business usage requirements, the query can include the following four types of query: detailed query, time series query, statistical query, and TOP query. In each type of query, a set of common parameters used by the query and some custom parameters that are not covered by the common parameters are defined. For example, when a user sends a request to query a detailed order. The application interface will create a detailed query for this request, and set the parameters submitted by the user to the common parameters in the detailed query. After all these are processed, the query is handed over to the processing engine for parsing. Create a query, which is only used for the user's query this time. When the user completes the data query, the query built for this request is also destroyed. No matter how many detailed orders the front end needs to check, you can create a detailed query in the interface request to query. Therefore, you don't need to implement business logic in each interface, reduce the amount of code, and have low maintenance costs. If you are processing a piece of data in a detailed order, you only need to process it once in the query, which greatly shortens the processing time.
[0029] After receiving the user query request, the client interface calls the application program interface and creates a query based on the application program interface. Corresponding query devices can be created for different user requests, which can satisfy the query requests of several users at the same time. The query parameters in the user request are parsed based on the query device to obtain the parsed query parameters.
[0030] 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.
[0031] The query engine can be understood as an underlying framework. In the query engine, multiple data sources can be integrated through rule definition (for example, defining a series of operations such as tables, fields, algorithms, and SQL translation of the corresponding database) to achieve unified interpretation and query of different databases.
[0032] The pre-configured mapping relationship configures the mapping relationship between the custom table in the query engine and the table in the database, the mapping relationship between the fields of the query engine and the fields of each table in the database, and the algorithm corresponding to the fields of the query engine and the fields of each table in the database.
[0033] After the query engine obtains the parsed query parameters, it can generate a corresponding query statement in combination with the pre-configured mapping relationship. The query statement can be a SQL statement or other query statement.
[0034] The embodiment of the present invention can create a query device based on the user query request received by the application program interface, and after receiving the user query request. The query device is created when it is used and can be destroyed after use, which 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 corresponding query statements based on the parsed query parameters and in combination with the pre-configured mapping relationship, so that the database can query the target data through the query statement. The query process of the entire network traffic data 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 the maintenance cost.
[0035] In some embodiments of the present invention, Figure 1 In the 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.
[0036] It should be noted that the table to be queried here refers to the table defined in the query engine.
[0037] Specifically, the user sends a query request to the query engine through the client interface, and the query request will first be received by the unified application interface. After the application interface receives the user's query request, it will create a query device, which will parse the user's query request and determine the parameters to be queried. The determined parameters can be the database to be queried, the table to be queried, the index to be queried, the condition to be queried, the paging and other parameters, which are not specifically limited here.
[0038] 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.
[0039] Through the indicator to be queried, the subsequent query engine can determine the corresponding algorithm according to the indicator.
[0040] 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.
[0041] For example, an indicator can be queried through a column in a table or calculated through multiple columns in a table. For example, a user requests to query a total utilization rate, and the table corresponding to the total utilization rate is the client traffic, server traffic, time, and bandwidth in Table A in Database 1. The query engine can determine the corresponding algorithm based on the pre-configured mapping relationship, that is, total utilization rate = (client traffic + server traffic) * 8 / time / bandwidth.
[0042] Currently, big data is stored in separate tables and databases. Therefore, the query conditions vary depending on the table to be queried. For example, if a user requests to query user information, the query conditions corresponding to the user information may include name, gender, age, mobile phone number, etc. If a user requests to query traffic information, the query conditions corresponding to the traffic information may include source port, end IP, destination port, destination IP, traffic size, packet size, etc.
[0043] In some embodiments of the present invention, Figure 1 Before the step S10 shown, the method may also include: defining a number of tables, a number of fields, and a number of algorithms based on the query engine, and in response to a 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 an algorithm corresponding to fields in the query engine and fields in the database.
[0044] The configuration unit of the query engine can be used to perform compatibility mapping configuration for third-party databases connected to the query engine. The configuration unit can also include a pre-defined configurable general application interface for connecting to a third-party database. The mapping configuration can include basic configuration, table mapping, field mapping, and algorithm mapping.
[0045] The embodiment of the present invention can map the connected database in real time without developing code, dynamically introduce the database into the query engine, and complete the entire process without restarting the service.
[0046] In some examples, in the basic configuration, you can configure the IP, driver, library name, user name, password, etc. of the third-party database.
[0047] In some examples, an optional link pool may be configured in the basic configuration to expand the scope of queries.
[0048] In some examples, for table mapping, the application program interface provides a complete mapping of a table. For example, a table name A is defined for querying traffic. If the subsequent query engine processing unit receives the query table A sent by the queryer, the query engine processing unit will find the specific table name of the database to be queried from the table A through the table mapping relationship.
[0049] After the table mapping is completed, field mapping will be performed. In some examples, for field mapping, some basic fields such as traffic, number of packets, etc. will also be defined in Table A of the query engine to facilitate rapid identification by the subsequent processing unit of the query engine. 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 are mapped to clientPkts. The query engine can quickly find the initPkts field through the clientPkts parsed by the query engine.
[0050] 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.
[0051] In some examples, for the mapping of algorithms, the algorithms can be divided into simple algorithms and aggregate algorithms.
[0052] Simple algorithms can be arithmetic operations, such as addition, subtraction, multiplication, and division.
[0053] For example, the parameter to be queried based on the query engine is the total traffic field. In the query engine, the fields in the database corresponding to the total traffic field are the client traffic field and the server traffic field. Then, according to the mapping relationship between the total traffic field in the query engine and the traffic field in the corresponding database, the algorithm that can be determined is the addition operation. Therefore, the query engine can obtain the total traffic = client traffic + server traffic, that is, totalBytes = clientBytes + serverBytes. If in the third-party database, the algorithm for client traffic 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, serverBytes = respIPv4Bytes + respIPv6Bytes.
[0054] When the processing unit of the query engine determines the corresponding algorithm according to the total traffic field, the corresponding algorithm is found through the mapping relationship of the total traffic, totalBytes = initIPv4Bytes + initIPv6Bytes +respIPv4Bytes + respIPv6Bytes.
[0055] The aggregation algorithm may be a statistical operation algorithm, such as summation, averaging, etc. 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 of the total traffic for one minute is totalBytes = SUM(initIPv4Bytes + initIPv6Bytes + respIPv4Bytes + respIPv6Bytes).
[0056] By configuring the mapping relationship in the query engine, the query engine can adapt to different databases more quickly, reducing the large amount of code implementation required to add a new data source, greatly reducing the coupling of the code, making the code more concise and easier to maintain.
[0057] In some embodiments of the present invention, Figure 1 Step S11 shown in the figure, based on the query engine, generates a query statement according to the pre-configured mapping relationship and the parsed query parameters, and sends the generated query statement to the database to obtain the target data, which may include the following: Figure 2 Steps S21 and S22 are shown.
[0058] S21. A processing unit based on the query engine maps the parsed query parameters according to a pre-configured mapping relationship to obtain mapped query parameters.
[0059] Specifically, the parsed query parameters may include: a database to be queried, a table to be queried, a field in the table to be queried, and a condition to be queried. Here, the table to be queried refers to parameters such as a table defined in the query engine.
[0060] 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.
[0061] In a specific implementation, the parsed query parameters are mapped according to a 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 an algorithm based on the correspondence between the fields in the table of the query engine and the fields in the table in the database to be queried.
[0062] S22. An interpretation unit based on the query engine generates a query statement according to the mapped query parameters, and sends the generated query statement to a database to obtain target data.
[0063] Specifically, SQL statements may be generated according to the mapped query parameters and an object-relational mapping framework (ORM framework for short).
[0064] 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 hand over these obtained parameters to the interpretation unit of the query engine. After obtaining these parameters, the interpretation unit of the query engine 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.
[0065] In some examples, if the processing unit of the query engine finds a 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.
[0066] In some embodiments of the present invention, Figure 1 After step S11 shown, the method may further include: based on the query engine, returning the target data received from the database to the client interface through the query device.
[0067] 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 the target data according to the query statement, and send the queried target data to the query engine.
[0068] For example, the database can receive an SQL statement sent by a query engine, and after finding the corresponding data according to the SQL statement, 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.
[0069] Based on the same inventive concept, according to another aspect of the present invention, the 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: 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; 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 the target data.
[0070] According to the embodiment of the present invention, a query engine can be flexibly created based on an application program interface according to a received user query request. The query engine can be destroyed after use, is flexible to use, and reduces the occupation of system resources. Based on the created query engine, the parameters in the user query request can be parsed to obtain the parsed query parameters, so that the query engine can generate corresponding query statements based on the parsed query parameters and in combination with the pre-configured mapping relationship, so that the database can query the target data through the query statement. The query process of the entire network traffic data 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 the maintenance cost.
[0071] In one example, if Figure 4 As shown in the figure, the current query engine has connected to a total of 4 third-party databases, namely MySql, ClickHouse, PostgreSQL, and MongoDB, and the mapping relationship with these four databases is configured respectively. The user client interface is connected to the query engine through the application program interface. When the user sends a query request to the service backend through the client interface, the application program interface first receives the query request. After the application program interface receives the user query request, it will create a query device, which will parse the user query request and determine the parameters to be involved in the query. For example, the parameters to be queried are: the database to be queried is the MySql database, the table to be queried is the user information table (such as Table A), the fields to be queried are name, gender, age, grade, Chinese score, math score and English score, and the condition to be queried is a person 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.
[0072] 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, the tables in the database to be queried, the fields in the tables in the database to be queried, and the algorithms used for calculation, and sends the SQL statements to the corresponding database for data query.
[0073] After the database finds the corresponding data based on the SQL statement sent by the query engine, it 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.
[0074] Based on the same inventive concept, according to another aspect of the present invention, Figure 5As 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.
[0075] Among them, 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 embodiment of the present application. The processor executes various functional applications and data processing of the device by running the non-volatile software programs, instructions and modules stored in the memory, that is, realizing the compression method of the above method embodiment.
[0076] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to 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 arranged 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.
[0077] 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.
[0078] Finally, it should be noted that a person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium of the program can be a disk, an optical disk, a read-only storage memory (ROM) or a random access memory (RAM), etc. The above-mentioned computer program embodiments can achieve the same or similar effects as the corresponding above-mentioned any method embodiments.
[0079] It will also be appreciated by those skilled in the art that various exemplary logic blocks, modules, circuits and algorithm 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 to 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.
[0080] The above are exemplary embodiments disclosed in the present invention, but it should be noted that various changes and modifications may be made without departing from the scope of the embodiments disclosed 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 may be described or required in individual form, they may also be understood as multiple unless explicitly limited to the singular.
[0081] It should be understood that, as used herein, the singular forms "a", "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" refers to any and all possible combinations including one or more of the associated listed items.
[0082] A person skilled in the art should understand that the discussion of any of the above embodiments is only exemplary and is not intended to imply that the scope of the disclosure of the embodiments of the present invention (including the claims) is limited to these examples; under the concept of the embodiments of the present invention, the technical features in the above embodiments or different embodiments can also be combined, and there are many other changes in different aspects of the above embodiments of the present invention, which are not provided in detail for the sake of simplicity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present invention should be included in the protection scope of the embodiments 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 an 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; 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.
2. The method according to claim 1, characterized in that 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, including: Based on the processing unit of the query engine, the parsed query parameters are mapped according to a pre-configured mapping relationship to obtain mapped query parameters; 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.
3. The method according to claim 2, characterized in that In response to receiving a user query request based on the application program interface, before creating a query device, the method further includes: Based on the query engine, a number of tables, a number of fields and a number of algorithms are defined, and in response to a database access, a mapping relationship between the tables in the query engine and the tables in the database is configured, a mapping relationship between the fields in the query engine and the fields in the database and algorithms corresponding to the fields in the query engine and the fields in the database are configured.
4. The method according to claim 3, characterized in that The parsed query parameters are mapped according to the pre-configured mapping relationship to obtain the mapped query parameters, including: The parsed query parameters are mapped according to a preconfigured mapping relationship to obtain a table in the database to be queried, fields in the table in the database to be queried, and an algorithm corresponding to the fields in the table defined by the query engine and the fields in the table in the database to be queried.
5. The method according to claim 2, characterized in that: Generate query statements based on the mapped query parameters, including: Generate SQL statements based on the mapped query parameters and the object-relational mapping framework.
6. The method according to any one of claims 1 to 5, characterized in that: Parsing the query parameters in the user query request based on the query device to obtain the parsed query parameters includes: The query parameter is parsed 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.
7. The method according to any one of claims 1 to 5, 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.
8. A network traffic data query system, characterized in that: include: An application program interface, configured to create a query device in response to receiving a user query request, and parse the query parameters in the user query request based on the query device to obtain the parsed query parameters; 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.
9. An electronic device, comprising: at least one processor; as well as A memory storing a computer program executable on the processor, wherein the processor executes the steps of the method according to any one of claims 1 to 7 when executing the program.
10. 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 7 are performed.
Citation Information
Patent Citations
Generation method and device for mapping relationship
CN103186541A
Data query method, system and device
CN110399388A
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