CN-122019643-A - Database access method, device, equipment and medium
Abstract
The invention relates to the technical field of databases and discloses a database access method, a device, equipment and a medium, which comprise the steps of responding to a first query request, determining a target database corresponding to a target measuring point in the first query request, and calling a target connector for the target database; the method comprises the steps of converting a first query request into a call instruction adapting to a target database based on a target connector, initiating a second query request to the target database based on the target connector and the call instruction, receiving an original query result returned by the target database, processing the original query result, and generating and displaying a target chart. The invention adapts different types of time sequence databases through the connector, thereby realizing unified processing of the query request and the data format, and improving the efficiency of data query and report generation.
Inventors
- LI DILI
- Nie Lunan
- MA HONGTAO
- ZHENG JIAN
- CHEN YUCHAO
- ZHOU YING
- JIAO LI
- LIN DA
- LIU GUANHUA
Assignees
- 华电电力科学研究院有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20251201
Claims (10)
- 1. A method of database access, the method comprising: responding to a first query request, determining a target database corresponding to a target measuring point in the first query request, and calling a target connector for the target database; Converting the first query request into a call instruction adapting to the target database based on the target connector; initiating a second query request to the target database based on the target connector and the call instruction, and receiving an original query result returned by the target database; and processing the original query result to generate and display a target chart.
- 2. The database access method according to claim 1, wherein the converting the first query request into a call instruction adapted to the target database based on the target connector includes: and mapping and packaging parameters in the first query request into a calling instruction conforming to a native query protocol of the target database based on an adaptation layer of the target connector.
- 3. The method for accessing a database according to claim 1, wherein said processing said original query result to generate and display a target graph comprises: Normalizing the original query result to generate structured data conforming to a preset standard format; a target graph is generated and displayed based on the structured data.
- 4. The database access method of claim 1, wherein prior to receiving the first query request, the method further comprises: The method comprises the steps of constructing a query model, wherein the query model comprises at least one equipment node, the equipment node comprises at least one component node, the component node comprises at least one measuring point node, and the measuring point node is configured to correspond to at least one time sequence data source in a preset database.
- 5. The database access method of claim 4, wherein the constructing a query model comprises: Responding to a new adding operation of the equipment node, and displaying a first configuration interface of the equipment node; and determining the attribute of the equipment node in response to the configuration operation at the first configuration interface.
- 6. The database access method of claim 5, wherein the constructing a query model further comprises: responding to a new adding operation of a component node of the equipment node, and displaying a second configuration interface of the component node; And determining the attribute of the component node in response to a configuration operation at the second configuration interface.
- 7. The database access method of claim 6, wherein the constructing a query model further comprises: responding to a new operation of a measuring point node of the component node, and displaying a third configuration interface of the measuring point node; And determining the attribute of the measuring point node in response to the configuration operation at the third configuration interface.
- 8. A database access apparatus, the apparatus comprising: The calling module is used for responding to a first query request, determining a target database corresponding to a target measuring point in the first query request, and calling a target connector for the target database; the request conversion module is used for converting the first query request into a call instruction adapting to the target database based on the target connector; The result receiving module is used for initiating a second query request to the target database based on the target connector and the call instruction and receiving an original query result returned by the target database; And the chart generation module is used for processing the original query result and generating and displaying a target chart.
- 9. A computer device, comprising: A memory and a processor in communication with each other, the memory having stored therein computer instructions, the processor executing the computer instructions to perform the database access method of any of claims 1 to 7.
- 10. A computer-readable storage medium having stored thereon computer instructions for causing a computer to perform the database access method of any of claims 1 to 7.
Description
Database access method, device, equipment and medium Technical Field The present invention relates to the field of database technologies, and in particular, to a method, an apparatus, a device, and a medium for accessing a database. Background The current report system generally follows the fixed flow of establishing a data source, defining a data set and configuring a report, configures connection information such as a server address, a port, an access account password and the like of the time sequence database in the link of establishing the data source, establishes communication with the time sequence database by loading a specific driver, configures fields in the data set as dimensions, values or screening conditions of the report according to query sentences input by a user and report types selected by the user, and finally displays the data in the report. However, the existing data model simplifies the time sequence data into a two-dimensional table form, and the hierarchical relationship between the fractured data and the business entity affects the query efficiency. In addition, the current part of mainstream time sequence databases do not support access through standard interfaces, only a software development kit customized by manufacturers is provided as a data access entry, the data set model of the existing system requires that a data source must return two-dimensional data comprising a row structure and a column structure to construct a data set, and the data format is incompatible with the two-dimensional structure requirement of the data set model, so that the existing system cannot access the time sequence databases and perform effective data extraction and report generation, the adaptation range of the system is limited, the integration analysis requirement of enterprises on the diversified time sequence databases cannot be met, and the efficiency of data report generation is also affected. Disclosure of Invention In view of the above, the present invention provides a method, apparatus, device and medium for accessing database, so as to solve the problem of low efficiency of database query and report generation. In a first aspect, the present invention provides a database access method, the method comprising: responding to a first query request, determining a target database corresponding to a target measuring point in the first query request, and calling a target connector for the target database; Converting the first query request into a call instruction adapting to the target database based on the target connector; initiating a second query request to the target database based on the target connector and the call instruction, and receiving an original query result returned by the target database; and processing the original query result to generate and display a target chart. The database access method includes the steps of responding to a first query request, determining a target database corresponding to a target measuring point in the first query request, calling a target connector for the target database, converting the first query request into a call instruction for adapting to the target database based on the target connector, initiating a second query request to the target database based on the target connector and the call instruction, receiving an original query result returned by the target database, and processing the original query result to generate and display a target chart. The invention adapts different types of time sequence databases through the connector, thereby realizing unified processing of the query request and the data format, and improving the efficiency of data query and report generation. In an alternative embodiment, the converting the first query request based on the target connector into a call instruction adapted to the target database includes: and mapping and packaging parameters in the first query request into a calling instruction conforming to a native query protocol of the target database based on an adaptation layer of the target connector. In an alternative embodiment, the processing the original query result to generate and display a target chart includes: Normalizing the original query result to generate structured data conforming to a preset standard format; a target graph is generated and displayed based on the structured data. In an alternative embodiment, before receiving the first query request, the method further comprises: The method comprises the steps of constructing a query model, wherein the query model comprises at least one equipment node, the equipment node comprises at least one component node, the component node comprises at least one measuring point node, and the measuring point node is configured to correspond to at least one time sequence data source in a preset database. In an alternative embodiment, the building the query model includes: Responding to a new adding operation of the equipment node, and displaying a first confi