Multi-data source visualization method, device, equipment and storage medium

By identifying and processing database operation instructions for multiple data sources, instantiating the corresponding operation templates and converting them into graph displays, the difficulty of visualizing data from multiple data sources is solved, and the support and unified management of multiple database types is realized, which reduces management Difficulty and overcomes synchronization delay and conflict issues.

CN118626697BActive Publication Date: 2024-12-17ZHONGDIAN DATA IND CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411110395.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-14
Publication Date
2024-12-17
Estimated Expiration
2044-08-14

AI Technical Summary

Technical Problem

In the case of multiple data sources, data synchronization delay, update conflicts or inconsistencies make data visualization difficult, and the prior art is difficult to effectively deal with the differences between multiple heterogeneous data sources.

Method used

By receiving database operation instructions from external data sources, identifying database types, instantiating preset operation templates, executing database operation logic, and converting the results into charts for display, the operations of different database types are uniformly managed using a common interface and factory model.

Benefits of technology

It realizes extensive support and unified management of multiple database types, reduces the difficulty of management and maintenance of data sources, overcomes data synchronization delay and update conflicts, and makes data visualization more suitable for the introduction of multiple data sources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626697B_ABST
    Figure CN118626697B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, equipment and storage medium for visualizing multiple data sources, and relates to the field of data processing technology. The method for visualizing multiple data sources includes: when calling an external data source, receiving database operation instructions corresponding to each external data source; identifying the database type of the corresponding external data source according to the database operation instruction; instantiating a preset operation template corresponding to the database type, and determining a database operation object, wherein the preset operation template includes the implementation logic of multiple database operations; executing the implementation logic of the corresponding database operation on the database operation object according to the database operation instruction, and determining the database operation result; and converting the database operation results corresponding to each external data source into a chart for display. The present application can reduce the difficulty of data visualization when multiple data sources are accessed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method, device, equipment and storage medium for visualizing multiple data sources. Background Art

[0002] With the widespread deployment of various government service platforms and the continuous improvement of data sharing mechanisms, the amount of data that government systems need to process has increased exponentially. From simple daily office data to massive information covering multiple dimensions such as people's livelihood, economy, and urban management, the scale and complexity of data have reached unprecedented levels.

[0003] The data sources of government systems are diverse, including traditional databases, API (Application Programming Interface), IoT sensors, social media and other channels. The data formats, protocols and modes of different data sources are different. In this case, the data integration solution must have extremely high flexibility and compatibility to ensure the accuracy and integrity of data during transmission and conversion. However, when multiple data sources are connected in parallel, due to the different types of databases connected, it is necessary to import multiple heterogeneous data resources, which is prone to data synchronization delays, update conflicts or inconsistencies, making it difficult to visualize data when multiple data sources are introduced.

[0004] Therefore, when accessing multiple data sources, it is difficult to visualize the data in multiple data sources, which becomes a problem that needs to be solved urgently.

[0005] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention

[0006] The main purpose of the present application is to provide a multi-data source visualization method, device, equipment and storage medium, aiming to solve the technical problem of the difficulty of visualizing data in multiple data sources when accessing multiple data sources.

[0007] To achieve the above objectives, the present application proposes a multi-data source visualization method, which includes:

[0008] When calling an external data source, receiving a database operation instruction corresponding to each of the external data sources;

[0009] Identify the database type of the corresponding external data source according to the database operation instruction;

[0010] Instantiating a preset operation template corresponding to the database type to determine a database operation object, wherein the preset operation template includes implementation logics of multiple database operations;

[0011] Executing the implementation logic of the corresponding database operation on the database operation object according to the database operation instruction to determine the database operation result;

[0012] The database operation results corresponding to each of the external data sources are converted into charts for display.

[0013] In one embodiment, before the step of receiving the database operation instruction corresponding to the external data source when calling the external data source, the method further includes:

[0014] Creating a general interface, in which operation types of database operations are defined;

[0015] Creating an original model, creating an initial operation template corresponding to each database type in the original model, and writing the implementation logic of the database operation of each operation type in the universal interface into each initial operation template, and determining a preset operation template;

[0016] A factory model is created, and the instantiation method of the preset operation template corresponding to each database type is determined according to the factory model.

[0017] In one embodiment, after the step of identifying the database type of the corresponding external data source according to the database operation instruction, the method further includes:

[0018] If there is no preset operation template corresponding to the database type of the external data source in the original model, the database type of the external data source is used as a newly added database type;

[0019] Determine the implementation logic of database operations of all operation types from the reference document of the newly added database type, create an initial operation template of the newly added database type in the original model, write the implementation logic into the initial operation template, and determine a preset operation template of the newly added database type;

[0020] The instantiation method of the preset operation template corresponding to the newly added database type is written into the factory model.

[0021] In one embodiment, the step of executing the implementation logic of the corresponding database operation on the database operation object according to the database operation instruction to determine the database operation result includes:

[0022] Determine the operation type of the database operation according to the database operation instruction;

[0023] If the operation type is connection or disconnection, the connection or disconnection implementation logic is executed on the database operation object, and after the database connection or disconnection with the data source is successfully completed, the next database operation instruction is received, and the following steps are executed: according to the database operation instruction, the database type of the corresponding external data source is identified;

