A method, device, equipment and storage medium for accessing multiple types of databases
By using technical means such as configuration information, proxy database, running sandbox and execution isolators in data processing, the query language adaptation cost and query statement execution isolation problems during access to various types of databases are solved, and more efficient and secure data processing is achieved.
Patent Information
- Application Number
- CN202411524890.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2044-10-30
AI Technical Summary
In data processing, a large amount of query language adaptation work is required when accessing multiple types of databases, resulting in waste of R&D costs, and the prior art has failed to effectively isolate the execution of multiple query statements.
By obtaining the configuration information of the target database, establishing a proxy database connection, and generating a running sandbox in the executor, reconstructing the original query statement, evaluating execution performance, establishing an execution isolator instance, isolating the running sandbox, and finally executing the target query statement in the sandbox.
It reduces the adaptation cost of users when accessing multiple types of databases, and reasonably isolates the execution of multiple query statements, improving the efficiency and security of data processing.
Smart Images

Figure CN119046308B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a method, device, equipment and storage medium for accessing multiple types of databases. Background Art
[0002] With the development of self-controllable products, many types of databases will be accessed in data processing, such as DAMO database, Renmin University Jincang database, and Jinwu database.
[0003] Due to differences in database environments, there are differences in query languages used in data queries. When a product accesses multiple databases, a lot of query language adaptation work is required, resulting in a waste of R&D costs.
[0004] Furthermore, in the specific data query of the prior art, the execution of multiple query statements is not reasonably isolated. Summary of the invention
[0005] The present invention provides a method, device, equipment and storage medium for accessing multiple types of databases, so as to reduce the adaptation cost when users access multiple types of databases and reasonably isolate the execution of multiple query statements.
[0006] According to one aspect of the present invention, a method for accessing multiple types of databases is provided, the method comprising:
[0007] In response to a user's access request to a target type database among the multiple types of databases, obtaining configuration information of the target type database;
[0008] Establishing a connection with a proxy database of the target type database according to the configuration information, and generating a corresponding running sandbox in the executor;
[0009] Obtaining an original query statement corresponding to the access request, and reconstructing the original query statement to generate a target query statement;
[0010] Determine, in the historical query statements, related query statements similar to the target query statement, and evaluate the execution performance of the target query statement according to each of the related query statements;
[0011] According to the execution performance, establishing an execution isolator instance in the executor; using the execution isolator to isolate the running sandbox in the executor;
[0012] The target query statement is executed in the running sandbox to access the proxy database corresponding to the target type database.
[0013] According to another aspect of the present invention, there is provided a device for accessing multiple types of databases, the device comprising:
[0014] A configuration information acquisition module, configured to respond to a user's access request to a target type database among multiple types of databases and acquire configuration information of the target type database;
[0015] An operation sandbox generation module is used to establish a connection with a proxy database of the target type database according to the configuration information, and generate a corresponding operation sandbox in the executor;
[0016] A target query statement generating module, used to obtain an original query statement corresponding to the access request, and reconstruct the original query statement to generate a target query statement;
[0017] An execution performance evaluation module, used to determine, in historical query statements, related query statements similar to the target query statement, and evaluate the execution performance of the target query statement based on each of the related query statements;
[0018] An executor isolation module, used to establish an execution isolator instance in the executor according to the execution performance; and to isolate the running sandbox in the executor using the execution isolator;
[0019] The query statement execution module is used to execute the target query statement in the running sandbox to access the proxy database corresponding to the target type database.
[0020] According to another aspect of the present invention, there is provided an electronic device, the electronic device comprising:
[0021] at least one processor; and
[0022] a memory communicatively connected to the at least one processor; wherein,
[0023] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method for accessing multiple types of databases described in any embodiment of the present invention.
[0024] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for accessing multiple types of databases described in any embodiment of the present invention when executed.
[0025] According to another aspect of the present invention, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the method for accessing multiple types of databases as described in any embodiment of the present invention.
[0026] The technical solution of the embodiment of the present invention obtains the configuration information of the target type database in response to the user's access request to the target type database among multiple types of databases; establishes a connection with the proxy database of the target type database according to the configuration information, and generates a corresponding running sandbox in the executor; obtains the original query statement corresponding to the access request, and reconstructs the original query statement to generate a target query statement; determines the associated query statement similar to the target query statement in the historical query statements, and evaluates the execution performance of the target query statement according to each of the associated query statements; establishes an execution isolator instance in the executor according to the execution performance; uses the execution isolator to isolate the running sandbox in the executor; executes the target query statement in the running sandbox to access the proxy database corresponding to the target type database, thereby solving the access problem to multiple types of autonomous and controllable databases, reducing the adaptation cost when users access multiple types of databases, and reasonably isolating the execution of multiple query statements.
[0027] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0029] Figure 1 is a flow chart of a method for accessing multiple types of databases provided according to an embodiment of the present invention;
[0030] Figure 2 is an application example diagram of a method for accessing multiple types of databases provided according to an embodiment of the present invention;
[0031] Figure 3 It is a structural diagram of a device for accessing multiple types of databases provided according to an embodiment of the present invention;
[0032] Figure 4 The present invention is a schematic diagram of the structure of an electronic device for implementing the method for accessing multiple types of databases according to an embodiment of the present invention. DETAILED DESCRIPTION
[0033] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0034] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0035] Figure 1 This is a flowchart of a method for accessing multiple types of databases according to an embodiment of the present invention. This embodiment can be applied to the case where query language is reconstructed when accessing multiple types of autonomous and controllable databases to be compatible with accessing multiple types of databases. This method can be executed by a device for accessing multiple types of databases. The device for accessing multiple types of databases can be implemented in the form of hardware and / or software. The device for accessing multiple types of databases can be configured in an electronic device such as a computer. Figure 1 As shown, the method includes:
[0036] Step 110: In response to a user's access request to a target type database among multiple types of databases, obtain configuration information of the target type database.
[0037] In product applications, it may be necessary to access multiple types of databases. Multiple types of databases may include but are not limited to DAMO database, Renmin University Jincang database, Jinwu database and other self-controllable databases. Configuration information includes but is not limited to IP information, port information, and connection information of business databases when accessing databases.
[0038] In an optional implementation of the embodiment of the present invention, obtaining the configuration information of the target type database includes: determining whether the class loaded by the Spring container is a data source by building a Spring frontend; if the loaded class is a data source, building a proxy server (Proxy) to proxy the target type database and obtain the configuration information of the target type database. By obtaining the configuration information of the target type database, the dynamic execution of the technical solution of the embodiment of the present invention can be achieved.
[0039] Step 120: Establish a connection with the proxy database of the target type database according to the configuration information, and generate a corresponding running sandbox in the executor.
[0040] Specifically, you can establish a connection with the proxy database of the target type database through the product's socket connection according to the configuration information. You can run multiple sandboxes at the same time in the executor, and different sandboxes can support different database operations.
[0041] In an optional implementation of an embodiment of the present invention, when generating a corresponding running sandbox in the executor, it also includes: creating a database dialect class loader, setting the database dialect class loader as the current jvm class loader, intercepting the loading of the database driver class through the database dialect class loader, and performing driver isolation.
[0042] According to the drivers of different databases, you can create a dialect class loader self-instance to complete the driver loading of different databases, realize the isolation of drivers, and bind different runners to support the operation of different databases.
[0043] Step 130: Obtain an original query statement corresponding to the access request, and reconstruct the original query statement to generate a target query statement.
[0044] The query statement may be a structured query language (SQL). Before executing the access method to multiple types of databases, a preset rule library or a preset query language conversion model may be constructed to reconstruct the original query statement and generate a target query statement.
[0045] Exemplarily, the preset rule base may replace single quotes in the database with double quotes, or perform keyword mapping conversion of query statements, etc. The preset query language conversion model may generate a conversion template, perform similarity matching or nearest neighbor algorithm matching on query statements, and perform query statement reconstruction.
[0046] In an optional implementation of an embodiment of the present invention, the original query statement is reconstructed to generate a target query statement, including: obtaining a query language conversion model generated by pre-training, and using a proximity algorithm to determine a target query language conversion template that is closest to the original query statement in the query language conversion model; and reconstructing the original query language according to the target query language conversion template to generate a target query statement.
[0047] The query language conversion model may be generated by collecting, splitting, classifying, and categorizing query statements. The query language conversion model may include multiple query language conversion templates. The neighboring algorithm may be a K-Nearest Neighbor (KNN) algorithm. Based on the KNN algorithm, a target query language conversion template may be determined. Based on the target query language conversion template, the language in the original query language is changed to generate a target query statement to adapt to the database access environment.
[0048] In an optional implementation of an embodiment of the present invention, before obtaining the query language conversion model generated by pre-training, it also includes: collecting multiple query language basic statements, and disassembling and normalizing the query language basic statements to generate a query language conversion model, wherein the query language conversion model includes multiple query language conversion templates; identifying the program query statements in the user application, and determining the call chain and call parameters of the program query statements to generate a recognition result; generating a test calling method based on the recognition result; using a neighboring algorithm to determine the nearest neighbor query language conversion template closest to the program query statement in the query language conversion model; in the query language conversion model, using the test calling method corresponding to the program query statement as the test calling method of the nearest neighbor query language conversion template.
[0049] When generating a query language conversion model, the commonly used query language basic statements can be collected, the statement forms can be sorted, and the indicators can be extracted to finally form a variety of query language conversion templates. Exemplarily, the SQL formats in different databases include but are not limited to: selection statements (SELECT), setting statements (INSERT), deletion statements (DELETE), modification statements (UPDATE), and data definition statements (DDL). Among them, SELECT includes result sets, where conditions, grouping, and paging. INSERT statements include parameters and insert selections (insert select). DELETE statements include content areas and where conditions. UPDATE statements include content areas and where conditions. DDL includes reserved words, types, and descriptions. In the SQL query language conversion model, commonly used SQL statements are managed, indicators of different statement types are automatically decomposed, and each SQL statement indicator is normalized to complete the correspondence between SQL statements and SQL formats of different databases.
[0050] In an embodiment of the present invention, identifying a program query statement in a user application may be performing an object-relational mapping (ORM) framework (Object-Relational Mapping) on the application. The application is analyzed to obtain a call chain and call parameters of the program query statement. A unit test call method of the program may be generated based on the call chain and call parameters.
[0051] By determining the neighbor query language conversion template and associating the test call method with the neighbor query language conversion template, SQL can be reconstructed. When the original query language is reconstructed into a target query statement, the corresponding test call method can be used to query data.
[0052] Step 140: Determine, in the historical query statements, related query statements similar to the target query statement, and evaluate the execution performance of the target query statement based on each related query statement.
[0053] Among them, the historical query statements and the target query statements can be compared to determine the similarity between the two. According to the similarity, the most relevant or associated query statements with a similarity greater than a preset value are determined in the historical query statements. According to the execution of the associated query statements, the execution performance of the target query statement can be evaluated. For example, the mean or weighted mean of the execution time of each associated query statement can be determined as the execution evaluation time of the target query statement.
[0054] In an optional implementation of an embodiment of the present invention, in historical query statements, associated query statements similar to the target query statement are determined, including: performing vector comparison between the target query statement and the historical query statement to determine the query statement similarity; and screening associated query statements in the historical query statements whose query statement similarity is greater than a preset similarity threshold.
[0055] The vector comparison may be a cosine similarity comparison. The preset similarity threshold may be a value greater than or equal to 0.8. For example, the preset similarity threshold is 0.9.
[0056] In an optional implementation of an embodiment of the present invention, the execution performance of the target query statement is evaluated based on each associated query statement, including: obtaining the historical execution performance of each associated query statement, and performing function fitting on the historical execution performance to obtain an execution performance function; based on the execution performance function, evaluating the execution performance of the target query statement.
[0057] The historical execution performance may be a historical execution time. Function fitting may include linear regression calculation. The execution performance function may be a function obtained by performing linear regression calculation based on the amount of data in the query statement as an independent variable and the corresponding execution time as a dependent variable. The execution performance of the target query statement may be obtained by substituting the amount of data in the target query statement into the execution performance function to obtain the corresponding execution evaluation time.
[0058] Step 150: Establish an execution isolator instance in the executor according to the execution performance; and use the execution isolator to isolate the running sandbox in the executor.
[0059] Among them, the execution isolator is established to ensure the normal independent execution of each query statement. However, in actual applications, if an execution isolator is established for each query statement, it will cause resource occupation. Therefore, the execution isolator can be reused for some query statements. Therefore, when establishing an execution isolator, an execution isolator instance can be established according to the execution performance of the target query statement. For example, for complex target query statements, an execution isolator instance can be established independently. For simple target query statements, the execution isolator instance can be reused.
[0060] In an optional implementation of an embodiment of the present invention, an execution isolator instance is established in the executor based on the execution performance, including: if the execution performance is that the execution evaluation time is less than a preset execution time threshold, a pooled execution isolator instance is established in the executor; if the execution performance is that the execution evaluation time is greater than or equal to the preset execution time threshold, a signal isolator instance is established in the executor.
[0061] Among them, the preset execution time threshold can be a value less than or equal to 0.6 seconds. For example, the preset execution time threshold can be set to 0.5 seconds. The execution evaluation time can be obtained by evaluating the target query statement. The pooled execution isolator instance can be understood as placing the target query statement in a common execution isolator. The signal isolator instance can be understood as placing the target query statement separately in an execution isolator.
[0062] After the creation of the execution isolator instance is completed, the SQL executor instance can be injected, and the monitoring callback can be bound to monitor the water level and perform execution monitoring. When the SQL statement is executed, the start time and end time of the SQL executor are recorded, and the successfully executed original SQL statement and the translated SQL statement are stored and the execution time is recorded in the historical execution log. At the same time, if the isolator is a signal isolator, a SQL execution result minute buffer can be established. Among them, the expiration time of the execution result minute buffer can be 1 minute. If the target query statement has not been executed for more than 1 minute, the execution of the target query statement can be forced to stop, which can prevent the execution from being too long and causing avalanche.
[0063] Step 160: Execute the target query statement in the running sandbox to access the proxy database corresponding to the target type database.
[0064] By running the sandbox to execute the target query statement, the security of data query can be guaranteed.
[0065] In an optional implementation of an embodiment of the present invention, after executing the target query statement in the running sandbox, it also includes: obtaining the execution result of the target query statement, and if the execution result is an execution exception, determining the target type database corresponding to the execution result; inputting the target query statement, the execution result, and the type of the target type database into the large language model, and obtaining the corrected query statement generated by the large language model; executing the corrected query statement in the running sandbox, and determining the corresponding corrected execution result; if the corrected execution result meets the preset execution performance condition, updating the corrected query statement to the target query statement corresponding to the original query statement; if the corrected execution result does not meet the preset execution performance condition, regenerating the corrected query statement according to the large language model.
[0066] Among them, the large language model can generate a correction query statement corresponding to the target type database based on the target query statement, the execution result, and the type of the target type database. The correction query statement may be different from the target query statement, but similar or close to the target query statement. The preset execution performance condition may be used to determine whether the execution performance of the correction query statement is better than the target query statement. For example, the preset execution performance condition may be that the execution time of the correction query statement is less than the execution time of the target query statement. Or, the preset execution performance condition may be that the execution time of the correction query statement is less than 80% of the execution time of the target query statement, etc. By generating the correction query statement by the large language model, the inappropriate target query statement can be optimized. When the correction query statement is generated by the large language model, the error message of SQL, the data source information, and the inappropriate target query statement or the correction query statement can be input into the large language model so that the large language model can give a more suitable query statement. When a more suitable correction query statement is found, the correction query statement can be used to update and optimize the target query language conversion template corresponding to the target query statement in the query language conversion model.
[0067] The technical solution of this embodiment obtains the configuration information of the target type database in response to the user's access request to the target type database among multiple types of databases; establishes a connection with the proxy database of the target type database according to the configuration information, and generates a corresponding running sandbox in the executor; obtains the original query statement corresponding to the access request, and reconstructs the original query statement to generate a target query statement; determines the associated query statements similar to the target query statement in the historical query statements, and evaluates the execution performance of the target query statement according to each associated query statement; establishes an execution isolator instance in the executor according to the execution performance; uses the execution isolator to isolate the running sandbox in the executor; executes the target query statement in the running sandbox to access the proxy database corresponding to the target type database, which solves the access problem to multiple types of autonomous and controllable databases, can reduce the adaptation cost when users access multiple types of databases, and reasonably isolates the execution of multiple query statements.
[0068] Figure 2 FIG. 1 is an application example diagram of a method for accessing multiple types of databases provided according to an embodiment of the present invention. Figure 2 As shown, the access method to multiple types of databases provided by the embodiment of the present invention can be used as SQL middleware. SQL middleware is set on the product to realize data access between the product and the database. When applying SQL middleware, the query language conversion model can be maintained in the SQL middleware in advance to realize the reconstruction of the original query statement and generate the target query statement. The product and the SQL middleware can be connected through a connector so that the SQL middleware responds to the user's access request to the target type database in the multiple types of databases and obtains the configuration information of the target type database. When obtaining the configuration information, a pre-emitter can also be set in the SQL middleware, and the pre-emitter determines whether the class loaded by the Spring container is a data source. If it is a data source, a proxy server of the SQL middleware is constructed. Through the configuration information such as IP, port, and connection information of the business database, the SQL middleware instance is created and bound, and returned to complete the dynamic implantation of the SQL middleware. When the SQL middleware obtains the configuration information, it can establish a connection with the proxy database of the target type database through the environment adapter according to the configuration information, and generate a corresponding running sandbox in the executor. When the corresponding running sandbox is generated in the executor, a database dialect class loader can be created in the SQL middleware, and the database dialect class loader can be set as the current jvm class loader. The database dialect class loader can be used to intercept the loading of the database driver class to isolate the driver.
[0069] When the SQL middleware receives the original query statement, it can reconstruct the target query statement through the query language conversion model. A historical library log library can be set in the SQL middleware, and historical data can be queried in the historical library log library. In the historical query statements, the associated query statements similar to the target query statement are determined, and the execution performance of the target query statement is evaluated based on each associated query statement. The SQL middleware establishes an execution isolator instance in the executor based on the execution performance; the execution isolator is used to isolate the running sandbox in the executor. The SQL middleware executes the target query statement in the running sandbox and records the execution results in the historical library log library. After executing the target query statement, the SQL middleware can also perform self-learning services to update the query language conversion model in the rule engine. For example, a large language model can be used to generate a correction query statement for self-learning services.
[0070] Figure 3 FIG. 1 is a schematic diagram of a structure of a device for accessing multiple types of databases according to an embodiment of the present invention. Figure 3 As shown, the device includes: a configuration information acquisition module 310, an operation sandbox generation module 320, a target query statement generation module 330, an execution performance evaluation module 340, an executor isolation module 350 and a query statement execution module 360. Among them:
[0071] The configuration information acquisition module 310 is used to respond to a user's access request to a target type database among the multiple types of databases and acquire configuration information of the target type database;
[0072] An operation sandbox generation module 320 is used to establish a connection with a proxy database of a target type database according to the configuration information and generate a corresponding operation sandbox in the executor;
[0073] A target query statement generating module 330 is used to obtain an original query statement corresponding to the access request, and reconstruct the original query statement to generate a target query statement;
[0074] An execution performance evaluation module 340 is used to determine related query statements similar to the target query statement in the historical query statements, and evaluate the execution performance of the target query statement based on each related query statement;
[0075] The executor isolation module 350 is used to establish an execution isolator instance in the executor according to the execution performance; and to isolate the running sandbox in the executor by using the execution isolator;
[0076] The query statement execution module 360 is used to execute the target query statement in the running sandbox to access the proxy database corresponding to the target type database.
[0077] Optionally, the actuator isolation module 350 includes:
[0078] A first executor isolation unit is used to establish a pooled execution isolator instance in the executor if the execution performance is that the execution evaluation time is less than a preset execution time threshold;
[0079] The second executor isolation unit is used to establish a signal isolator instance in the executor if the execution performance is that the execution evaluation time is greater than or equal to a preset execution time threshold.
[0080] Optionally, the device further includes:
[0081] The driver isolation module is used to create a database dialect class loader when generating the corresponding running sandbox in the executor, set the database dialect class loader as the current jvm class loader, intercept the loading of the database driver class through the database dialect class loader, and perform driver isolation.
[0082] Optionally, the target query statement generating module 330 includes:
[0083] A target query language conversion template determination unit is used to obtain a query language conversion model generated by pre-training, and use a proximity algorithm to determine a target query language conversion template that is closest to the original query statement in the query language conversion model;
[0084] The target query statement generating unit is used to reconstruct the original query language according to the target query language conversion template to generate the target query statement.
[0085] Optionally, the device further includes:
[0086] A query language conversion model generation module is used to collect multiple query language basic statements before obtaining the query language conversion model generated by pre-training, and to disassemble and normalize the query language basic statements to generate a query language conversion model, wherein the query language conversion model includes multiple query language conversion templates;
[0087] The test call method generation module is used to identify the program query statement in the user application, determine the call chain and call parameters of the program query statement, and generate the recognition result; generate the test call method according to the recognition result;
[0088] A nearest neighbor query language conversion template determination module is used to determine the nearest neighbor query language conversion template closest to the program query statement in the query language conversion model by using a neighbor algorithm;
[0089] The test call method association module is used to use the test call method corresponding to the program query statement as the test call method of the neighbor query language conversion template in the query language conversion model.
[0090] Optionally, the execution performance evaluation module 340 includes:
[0091] A query statement similarity determination unit is used to compare the target query statement with the historical query statement vectors to determine the query statement similarity;
[0092] The associated query statement screening unit is used to screen the associated query statements corresponding to the query statement similarity in the historical query statements being greater than a preset similarity threshold;
[0093] An execution performance function determination unit is used to obtain the historical execution performance of each associated query statement, and perform function fitting on the historical execution performance to obtain an execution performance function;
[0094] The execution performance evaluation unit is used to evaluate the execution performance of the target query statement according to the execution performance function.
[0095] Optionally, the device further includes:
[0096] A target type database determination module is used to obtain the execution result of the target query statement after executing the target query statement in the running sandbox, and if the execution result is an execution exception, determine the target type database corresponding to the execution result;
[0097] A correction query statement acquisition module is used to input the target query statement, the execution result, and the type of the target type database into the large language model to obtain the correction query statement generated by the large language model;
[0098] A correction execution result determination module, used to execute the correction query statement in the running sandbox and determine the corresponding correction execution result;
[0099] A target query statement updating module, configured to update the corrected query statement to a target query statement corresponding to the original query statement if the corrected execution result meets a preset execution performance condition;
[0100] The correction query statement regeneration module is used to regenerate the correction query statement based on the large language model if the correction execution result does not meet the preset execution performance condition.
[0101] The device for accessing multiple types of databases provided by the embodiment of the present invention can execute the method for accessing multiple types of databases provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0102] Figure 4A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0103] like Figure 4 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.
[0104] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0105] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as methods for accessing various types of databases.
[0106] In some embodiments, the method for accessing a variety of databases may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the method for accessing a variety of databases described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the method for accessing a variety of databases in any other appropriate manner (e.g., by means of firmware).
[0107] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0108] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0109] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0110] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0111] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0112] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0113] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0114] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for accessing multiple types of databases, characterized in that: include: In response to a user's access request to a target type database among the multiple types of databases, obtaining configuration information of the target type database; Establishing a connection with a proxy database of the target type database according to the configuration information, and generating a corresponding running sandbox in the executor; Obtaining an original query statement corresponding to the access request, and reconstructing the original query statement to generate a target query statement; Determine, in the historical query statements, related query statements similar to the target query statement, and evaluate the execution performance of the target query statement according to each of the related query statements; establishing an execution isolator instance in the executor according to the execution performance; Using the execution isolator to isolate the running sandbox in the executor; Executing the target query statement in the running sandbox to access the proxy database corresponding to the target type database; The original query statement is reconstructed to generate a target query statement, including: obtaining a query language conversion model generated by pre-training, and using a proximity algorithm to determine a target query language conversion template that is closest to the original query statement in the query language conversion model; reconstructing the original query language according to the target query language conversion template to generate a target query statement; The query language conversion model is generated by collecting a plurality of query language basic statements, and performing decomposition and normalization processing on the query language basic statements. The query language conversion model includes a plurality of query language conversion templates.
2. The method for accessing multiple types of databases according to claim 1, characterized in that: According to the execution performance, establishing an execution isolator instance in the executor, including: If the execution performance is that the execution evaluation time is less than a preset execution time threshold, establishing a pooled execution isolator instance in the executor; If the execution performance is that the execution evaluation time is greater than or equal to a preset execution time threshold, a signal isolator instance is established in the executor.
3. The method for accessing multiple types of databases according to claim 1, characterized in that: When generating the corresponding running sandbox in the executor, it also includes: Create a database dialect class loader, set the database dialect class loader as the current jvm class loader, intercept the loading of the database driver class through the database dialect class loader, and perform driver isolation.
4. The method for accessing multiple types of databases according to claim 1, characterized in that: Before obtaining the query language conversion model generated by pre-training, it also includes: Collecting a plurality of query language basic statements, and performing disassembly and normalization processing on the query language basic statements to generate a query language conversion model, wherein the query language conversion model includes a plurality of query language conversion templates; Identify the program query statement in the user application, determine the call chain and call parameters of the program query statement, and generate an identification result; generate a test call method according to the identification result; Using a neighboring algorithm to determine a neighboring query language conversion template closest to the program query statement in the query language conversion model; In the query language conversion model, the test calling method corresponding to the program query statement is used as the test calling method of the neighbor query language conversion template.
5. The method for accessing multiple types of databases according to claim 1, characterized in that: Determining, from the historical query statements, related query statements similar to the target query statement, and evaluating the execution performance of the target query statement according to each of the related query statements, including: Performing a vector comparison between the target query statement and the historical query statement to determine the query statement similarity; Filtering the associated query statements corresponding to the historical query statements whose query statement similarity is greater than a preset similarity threshold; Obtaining the historical execution performance of each of the associated query statements, and performing function fitting on the historical execution performance to obtain an execution performance function; The execution performance of the target query statement is evaluated according to the execution performance function.
6. The method for accessing multiple types of databases according to claim 1, characterized in that: After executing the target query statement in the running sandbox, the method further includes: Obtaining an execution result of the target query statement, and if the execution result is an execution exception, determining a target type database corresponding to the execution result; Inputting the target query statement, the execution result, and the type of the target type database into a large language model to obtain a corrected query statement generated by the large language model; Executing the correction query statement in the running sandbox and determining a corresponding correction execution result; If the correction execution result meets the preset execution performance condition, updating the corrected query statement to a target query statement corresponding to the original query statement; If the correction execution result does not meet the preset execution performance condition, a correction query statement is regenerated according to the large language model.
7. A device for accessing multiple types of databases, characterized in that: include: A configuration information acquisition module, configured to respond to a user's access request to a target type database among multiple types of databases and acquire configuration information of the target type database; An operation sandbox generation module is used to establish a connection with a proxy database of the target type database according to the configuration information, and generate a corresponding operation sandbox in the executor; A target query statement generating module, used to obtain an original query statement corresponding to the access request, and reconstruct the original query statement to generate a target query statement; An execution performance evaluation module, used to determine, in historical query statements, related query statements similar to the target query statement, and evaluate the execution performance of the target query statement based on each of the related query statements; an executor isolation module, for establishing an execution isolator instance in the executor according to the execution performance; Using the execution isolator to isolate the running sandbox in the executor; A query statement execution module, used to execute the target query statement in the running sandbox to access the proxy database corresponding to the target type database; Among them, the target query statement generation module includes: A target query language conversion template determination unit is used to obtain a query language conversion model generated by pre-training, and use a proximity algorithm to determine a target query language conversion template that is closest to the original query statement in the query language conversion model; A target query statement generating unit, used for reconstructing the original query language according to the target query language conversion template to generate a target query statement; The query language conversion model is generated by collecting a plurality of query language basic statements, and performing decomposition and normalization processing on the query language basic statements. The query language conversion model includes a plurality of query language conversion templates.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method for accessing multiple types of databases according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for accessing multiple types of databases according to any one of claims 1 to 6 when executed.
Citation Information
Patent Citations
System and method for sandboxing support in multidimensional database environment
CN107533569A
Data processing method and device, electronic equipment and storage medium
CN110941627A