[0024] If the operation type is query or update, the implementation logic of query or update is executed on the database operation object according to the database operation instruction, and the database data returned after successful execution is obtained, and the database data is used as the database operation result.

[0025] In one embodiment, the step of executing the implementation logic of querying or updating the database operation object according to the database operation instruction and obtaining the database data returned after successful execution includes:

[0026] Parsing the database operation instruction to determine database operation parameters, wherein the database operation parameters at least include operation type, target table, condition parameter, and return field;

[0027] Determine the implementation logic of the database operation whose operation type is query or update in the preset operation template;

[0028] Constructing a database operation statement according to the database operation parameters and the implementation logic;

[0029] The database operation object is called to execute the database operation statement, and the database data returned by the database is obtained.

[0030] In one embodiment, the step of identifying the database type of the corresponding external data source according to the database operation instruction includes:

[0031] Extracting an instruction feature from the database operation instruction, wherein the instruction feature is at least one of a keyword and a syntax;

[0032] Matching the instruction feature with features of known database types in a preset matching rule library;

[0033] If the match is successful, the database type of the external data source is determined based on the known database type.

[0034] In one embodiment, the step of converting the database operation results corresponding to each of the external data sources into a chart for display includes:

[0035] Detecting a chart drawing instruction and obtaining a chart template generated by the chart drawing instruction;

[0036] Determining a display position of each of the external data sources in the chart template;

[0037] The corresponding database operation results are displayed at the display positions corresponding to the external data sources.

[0038] In addition, to achieve the above-mentioned purpose, the present application also proposes a multi-data source visualization device, the multi-data source visualization device comprising:

[0039] A receiving module, used for receiving database operation instructions corresponding to each external data source when calling the external data source;

[0040] An identification module, used to identify the database type of the corresponding external data source according to the database operation instruction;

[0041] An instantiation module, used to instantiate a preset operation template corresponding to the database type and determine a database operation object, wherein the preset operation template includes implementation logic of multiple database operations;

[0042] An operation module, used to execute the implementation logic of the corresponding database operation on the database operation object according to the database operation instruction, and determine the database operation result;

[0043] The display module is used to convert the database operation results corresponding to each of the external data sources into charts for display.

[0044] In addition, to achieve the above-mentioned purpose, the present application also proposes a multi-data source visualization device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the multi-data source visualization method as described above.

[0045] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the multi-data source visualization method described above are implemented.

[0046] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of the multi-data source visualization method described above are implemented.

[0047] In the present application, when calling an external data source, a database operation instruction corresponding to each external data source is received; the database type of the corresponding external data source is identified according to the database operation instruction; the preset operation template corresponding to the database type is instantiated to determine the database operation object, wherein the preset operation template includes the implementation logic of multiple database operations; the implementation logic of the corresponding database operation is executed on the database operation object according to the database operation instruction to determine the database operation result; and the database operation result corresponding to each external data source is converted into a chart for display. The present application dynamically identifies the database type through the received database operation instruction, generates a database operation object based on the database type, and executes the database operation according to the database operation object. It can adapt to database operations of different database types, realizes extensive support and unified management of database operations of multiple database types, and the database operation based on the unified interface can separate the database operation of each database type, reduce the management and maintenance difficulty of each data source, thereby overcoming the problems of data synchronization delay, update conflict or inconsistency, and making data visualization more adaptable to the situation where multiple data sources are introduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0049] In order to more clearly illustrate the embodiments of the present application 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, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0050] Figure 1 A flowchart of the first embodiment of the method for visualizing multiple data sources in this application;

[0051] Figure 2 A visualization process diagram provided for the first embodiment of the multi-data source visualization method of the present application;

[0052] Figure 3 A flowchart of the second embodiment of the multi-data source visualization method of the present application is provided;

[0053] Figure 4 This is a schematic diagram of the module structure of a multi-data source visualization device according to an embodiment of the present application;

[0054] Figure 5 Schematic diagram of the device structure of the hardware operating environment involved in the multi-data source visualization method in the embodiment of the present application.

[0055] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0056] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0057] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0058] The present application embodiment provides a method for visualizing multiple data sources. Figure 1 , Figure 1 This is a flowchart of the first embodiment of the multi-data source visualization method of the present application.

[0059] In this embodiment, the multi-data source visualization method includes steps S10 to S50:

[0060] Step S10, when calling an external data source, receiving a database operation instruction corresponding to each external data source;

[0061] It should be noted that external data sources refer to data sets stored outside the enterprise or provided by a third party. These data are not directly controlled by the system, but are crucial to the realization of system functions. They can be cloud databases, data returned by API interfaces, data files in remote file systems, etc. There are various types of external data sources, which may include relational databases (such as MySQL, PostgreSQL), NoSQL databases (such as MongoDB, Cassandra), big data platforms (such as Hadoop HDFS, Spark), etc. Each database has a different set of operation instructions and protocols. Database operation instructions usually refer to SQL statements or other database-specific languages, which are used to perform operations such as data retrieval (SELECT), data insertion (INSERT), update (UPDATE), and deletion (DELETE). Although basic SQL (Structured Query Language) statements are common in most relational databases, there are still syntax differences between different database systems, especially advanced features and optimized syntax. Therefore, when receiving instructions, it is necessary to parse the instructions to adapt to the characteristics of different databases.

[0062] Step S20, identifying the database type of the corresponding external data source according to the database operation instruction;

[0063] It should be noted that the database type and the database operation instruction are matched, and the database operation instruction can identify the matched database type, which is the database type of the corresponding external source data. Specifically, the analysis can be performed based on the keywords or specific grammatical structures in the instruction. For example, functions, keywords or data types that are unique to certain database systems can be used as identification marks. Regular expressions or pattern matching algorithms can also be used to identify specific SQL grammatical patterns.

[0064] In a feasible implementation, step S20 may include steps S21 to S23:

[0065] Step S21, extracting instruction features from the database operation instructions, where the instruction features are at least one of a keyword and a syntax;

[0066] It should be noted that database operation instructions often contain specific keywords, which define the type of operation, such as SELECT, INSERT, UPDATE, DELETE, etc. Different keywords correspond to different aspects of database operations, such as data retrieval, data insertion, data modification or data deletion. In addition to keywords, the grammatical structure of the instruction is also part of feature extraction, including identifying table names, field names, conditional expressions, function calls, etc. For example, extracting conditional expressions from the WHERE clause can help understand the specific conditions of the query. Different database systems may have different grammatical rules. By analyzing the grammatical structure of the instruction, you can further accurately match the operational grammatical characteristics of a specific database.

[0067] Step S22, matching the instruction feature with the feature of the known database type in the preset matching rule library;

[0068] It should be noted that by comparing the command features with the preset rule base, it can automatically identify which database management system the database operation command is applicable to, such as MySQL, PostgreSQL, Oracle, SQL Server, etc. After identifying the database type, the corresponding driver, syntax parsing rules and optimization strategies can be used in a targeted manner to ensure the correct execution of the operation command. The matching rule base is usually manually constructed by database experts based on the characteristics of various database management systems and the differences in standard SQL syntax, and contains keywords, functions, syntax structures and other features unique to various databases.

[0069] Step S23: If the match is successful, the database type of the external data source is determined according to the known database type.

[0070] Once the match is successful, the system will know exactly which database type the external data source belongs to, such as MySQL, PostgreSQL, SQLServer, Oracle, etc.

[0071] In this implementation, without knowing or determining the type of the external data source, its database type is adaptively identified, thereby improving the flexibility and compatibility of the system, reducing the risk of manual configuration errors, and improving the automation and efficiency of data operations.

[0072] Step S30, instantiating a preset operation template corresponding to the database type to determine a database operation object, wherein the preset operation template includes implementation logics of multiple database operations;

[0073] It should be noted that the preset operation template is an application of a design pattern, which defines a series of common interfaces or abstract classes for database operations, such as query, insert, update, delete, etc. These templates provide consistent interfaces for operations of different database types, but the specific implementation details (logic) vary according to the type of database. Each operation template encapsulates the logic of performing operations on a specific database, including establishing a database connection, generating and executing SQL statements, processing result sets, etc. These logics are customized according to the specific requirements of the database type, ensuring the compatibility and efficiency of the operation.

[0074] In order to dynamically create the correct database operation object according to the database type, the factory pattern or abstract factory pattern is usually used. The factory class returns the corresponding database operation object instance based on the database type parameter passed in. Specifically, there will be a mapping mechanism inside the factory class to map the database type to the corresponding operation template class. When an operation object of a specific database type is requested, the factory method will check this mapping, instantiate the corresponding operation template class, and return this instance.

[0075] The database operation object is a specific object instantiated from the preset operation template, and has the ability to perform database operations. This object contains specific methods for performing operations such as query and update, which are implemented according to the logic defined in the preset template. In this way, the system can dynamically create and use operation objects of different database types as needed at runtime, without the need to hard-code specific database operation logic at compile time, which improves the flexibility and scalability of the system.

[0076] The preset operation template not only defines the operation interface, but also contains the implementation details for different databases. For example, for query operations, the implementation of MySQL may need to consider its unique SQL syntax and functions, while the implementation of PostgreSQL must comply with its own specifications.

[0077] Step S40, executing the implementation logic of the corresponding database operation on the database operation object according to the database operation instruction, and determining the database operation result;

[0078] It should be noted that the database operation instruction needs to be parsed first to clarify the intention of the operation (such as query, insert, update or delete), as well as the object of the operation (table name, column name, etc.) and conditions (such as WHERE clause). After the parsing is completed, the system needs to map the operation instruction to the corresponding method on the database operation object. For example, an instruction of "query all users" will be mapped to the query method of the operation object, and the corresponding query conditions will be passed in. The database operation object already contains the implementation logic of various database operations when instantiated (such as step S30). Here, according to the specific content of the instruction, the corresponding logic method is called. For SQL databases, the operation object may generate the corresponding SQL statement according to the instruction, and then use the database driver to execute this SQL. If it is a NoSQL database or other type of database, the operation logic will perform the corresponding operation according to the characteristics of the database, such as document retrieval, key-value pair operation, etc. After the operation is executed, the system needs to collect the results of the operation. For query operations, the result set is obtained and processed; for insert, update, and delete operations, the number of rows affected or the confirmation status is returned.

[0079] Step S50: converting the database operation results corresponding to each external data source into a chart for display.

[0080] It should be noted that most modern front-end development frameworks or visualization libraries (such as ECharts, D3.js, Highcharts, etc.) have a rich set of built-in chart templates, covering a variety of common chart types such as line charts, bar charts, pie charts, scatter charts, etc. Developers can choose the template that best meets the current data display needs from these libraries. In addition to using preset templates, you can also design customized chart styles and layouts based on historical project experience or specific business needs to form custom templates.

[0081] Some visualization platforms or services allow you to directly request specific chart templates through the API interface by passing the necessary parameters. In the actual project code, you can introduce specific classes or components to customize the appearance and behavior of the chart by configuring parameters.

[0082] After obtaining the template, you need to bind the data from the external data source to the chart template to achieve dynamic data loading and updating.

[0083] Bind the database operation results to the front-end chart template. After data binding is completed, the front-end framework or library (such as ECharts, D3.js, Chart.js) will dynamically generate HTML, SVG (Scalable Vector Graphics) or Canvas elements based on the data and template definition to achieve visual display of charts in web pages or applications.

[0084] In order to improve the user experience, charts usually need to implement interactive functions, such as zooming, dragging to view data in different time periods, clicking on the legend to filter data series, hovering to display detailed information, etc. The corresponding event listeners and processing logic can be implemented in the front-end code.

[0085] In one possible implementation, see Figure 2 , step S50 may include steps S51 to S53:

[0086] Step S51, detecting a chart drawing instruction and obtaining a chart template generated by the chart drawing instruction;

[0087] It should be noted that chart drawing instructions may come from multiple channels, including user operations through the graphical interface, API calls, scheduled task execution, etc. Chart templates include line charts, bar charts, pie charts, scatter charts, etc. Each template defines the basic structure, color configuration, font style, etc. of the chart. For some highly customized requirements, templates can be generated dynamically, and chart templates that meet the requirements can be combined in real time based on the parsed instruction parameters. Or according to the specific requirements of the instruction, the most suitable template can be selected or generated from the template library.

[0088] Step S52, determining the display position of each external data source in the chart template;

[0089] It should be noted that the system will map the data fields in the external data source to the data points required by the chart template. For example, if the chart is a line chart, the time series data will be mapped to the X-axis, and the numerical data will be mapped to the Y-axis.

[0090] Step S53: display the corresponding database operation results at the display positions corresponding to the external data sources.

[0091] It should be noted that before displaying, the relevant database operation results need to be extracted from the database, and the processed database operation results need to match the format required by the chart template. Based on the display position determined in step S52, the system uses a graphics library or a drawing API to dynamically "fill" the processed database operation results into the chart template.

[0092] In this embodiment, the system monitors and captures a chart drawing instruction, which is usually triggered by the user through the front-end interface operation, or executed by the back-end logic as planned. According to the received instruction, the system automatically or manually selects a predefined chart template. The template defines the basic structure, color scheme, legend layout, etc. of the chart, which is the basic framework for chart display; the system analyzes the chart template and maps the data of each external data source to the corresponding part in the template according to the data dimension specified in the instruction; according to the layout determined in step S52, the system directly injects the database operation results of each external data source into the corresponding position of the chart template. After completing the data filling, the system uses the functions of the chart library (such as D3.js, ECharts, etc.) to dynamically generate the final chart view and display it in real time in the specified area of ​​the user interface. It can efficiently and accurately convert complex database operation results into a chart form that is easy for users to understand and analyze.

[0093] In this embodiment, when calling an external data source, a database operation instruction corresponding to each external data source is received; the database type of the corresponding external data source is identified according to the database operation instruction; the preset operation template corresponding to the database type is instantiated to determine the database operation object, wherein the preset operation template includes the implementation logic of multiple database operations; the implementation logic of the corresponding database operation is executed on the database operation object according to the database operation instruction to determine the database operation result; and the database operation result corresponding to each external data source is converted into a chart for display. The present application dynamically identifies the database type through the received database operation instruction, generates a database operation object based on the database type, and executes the database operation according to the database operation object, which can adapt to the database operation of different database types, realizes the extensive support and unified management of the database operation of multiple database types, and the database operation based on the unified interface can separate the database operation of each database type, reduce the management difficulty and maintenance difficulty of each data source, thereby overcoming the problems of data synchronization delay, update conflict or inconsistency, making data visualization more adaptable to the situation of introducing multiple data sources, making data visualization more adaptable to the situation of introducing multiple data sources.

[0094] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 3 Before step S10, the multi-data source visualization method further includes steps S01 to S03:

[0095] Step S01, creating a general interface, defining the operation type of database operation in the general interface, wherein the database operation type at least includes connection, disconnection, query and update;

[0096] It should be noted that when performing data integration or data processing, the system needs to interact with different data sources, which may include but are not limited to relational databases (such as MySQL, PostgreSQL), NoSQL databases (such as MongoDB), APIs, file systems, etc. Each data source has different access methods and operation logic. In order to uniformly manage these differences and reduce the coupling between upper-level applications and data sources, it is particularly important to define a set of standard common interfaces.

[0097] In the common interface, define the types of database operations that the data source should be able to implement. This interface defines the standard way for upper-level applications to interact with data sources, and does not involve specific implementation details. Database operation types include connect, disconnect, query, and update. Among them, Connect can provide methods for establishing a connection with a data source. This operation usually requires parameters such as the database address, user name, and password, and returns an object representing the connection status; Disconnect defines methods for safely closing the connection with the data source and releasing resources; Query defines methods for executing SQL queries or other data retrieval operations, usually accepting SQL statements as parameters and returning query result sets; Update includes operations such as insert, update, and delete, provides methods to perform database modification operations, accepts SQL statements or specific objects as parameters, and returns the number of rows or status information affected by the operation.

[0098] As an example, the code for a common interface definition can be:

[0099] public interface DataSourceOperations {

[0100] Connection connect(String url, String username, String password);

[0101] void disconnect(Connection conn);

[0102] ResultSet query(Connection conn, String query);

[0103] int update(Connection conn, String update);

[0104] / / You can add more operation methods as needed, such as batch operation, transaction processing, etc.

[0105] }

[0106] It can be understood that by defining a common interface, a clear and unified interaction specification is provided for subsequent steps. The defined interface is general enough to adapt to various types of data sources. At the same time, the interface design takes into account possible new data source types or operation types that may be added in the future, making it easy to expand.

[0107] Step S02, creating an original model, creating an initial operation template corresponding to each database type in the original model, and writing the implementation logic of the database operation of each operation type in the universal interface into each initial operation template, and determining a preset operation template;

[0108] It should be noted that the original model is an abstract conceptual model that can identify each database type (such as MySQL, PostgreSQL, etc.) that the system needs to support based on the interface defined in step S01. Create a specific class for each database type. These classes correspond to the original model and will implement the common interface defined in step S01. For example, for the MySQL database, you can create a class called MySQLDataAccessImpl; for PostgreSQL, create a PostgreSQLDataAccessImpl class.

[0109] In each specific class, all methods declared in the interface are implemented as operation steps, including writing implementation logic for operations such as connecting to the database, executing queries, and updating data. For example, in the MySQLDataAccessImpl class, methods for connecting to the database may include using the JDBC driver to establish a connection, executing SQL statements, and other operations.

[0110] As an example, the code for the MySQL class could be:

[0111] class MySQLDataAccessImpl implements DataSourceOperations {

[0112] public Connection connect(String url, String username, Stringpassword) {

[0113] / / Implement the connection logic of MySQL database

[0114] }

[0115] / / Implementation of other database operation methods...

[0116] }

[0117] It can be understood that the general database operation interface (such as connection, disconnection, query, update, etc.) defined in step S01 is converted into operation steps for each database, so that the multi-data source visualization method can be compatible with multiple databases such as MySQL, PostgreSQL, SQL Server, etc. By creating an independent processing operation template for each database type, the system can more easily add support for new database types by simply adding a new implementation class without modifying the existing code, thereby enhancing the flexibility and maintainability of the system.

[0118] Step S03: Create a factory model, and determine the instantiation method of the preset operation template corresponding to each database type according to the factory model.

[0119] It should be noted that in some complex scenarios, you can first define a factory interface or abstract factory class, that is, create a factory model and declare a method to create a data access instance, such as createDataAccess(String dbType). Then create a specific factory class (such as DatabaseAccessFactory), which is responsible for creating the corresponding database operation object according to the database type. In the factory model method, based on the incoming database type string (such as "MySQL", "PostgreSQL", etc.), decide which specific preset operation template to instantiate, usually through conditional statements (such as if-else, switch-case) or using mapping relationships (such as HashMap).

[0120] As an example, the code of the factory model can be:

[0121] class DatabaseAccessFactory {

[0122] public DataSourceOperations createDataSource(String dbType) {

[0123] if ("MySQL".equals(dbType)) {

[0124] return new MySQLDataSource();

[0125] } else if ("PostgreSQL".equals(dbType)) {

[0126] return new PostgreSQLDataSource();

[0127] } else {

[0128] throw new IllegalArgumentException("Unsupported database type: " +dbType);

[0129] }

[0130] }

[0131] }

[0132] It is understandable that through the factory pattern, in the client code, the specific database operation class is no longer directly instantiated, but the factory method is called to obtain the operation object. In this way, the client's dependence on the specific database operation class is eliminated, the code is more concise and easy to maintain, and the database type can be isolated from the creation process of the specific implementation, so that the high-level business logic does not need to understand the creation details of the specific implementation, reducing the coupling between modules. The factory model is responsible for instantiating the preset operation templates corresponding to different database types, which is easy to manage and maintain. Especially when it is necessary to support more database types, you only need to expand the factory model and add the preset operation templates corresponding to the database type in the original model. There is no need to modify the existing code, which is easy to expand.

[0133] In this embodiment, a general interface is created, and the operation type of database operation is defined in the general interface. The purpose is to provide a set of standard APIs so that database operations of different database types can be called in the same way, thereby reducing the coupling between the upper-level business code and the specific database implementation; an original model is created, and an initial operation template corresponding to each database type is created in the original model, and the implementation logic of the database operation of each operation type in the general interface is written into each initial operation template, and preset operation templates are determined. These preset operation templates can implement the general interface defined in step S01, and can be optimized according to the characteristics of each database to ensure efficient execution of database operations; a factory model is created, and the instantiation method of the preset operation template corresponding to each database type is determined based on the factory model, and a unified interface is provided to create instances of preset operation templates of different database types, thereby avoiding hard coding of directly instantiating specific classes and enhancing the flexibility and maintainability of the code.

[0134] In a feasible implementation manner, after step S20, steps A10 to A30 are further included:

[0135] Step A10: if there is no preset operation template corresponding to the database type of the external data source in the original model, the database type of the external data source is used as a newly added database type;

[0136] It should be noted that the goal of step A10 is to find that when the system attempts to interact with an external data source, it finds that the original model does not contain the preset operation template for the database type used by the data source. At this time, the system needs to be able to identify this situation and take measures to deal with it.

[0137] The system first checks the received database operation instructions or identification information of the external data source and compares it with the list of preset operation templates in the original model. The original model usually includes support for known database types (such as MySQL, PostgreSQL, etc.), each of which has a corresponding template that defines how to connect, query, update, etc. If it is found that the database type of the external data source is not in the existing template list, the system marks this type as a new database type.

[0138] Step A20, determining the implementation logic of database operations of all operation types from the reference document of the newly added database type, creating an initial operation template of the newly added database type in the original model, writing the implementation logic into the initial operation template, and determining a preset operation template of the newly added database type;

[0139] It should be noted that developers need to obtain detailed reference documents from the official website of the newly added database type, the developer community, or the officially released guide. These documents usually contain database installation, configuration, API interface, SQL syntax, best practices, etc. Specifically, based on the operation types defined in the original model (such as connection, disconnection, query, update, etc.), identify and sort out the implementation logic corresponding to these operations in the reference documents. According to the reference documents, determine the specific implementation logic for each operation type.

[0140] In the original model, an initial operation template is designed for the newly added database type. This template is the basic framework for the operation implementation of this database type, and usually inherits or implements a common interface to ensure the standardization and compatibility of operations. The determined implementation logic is encoded and filled into the initial operation template.

[0141] Step A30, writing the instantiation method of the preset operation template corresponding to the newly added database type into the factory model.

[0142] It should be noted that for the newly added database type, the instantiation method of the preset operation template is designed, including the definition of the method signature, parameters, initialization process, etc. for creating the database operation object of this type. It is necessary to ensure that the instantiation logic can correctly call the method in the preset operation template and handle the necessary parameter transfer and resource initialization.

[0143] In this embodiment, when the system encounters a database type that is not preset, it dynamically expands its compatibility and processing capabilities, from identification, evaluation to the final implementation of the entire process of supporting new types of databases. In this way, the system can more flexibly adapt to different data source environments and maintain a high degree of scalability and flexibility.

[0144] In a feasible implementation manner, step S40 includes steps S41 to S43:

[0145] Step S41, determining the operation type of the database operation according to the database operation instruction;

[0146] It should be noted that a database operation instruction may be a SQL statement, an API call parameter, or a command string in a specific format. By scanning the instruction, key operation keywords are identified. For example, "SELECT" usually indicates a query operation, "INSERT" or "UPDATE" refers to inserting or updating data, "DELETE" means deleting a record, and "CONNECT" and "DISCONNECT" are used to establish and disconnect database connections, respectively.

[0147] Step S42, if the operation type is connection or disconnection, the connection or disconnection implementation logic is executed on the database operation object, and after the database connection or disconnection with the data source is successfully established or successfully disconnected, the next database operation instruction is received, and the following steps are executed: the database type of the corresponding external data source is identified according to the database operation instruction;

[0148] It should be noted that if the operation type is to connect, the connection method is called through the database operation object, and the necessary connection parameters (such as database URL, user name, password, etc.) are passed in to try to establish a connection with the specified data source; if the operation type is to disconnect, the disconnect method is also called through the database operation object to release database resources. After a successful connection or disconnection, the system usually receives a success status signal or exception feedback. Success means that other database operations can continue; failure may require recording error logs, attempting to retry, or throwing exceptions to the upper-level application for processing.

[0149] After the connection or disconnection operation is successfully executed, the system is ready to receive the next database operation instruction. For the newly received instruction, the logic of step S41 is executed again to identify the database type of the external data source.

[0150] Step S43, if the operation type is query or update, the implementation logic of query or update is executed on the database operation object according to the database operation instruction, and the database data returned after the execution is successful is obtained, and the database data is used as the database operation result.

[0151] It should be noted that for query operations, according to the keywords (such as SELECT) and specific query conditions in the operation instructions, the target table, field, filter conditions, sorting method and other information of the query are parsed, and the query method is called through the database operation object to pass the parsed query information to the database. After the query is successful, the system will receive the query result set from the database as the database operation result. For update operations (such as INSERT, UPDATE, DELETE), the system parses the instructions to determine the table, field, condition and new value to be modified. The update operation is performed through the database operation object.

[0152] After the operation is successful, the system will encapsulate the acquired data or operation status as the database operation result.

[0153] In this embodiment, through a flexible processing mechanism for database operation instructions, corresponding actions can be taken according to different operation types to ensure efficient and accurate data access.

[0154] In a feasible implementation, step S43 may include steps S431 to S434:

[0155] Step S431, parsing the database operation instruction to determine the database operation parameters, wherein the database operation parameters at least include the operation type, target table, condition parameter, and return field;

[0156] Step S432, determining the implementation logic of the database operation whose operation type is query or update in the preset operation template;

[0157] Step S433, constructing a database operation statement according to the database operation parameters and implementation logic;

[0158] Step S434, calling the database operation object to execute the database operation statement, and obtaining the database data returned by the database.

[0159] In this implementation, the received database operation instruction is carefully analyzed, key parameters are identified and extracted, and the parameters parsed from step S431 are used in combination with the operation logic template determined in step S432 to dynamically construct a complete database operation statement, and the database operation statement constructed in step S433 is executed through the established database operation object. After the execution is completed, a response is received from the database, which is usually a set of records that meet the conditions for query operations; for update operations, it is the number of affected rows or other operation status information, which are then further processed by the system as database operation results or returned to the upper-level application. This implementation can interact with the database flexibly and efficiently, and ensures the accuracy and efficiency of the operation, whether reading data or updating data.

[0160] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the multi-data source visualization method of the present application. More simple transformations based on this technical concept are all within the protection scope of the present application.

[0161] This application also provides a multi-data source visualization device, please refer to Figure 4 , the multi-data source visualization device includes:

[0162] The receiving module 10 is used to receive the database operation instructions corresponding to each external data source when calling the external data source;

[0163] An identification module 20, configured to identify the database type of the corresponding external data source according to the database operation instruction;

[0164] An instantiation module 30, configured to instantiate a preset operation template corresponding to the database type and determine a database operation object, wherein the preset operation template includes implementation logics of multiple database operations;

[0165] An operation module 40 is used to execute the implementation logic of the corresponding database operation on the database operation object according to the database operation instruction, and determine the database operation result;

[0166] The display module 50 is used to convert the database operation results corresponding to each of the external data sources into charts for display.

[0167] The multi-data source visualization device provided by the present application adopts the multi-data source visualization method in the above embodiment, which can solve the technical problem that it is difficult to visualize the data in the multi-data source when accessing the multi-data source. Compared with the prior art, the beneficial effects of the multi-data source visualization device provided by the present application are the same as the beneficial effects of the multi-data source visualization method provided by the above embodiment, and other technical features in the multi-data source visualization device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0168] The present application provides a multi-data source visualization device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute the multi-data source visualization method in the above-mentioned embodiment 1.

[0169] Reference below Figure 5, which shows a schematic diagram of the structure of a multi-data source visualization device suitable for implementing the embodiment of the present application. The multi-data source visualization device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The multi-data source visualization device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0170] like Figure 5 As shown, the multi-data source visualization device may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the multi-data source visualization device are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 may allow the multi-data source visualization device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows a multi-data source visualization device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have instead.

[0171] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0172] The multi-data source visualization device provided by the present application adopts the multi-data source visualization method in the above embodiment, which can solve the technical problem of the difficulty of visualizing the data in the multi-data source when accessing the multi-data source. Compared with the prior art, the beneficial effects of the multi-data source visualization device provided by the present application are the same as the beneficial effects of the multi-data source visualization method provided by the above embodiment, and other technical features in the multi-data source visualization device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0173] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0174] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0175] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, the computer-readable program instructions being used to execute the multi-data source visualization method in the above-mentioned embodiment.

[0176] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned multi-data source visualization method, and can solve the technical problem that it is difficult to visualize the data in the multi-data source when accessing the multi-data source. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the present application are the same as the beneficial effects of the multi-data source visualization method provided in the above-mentioned embodiment, and will not be repeated here.

[0177] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned multi-data source visualization method when executed by a processor.

[0178] The computer program product provided by the present application can solve the technical problem that it is difficult to visualize the data in multiple data sources when accessing multiple data sources. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the multiple data source visualization method provided by the above embodiment, and will not be repeated here.

[0179] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A method for visualizing multiple data sources, It is characterized in that The multi-data source visualization method comprises: When calling an external data source, receiving a database operation instruction corresponding to each of the external data sources; Identify the database type of the corresponding external data source according to the database operation instruction; Instantiating a preset operation template corresponding to the database type, and determining a database operation object, wherein the preset operation template includes implementation logics of multiple database operations, and the database operation object is a specific object instantiated from the preset operation template, includes implementation logics of multiple database operations, and can execute database operations; Determine a database operation result according to the implementation logic of the database operation corresponding to the database operation object of the database operation instruction; Convert the database operation results corresponding to each of the external data sources into charts for display; Wherein, before the step of receiving the database operation instruction corresponding to the external data source when calling the external data source, the method further includes: Creating a general interface, in which operation types of database operations are defined; Creating an original model, creating an initial operation template corresponding to each database type in the original model, and writing the implementation logic of the database operation of each operation type in the universal interface into each initial operation template, and determining a preset operation template; Creating a factory model, and determining the instantiation method of the preset operation template corresponding to each database type according to the factory model; Wherein, after the step of identifying the database type of the corresponding external data source according to the database operation instruction, the method further includes: If there is no preset operation template corresponding to the database type of the external data source in the original model, the database type of the external data source is used as a newly added database type; Determine the implementation logic of database operations of all operation types from the reference document of the newly added database type, create an initial operation template of the newly added database type in the original model, write the implementation logic into the initial operation template, and determine a preset operation template of the newly added database type; Writing the instantiation method of the preset operation template corresponding to the newly added database type into the factory model; The step of executing the implementation logic of the corresponding database operation on the database operation object according to the database operation instruction to determine the database operation result includes: Determine the operation type of the database operation according to the database operation instruction; If the operation type is connection or disconnection, the connection or disconnection implementation logic is executed on the database operation object, and after the database connection or disconnection with the data source is successfully completed, the next database operation instruction is received, and the following steps are executed: according to the database operation instruction, the database type of the corresponding external data source is identified; If the operation type is query or update, the implementation logic of query or update is executed on the database operation object according to the database operation instruction, and the database data returned after the execution is successful is obtained, and the database data is used as the database operation result; The step of converting the database operation results corresponding to each of the external data sources into a chart for display includes: Detecting a chart drawing instruction and obtaining a chart template generated by the chart drawing instruction; Determining a display position of each of the external data sources in the chart template; The corresponding database operation results are displayed at the display positions corresponding to the external data sources.

2. The method for visualizing multiple data sources according to claim 1, It is characterized in that The step of executing the implementation logic of querying or updating the database operation object according to the database operation instruction and obtaining the database data returned after successful execution includes: Parsing the database operation instruction to determine database operation parameters, wherein the database operation parameters at least include operation type, target table, condition parameter, and return field; Determine the implementation logic of the database operation whose operation type is query or update in the preset operation template; Constructing a database operation statement according to the database operation parameters and the implementation logic; The database operation object is called to execute the database operation statement, and the database data returned by the database is obtained.

3. The method for visualizing multiple data sources according to claim 1, It is characterized in that The step of identifying the database type of the corresponding external data source according to the database operation instruction includes: Extracting an instruction feature from the database operation instruction, wherein the instruction feature is at least one of a keyword and a syntax; Matching the instruction feature with features of known database types in a preset matching rule library; If the match is successful, the database type of the external data source is determined based on the known database type.

4. A multi-data source visualization device, It is characterized in that The multi-data source visualization device comprises: A receiving module, used for receiving database operation instructions corresponding to each external data source when calling the external data source; An identification module, used to identify the database type of the corresponding external data source according to the database operation instruction; An instantiation module, used to instantiate a preset operation template corresponding to the database type and determine a database operation object, wherein the preset operation template includes the implementation logic of multiple database operations, and the database operation object is a specific object instantiated from the preset operation template, contains the implementation logic of multiple database operations, and can perform database operations; An operation module, used to execute the implementation logic of the corresponding database operation on the database operation object according to the database operation instruction, and determine the database operation result; A display module, used to convert the database operation results corresponding to each of the external data sources into charts for display; Wherein, the multi-data source visualization device is also used for: Creating a general interface, in which operation types of database operations are defined; Creating an original model, creating an initial operation template corresponding to each database type in the original model, and writing the implementation logic of the database operation of each operation type in the universal interface into each initial operation template, and determining a preset operation template; Creating a factory model, and determining the instantiation method of the preset operation template corresponding to each database type according to the factory model; Wherein, the multi-data source visualization device is also used for: If there is no preset operation template corresponding to the database type of the external data source in the original model, the database type of the external data source is used as a newly added database type; Determine the implementation logic of database operations of all operation types from the reference document of the newly added database type, create an initial operation template of the newly added database type in the original model, write the implementation logic into the initial operation template, and determine a preset operation template of the newly added database type; Writing the instantiation method of the preset operation template corresponding to the newly added database type into the factory model; Wherein, the operation module is specifically used for: Determine the operation type of the database operation according to the database operation instruction; If the operation type is connection or disconnection, the connection or disconnection implementation logic is executed on the database operation object, and after the database connection or disconnection with the data source is successfully completed, the next database operation instruction is received, and the following steps are executed: according to the database operation instruction, the database type of the corresponding external data source is identified; If the operation type is query or update, the implementation logic of query or update is executed on the database operation object according to the database operation instruction, and the database data returned after the execution is successful is obtained, and the database data is used as the database operation result; Wherein, the display module is specifically used for: Detecting a chart drawing instruction and obtaining a chart template generated by the chart drawing instruction; Determining a display position of each of the external data sources in the chart template; The corresponding database operation results are displayed at the display positions corresponding to the external data sources.

5. A multi-data source visualization device, It is characterized in that The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the multi-data source visualization method according to any one of claims 1 to 3.

6. A storage medium, It is characterized in that The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the multi-data source visualization method according to any one of claims 1 to 3 are implemented.

Citation Information

Patent Citations

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

    CN112182074A

  • Data access control method and device, electronic equipment and storage medium

    CN116257542A

  • SQL conversion method and device, computer equipment and storage medium

    CN117033348A

  • SQL statement generation method and device for multi-type database and storage medium

    CN117453713A

  • System and method for building a unified query that spans heterogeneous environments

    US20070208723A1