Database processing method and related equipment

By setting up a set of business layer statements at the business layer and calling different parsing classes for parsing according to the database type, the problem of redundant SQL statements is solved, the reduction and compatibility of SQL statements is achieved, and the stability and maintenance efficiency of code are improved.

CN119537405APending Publication Date: 2025-02-28BEIJING HONGTENG INTELLIGENT TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202311109407.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-30
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

In project development, due to the increasing types of databases, different databases need to be adapted to SQL statements in corresponding syntax formats, resulting in a lot of redundant SQL statements.

Method used

By setting up a set of business layer statements at the business layer and calling different parsing classes for parsing according to the types of different databases, the business layer statements are converted into SQL statements corresponding to the database type for execution by the database.

Benefits of technology

The SQL statements in the business layer are reduced, and only a set of business layer statements are retained, which reduces redundant SQL statements. Through the parsing class configuration, a set of business layer statements can be adapted to multiple different types of databases, ensuring the compatibility of business layer statements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119537405A_ABST
    Figure CN119537405A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a database processing method and related equipment. The database processing method comprises the steps that in response to starting of a service, a configuration file is obtained, and the configuration file comprises a database type; according to the database type, calling a corresponding analysis class, each analysis class corresponding to a different type of database; inputting a business layer statement into an analysis class to obtain a target statement, the target statement being an SQL statement corresponding to the database type; and sending the target statement to the corresponding database, so that the corresponding database executes the target statement. According to the technical scheme provided by the embodiment of the invention, the content of the analysis class is less than the content of the SQL statement generated by adapting to one type of database at present, so that all code quantities of the business layer statement and the analysis class are greatly reduced compared with the code quantity of the current SQL statement, but the compatibility corresponding to each database at present is kept; and the code is easier to maintain.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer and communication technology, and in particular to a database processing method and related equipment. Background Art

[0002] During project development, you will encounter various databases, each with its own syntax format. As the number of database types adapted in the project increases, you need to adapt SQL statements with corresponding syntax formats to different databases, resulting in many redundant SQL statements. Summary of the invention

[0003] The embodiments of the present application provide a database processing method and related devices, thereby reducing redundant SQL statements at least to a certain extent.

[0004] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.

[0005] According to one aspect of an embodiment of the present application, a database processing method is provided, including: in response to the startup of a service, obtaining a configuration file, the configuration file including a database type; calling a corresponding parsing class according to the database type, each of the parsing classes corresponding to a different type of database; inputting a business layer statement into the parsing class to obtain a target statement, the target statement being an SQL statement corresponding to the database type; and sending the target statement to the corresponding database so that the corresponding database executes the target statement.

[0006] In an embodiment of the present application, before inputting the business layer statement into the parsing class to obtain the target statement, the method further includes: instantiating a corresponding database object according to the database type and establishing a connection with the corresponding database.

[0007] In an embodiment of the present application, before inputting the business layer statement into the parsing class to obtain the target statement, the method further includes: inputting the business layer statement into the warehouse layer; and calling the parsing class at the warehouse layer.

[0008] In an embodiment of the present application, a business layer statement is input into a parsing class to obtain a target statement, which specifically includes: inputting the business layer statement into a parsing class, the parsing class calling a statement conversion template; and converting the business layer statement into a target statement according to the conversion template.

[0009] In an embodiment of the present application, a business layer statement is input into a parsing class to obtain a target statement, which specifically includes: inputting the business layer statement into a parsing class, the parsing class calling a statement parsing model; inputting the business layer statement into a statement parsing model to obtain the target statement.

[0010] In an embodiment of the present application, the method also includes: obtaining a business layer statement sample set, the business layer statement sample set including multiple business layer statement samples, each of the business layer statement samples being marked with a corresponding target statement; inputting all business layer statement samples in the business layer statement sample set into a statement parsing model one by one to obtain an output target statement; updating parameters of the statement parsing model according to the output target statement and the marked target statement until a predetermined end condition is reached, thereby terminating the training and obtaining a trained statement parsing model.

[0011] In an embodiment of the present application, before obtaining the configuration file in response to the startup of the service, the method also includes: constructing a business class, determining operation constants, business layer objects and operation methods; calling the business class, and constructing a business layer statement according to the operation constants, the business layer objects and the operation methods.

[0012] According to one aspect of an embodiment of the present application, a database processing method device is provided, and the database processing method device includes: a file acquisition module, used to obtain a configuration file in response to the startup of a service, wherein the configuration file includes a database type; a parsing call module, used to call a corresponding parsing class according to the database type, each of the parsing classes corresponding to a different type of database; a statement parsing module, used to input a business layer statement into the parsing class to obtain a target statement, wherein the target statement is an SQL statement corresponding to the database type; and a statement sending module, used to send the target statement to the corresponding database so that the corresponding database executes the target statement.

[0013] In an embodiment of the present application, the database processing method device further includes: a database connection module, which is used to instantiate a corresponding database object according to the database type and establish a connection with the corresponding database.

[0014] In an embodiment of the present application, the database processing method device includes: a warehouse layer input module, used to input the business layer statement into the warehouse layer; and a warehouse layer calling module, used to call the parsing class at the warehouse layer.

[0015] In an embodiment of the present application, the statement parsing module specifically includes: a template calling submodule, which is used to input the business layer statement into a parsing class, and the parsing class calls a statement conversion template; a statement conversion submodule, which is used to convert the business layer statement into a target statement according to the conversion template.

[0016] In an embodiment of the present application, the statement parsing module specifically includes: a model calling submodule, used to input the business layer statement into the parsing class, and the parsing class calls the statement parsing model; a model output submodule, used to input the business layer statement into the statement parsing model to obtain the target statement.

[0017] In an embodiment of the present application, the database processing method device also includes: a sample acquisition module, used to obtain a business layer statement sample set, the business layer statement sample set includes multiple business layer statement samples, and each of the business layer statement samples is marked with a corresponding target statement; a sample input module, used to input all business layer statement samples in the business statement sample set into a statement parsing model one by one to obtain an output target statement; a parameter updating module, used to update the parameters of the statement parsing model according to the output target statement and the marked target statement, until a predetermined end condition is reached, the training is terminated, and a trained statement parsing model is obtained.

[0018] In an embodiment of the present application, the database processing method device includes: a business class construction module, used to construct a business class, determine operation constants, business layer objects and operation methods; a business class calling module, used to call the business class and construct a business layer statement according to the operation constants, the business layer objects and the operation methods.

[0019] According to one aspect of an embodiment of the present application, a computer-readable medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the database processing method described in the above embodiment is implemented.

[0020] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the database processing method as described in the above embodiments.

[0021] In the technical solutions provided in some embodiments of the present application, by setting a set of business layer statements in the business layer, when it is necessary to operate the database, different parsing classes are called for parsing according to the types of different databases, and the business layer statements are converted into SQL statements corresponding to the database type for execution by the database, thereby reducing the SQL statements in the business layer and retaining only one set of business layer statements, thereby reducing redundant SQL statements. At the same time, by configuring the parsing class at the bottom layer to perform statement conversion, a set of business layer statements can be adapted to multiple different types of databases, thereby ensuring the compatibility of business layer statements. The parsing class in the embodiment of the present application is only a conversion template, and its content is far less than the content of the SQL statements generated by the prior art to adapt to one type of database. Therefore, the amount of code of the business layer statements plus the parsing class of the present application is much less than the amount of code of the SQL statements in the prior art, but the compatibility of the prior art corresponding to each database is maintained, making the code easier to maintain.

[0022] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0024] Figure 1 A schematic diagram of an exemplary system architecture to which the technical solution of the embodiments of the present application can be applied is shown.

[0025] Figure 2 A flowchart of a database processing method provided in an embodiment of the present application is shown.

[0026] Figure 3 A schematic diagram of the structure of a database processing device provided in an embodiment of the present application.

[0027] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0028] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.

[0029] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the application.

[0030] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0031] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0032] Figure 1 A schematic diagram of an exemplary system architecture to which the technical solution of the embodiments of the present application can be applied is shown.

[0033] like Figure 1 As shown, the system architecture may include terminal devices (such as Figure 1 The embodiment of the present invention is a schematic diagram of a mobile phone 101, a tablet computer 102, a portable computer 103, a desktop computer, etc., a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the terminal device and the server 105. The network 104 may include various connection types, such as a wired communication link, a wireless communication link, etc.

[0034] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. According to the implementation requirements, there may be any number of terminal devices, networks and servers. For example, the server 105 may be a server cluster composed of multiple servers.

[0035] The user can use the terminal device to interact with the server 105 through the network 104 to receive or send messages, etc. The server 105 can be a server that provides various services. For example, the user uses the terminal device 103 (or the terminal device 101 or 102) to upload a configuration file to the server 105. The configuration file includes a database type. The server 105 can call the corresponding parsing class according to the database type, and each of the parsing classes corresponds to a different type of database; input the business layer statement into the parsing class to obtain a target statement, and the target statement is an SQL statement corresponding to the database type; send the target statement to the corresponding database so that the corresponding database executes the target statement.

[0036] It should be noted that the database processing method provided in the embodiment of the present application is generally executed by the server 105, and accordingly, the database processing method device is generally set in the server 105. However, in other embodiments of the present application, the terminal device may also have similar functions to the server, so as to execute the solution of the database processing method provided in the embodiment of the present application.

[0037] The implementation details of the technical solution of the embodiment of the present application are described in detail below:

[0038] Figure 2 A flowchart of a database processing method according to an embodiment of the present application is shown. The database processing method can be executed by a server, which can be Figure 1 Refer to the server shown in . Figure 2 As shown, the database processing method at least includes:

[0039] Step S100, in response to the start of the service, obtaining a configuration file, wherein the configuration file includes a database type.

[0040] Step S200: Call the corresponding parsing class according to the database type, each of the parsing classes corresponding to a different type of database.

[0041] Step S300: input the business layer statement into the parsing class to obtain a target statement, where the target statement is an SQL statement corresponding to the database type.

[0042] Step S400: sending the target statement to the corresponding database so that the corresponding database executes the target statement.

[0043] In the embodiment of the present application, by setting a set of business layer statements in the business layer, when it is necessary to operate the database, different parsing classes are called for parsing according to the types of different databases, and the business layer statements are converted into SQL statements corresponding to the database type for execution by the database, thereby reducing the SQL statements in the business layer, retaining only a set of business layer statements, and reducing redundant SQL statements. At the same time, by configuring the parsing class at the bottom layer to perform statement conversion, a set of business layer statements can be adapted to multiple different types of databases, ensuring the compatibility of business layer statements. The parsing class in the embodiment of the present application is only a conversion template, and its content is far less than the content of the SQL statements generated by the prior art to adapt to one type of database. Therefore, the amount of code of the business layer statements plus the parsing class of the present application is much less than the amount of code of the SQL statements in the prior art, but the compatibility of the prior art corresponding to each database is maintained, making the code easier to maintain.

[0044] In step S100, when an operation needs to be performed on a database, a configuration file is first configured, and the configuration file includes the database object to be operated and the type of the database, i.e., the database type. After the configuration file is configured, the service is started and the configuration file is obtained. At this time, the server can perform corresponding adaptation operations according to the database type, so that the server can establish a connection with the database and complete various communications.

[0045] In step S200, after obtaining the database type, the corresponding parsing class can be called according to the database type to convert the business layer statement into a target statement.

[0046] Each parsing class corresponds to a different type of database. When a new database needs to be connected, the corresponding parsing class can be directly configured according to the database parameters (i.e. the parameters of the database to be connected) and added to the warehouse layer. When you need to interact with the newly connected database, you can directly call the corresponding newly configured parsing class. Compared with rewriting SQL statements adapted to the new database, the parsing class has less code and is easier to maintain, which improves the efficiency of database adaptation and saves the cost of code maintenance.

[0047] In some embodiments of the present application, before step S300, the database processing method may further include:

[0048] According to the database type, a corresponding database object is instantiated and a connection is established with the corresponding database.

[0049] After obtaining the database type, the server performs corresponding adaptation operations according to the database type, mainly instantiating the corresponding database object to achieve the connection of the corresponding database object, which is the database that needs to be operated.

[0050] In some embodiments of the present application, before step S300, the database processing method may further include:

[0051] Inputting the business layer statements into the warehouse layer;

[0052] The parsing class is called at the repository layer.

[0053] In this embodiment, before the business layer statement is input into the parsing class, it is necessary to first input the business layer statement from the business layer to the warehouse layer where the parsing class is located through a specific interface. In the warehouse layer, the corresponding parsing class is called according to the database type for parsing.

[0054] In step S300, after the business layer statement is input into the parsing class, the corresponding target statement is obtained, and the target statement is an SQL statement corresponding to the database type. The specific way in which the parsing class converts the business layer statement into the target statement can refer to the following embodiment.

[0055] Specifically, in some embodiments, the specific implementation of step S300 can refer to the following embodiments. Figure 2 The detailed description of step S300 in the database processing method shown in the corresponding embodiment, in the database processing method, step S300 may include the following steps:

[0056] Input the business layer statement into the parsing class, and the parsing class calls the statement conversion template;

[0057] The business layer statement is converted into a target statement according to the conversion template.

[0058] In this embodiment, each parsing class includes a conversion template that can convert business layer statements into SQL statements that are suitable for different databases. After the business layer statements are input into the parsing class, the parsing class converts the business layer statements into SQL statements corresponding to the database type (i.e., target statements) through the conversion template, thereby realizing the free conversion of business layer statements to SQL statements corresponding to each database type. In the embodiment of the present application, there is only one set of SQL statements for the business layer statements, and the amount of code is greatly reduced, which not only reduces the workload during development, but also improves the efficiency during development; during later maintenance, only one set of SQL statements needs to be maintained, and the modification of this set of SQL statements completes the modification of SQL statements for all databases, which reduces maintenance costs and improves the stability of the code.

[0059] At the same time, although the conversion templates in the parsing class are generated according to different types of databases, they are mainly generated according to the SQL statement generation rules of different types of databases. They mainly convert business layer statements into SQL statements that conform to the rules of the corresponding database type. Therefore, compared with a complete set of SQL statements adapted to the corresponding database, the amount of code contained in the parsing class is less and more refined, and its maintenance is simpler than a complete set of SQL statements adapted to the corresponding database. In general, if the business layer statements are maintained well, the target statements obtained are basically problem-free, which reduces maintenance costs and improves code stability.

[0060] Specifically, in other embodiments, the specific implementation of step S300 can refer to the following embodiments. Figure 2 The detailed description of step S300 in the database processing method shown in the corresponding embodiment, in the database processing method, step S300 may include the following steps:

[0061] Input the business layer statement into the parsing class, and the parsing class calls the statement parsing model;

[0062] The business layer statement is input into a statement parsing model to obtain the target statement.

[0063] In an embodiment of the present application, each parsing class includes a parsing model that can convert business layer statements into SQL statements that are adapted to different databases. After the business layer statements are input into the parsing class, the parsing class converts the business layer statements into SQL statements corresponding to the database type (i.e., target statements) through the parsing model, thereby realizing the free conversion of business layer statements to SQL statements corresponding to each database type. In an embodiment of the present application, the parsing model is used to convert business layer statements in the parsing class. The parsing model is obtained through training with a large number of samples, and maintenance only requires adjustment through samples. Compared with a complete set of SQL statements adapted to the corresponding database, it is easier to maintain and has a lower maintenance cost. Basically, it only needs to maintain the business layer statements, which reduces maintenance costs and improves the stability of the code.

[0064] Specifically, in some embodiments, the training method of the above-mentioned parsing model mainly includes:

[0065] Acquire a business layer statement sample set, wherein the business layer statement sample set includes a plurality of business layer statement samples, and each of the business layer statement samples is marked with a corresponding target statement;

[0066] Input all business-layer statement samples in the business statement sample set into the statement parsing model one by one to obtain output target statements;

[0067] According to the output target sentence and the marked target sentence, the parameters of the sentence parsing model are updated until a predetermined end condition is reached, and the training is terminated to obtain a trained sentence parsing model.

[0068] Specifically, in some embodiments, updating the parameters of the sentence parsing model according to the output target sentence and the marked target sentence until a predetermined end condition is reached, and the training is terminated. Obtaining the trained sentence parsing model may specifically include:

[0069] If, in the business layer sentence sample set, less than a predetermined number of business layer sentence samples are input into the parsing model and the target sentence output is consistent with the marked target sentence, the encoder is parameter updated;

[0070] If, in the business layer statement sample set, more than a predetermined number of business layer statement samples are input into the parsing model and the target statement output is consistent with the marked target statement, then the predetermined end condition is met, the training is ended, and a trained statement parsing model is obtained.

[0071] Specifically, in some other embodiments, updating the parameters of the sentence parsing model according to the output target sentence and the marked target sentence until a predetermined end condition is reached, and the training is terminated. Obtaining the trained sentence parsing model may specifically include:

[0072] Determining a loss function according to the output target sentence and the marked target sentence;

[0073] The parameters of the sentence parsing model are updated according to the loss function until a predetermined end condition is reached, and the training is terminated to obtain a trained sentence parsing model.

[0074] In this embodiment, the loss function reaching a predetermined end condition may be that the loss function converges or the loss function is less than a predetermined loss (eg, 0.001).

[0075] In the above embodiment, SQL statements are converted through a neural network model obtained through multiple trainings to obtain corresponding target statements. The neural network model is obtained through multiple trainings. The more samples it trains, the more accurate the results obtained. It basically does not require maintenance during operation, which also reduces maintenance costs and improves the efficiency and accuracy of SQL statement conversion.

[0076] In step S400, the target statement is sent to a corresponding database, and the corresponding database executes the target statement.

[0077] Before step S100, the method further includes:

[0078] Construct business classes, determine operation constants, business layer objects, and operation methods;

[0079] The business class is called, and a business layer statement is constructed according to the operation constant, the business layer object and the operation method.

[0080] In the embodiment of the present application, before starting the service, it is also necessary to configure the business layer statement. Specifically, first construct the business class according to the operation requirements, define the operation (Operator) constant, define the business layer (EXP) object and the operation method.

[0081] For example, for an operation constant, it may include a judgment to distinguish the Where condition, such as 0 represents equal to 1 represents not equal to.

[0082] For business layer objects, they include multiple business layer attributes, such as Logic integers, which are used to define And, Or, and In conditions; SubExps array objects, which represent the where conditions of the child level; Column strings, which represent fields; Operator integers, which are used to define the above Operator operations; and Value interfaces, which represent the values ​​to be queried.

[0083] The operation method is defined by multiple parameters. For example, the equal method contains two parameters: column represents the field, value is the value to be queried, and the return value is the business layer (EXP) object.

[0084] After having the business class, you can construct specific business layer statements based on the business class. This can be achieved by adding the package name and method. For example, construct an equal query: exp.Eq("id",1); construct a greater than query: exp.Gt("id",1); construct an In query: exp.In("id",[1]); construct a multi-condition query: exp.And(exp.In("id",[1]),exp.Eq("id",1)).

[0085] This results in a complete set of business layer statements. Since the business layer only has one set of SQL statements, no matter how many databases are adapted, only one set of SQL statements needs to be developed and maintained, which greatly improves R&D efficiency and code quality. At the same time, later maintenance, iterative updates, and code readability are greatly improved.

[0086] The following describes an apparatus embodiment of the present application, which can be used to execute the database processing method in the above-mentioned embodiment of the present application. For details not disclosed in the apparatus embodiment of the present application, please refer to the above-mentioned embodiment of the database processing method of the present application.

[0087] Figure 3 A block diagram of a database processing device according to an embodiment of the present application is shown.

[0088] Reference Figure 3 As shown, according to an embodiment of the present application, the database processing device 300 includes: a file acquisition module 310, a parsing call module 320, a statement parsing module 330, and a statement sending module 340. The file acquisition module 310 is used to obtain a configuration file in response to the start of the service, and the configuration file includes a database type; the parsing call module 320 is used to call a corresponding parsing class according to the database type, and each of the parsing classes corresponds to a different type of database; the statement parsing module 330 is used to input a business layer statement into the parsing class to obtain a target statement, and the target statement is an SQL statement corresponding to the database type; the statement sending module 340 is used to send the target statement to the corresponding database so that the corresponding database executes the target statement.

[0089] In an embodiment of the present application, the database processing method device further includes: a database connection module, which is used to instantiate a corresponding database object according to the database type and establish a connection with the corresponding database.

[0090] In an embodiment of the present application, the database processing method device includes: a warehouse layer input module, used to input the business layer statement into the warehouse layer; and a warehouse layer calling module, used to call the parsing class at the warehouse layer.

[0091] In an embodiment of the present application, the statement parsing module specifically includes: a template calling submodule, which is used to input the business layer statement into a parsing class, and the parsing class calls a statement conversion template; a statement conversion submodule, which is used to convert the business layer statement into a target statement according to the conversion template.

[0092] In an embodiment of the present application, the statement parsing module specifically includes: a model calling submodule, used to input the business layer statement into the parsing class, and the parsing class calls the statement parsing model; a model output submodule, used to input the business layer statement into the statement parsing model to obtain the target statement.

[0093] In an embodiment of the present application, the database processing method device also includes: a sample acquisition module, used to obtain a business layer statement sample set, the business layer statement sample set includes multiple business layer statement samples, and each of the business layer statement samples is marked with a corresponding target statement; a sample input module, used to input all business layer statement samples in the business statement sample set into a statement parsing model one by one to obtain an output target statement; a parameter updating module, used to update the parameters of the statement parsing model according to the output target statement and the marked target statement, until a predetermined end condition is reached, the training is terminated, and a trained statement parsing model is obtained.

[0094] In an embodiment of the present application, the database processing method device includes: a business class construction module, used to construct a business class, determine operation constants, business layer objects and operation methods; a business class calling module, used to call the business class and construct a business layer statement according to the operation constants, the business layer objects and the operation methods.

[0095] In the technical solutions provided in some embodiments of the present application, by setting a set of business layer statements in the business layer, when it is necessary to operate the database, different parsing classes are called for parsing according to the types of different databases, and the business layer statements are converted into SQL statements corresponding to the database type for execution by the database, thereby reducing the SQL statements in the business layer and retaining only one set of business layer statements, thereby reducing redundant SQL statements. At the same time, by configuring the parsing class at the bottom layer to perform statement conversion, a set of business layer statements can be adapted to multiple different types of databases, thereby ensuring the compatibility of business layer statements. The parsing class in the embodiment of the present application is only a conversion template, and its content is far less than the content of the SQL statements generated by the prior art to adapt to one type of database. Therefore, the amount of code of the business layer statements plus the parsing class of the present application is much less than the amount of code of the SQL statements in the prior art, but the compatibility of the prior art corresponding to each database is maintained, making the code easier to maintain.

[0096] Figure 4 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.

[0097] It should be noted that Figure 4 The computer system of the electronic 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.

[0098] like Figure 4 As shown, the computer system includes a central processing unit (CPU) 1801, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1802 or the program loaded from the storage part 1808 to the random access memory (RAM) 1803, such as executing the method described in the above embodiment. In RAM 1803, various programs and data required for system operation are also stored. CPU 1801, ROM 1802 and RAM 1803 are connected to each other through bus 1804. Input / output (I / O) interface 1805 is also connected to bus 1804.

[0099] The following components are connected to the I / O interface 1805: an input section 1806 including a keyboard, a mouse, etc.; an output section 1807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1808 including a hard disk, etc.; and a communication section 1809 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1809 performs communication processing via a network such as the Internet. A drive 1810 is also connected to the I / O interface 1805 as needed. A removable medium 1811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1810 as needed so that a computer program read therefrom is installed into the storage section 1808 as needed.

[0100] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program 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 section 1809, and / or installed from a removable medium 1811. When the computer program is executed by a central processing unit (CPU) 1801, various functions defined in the system of the present application are executed.

[0101] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a 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 above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0102] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0103] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.

[0104] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the method described in the above embodiment.

[0105] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0106] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.

[0107] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not disclosed in the present application.

[0108] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A database processing method, characterized in that: include: In response to starting the service, obtaining a configuration file, wherein the configuration file includes a database type; According to the database type, the corresponding parsing class is called, and each parsing class corresponds to a different type of database; Input the business layer statement into the parsing class to obtain a target statement, where the target statement is an SQL statement corresponding to the database type; The target statement is sent to the corresponding database so that the corresponding database executes the target statement.

2. The database processing method according to claim 1, characterized in that: The step of inputting the business layer statement into the parsing class to obtain the target statement specifically includes: Input the business layer statement into the parsing class, and the parsing class calls the statement conversion template; The business layer statement is converted into a target statement according to the conversion template.

3. The database processing method according to claim 1, characterized in that: Before obtaining the configuration file in response to starting the service, the method further includes: Construct business classes, determine operation constants, business layer objects, and operation methods; The business class is called, and a business layer statement is constructed according to the operation constant, the business layer object and the operation method.

4. The database processing method according to claim 1, characterized in that: The step of inputting the business layer statement into the parsing class to obtain the target statement specifically includes: Input the business layer statement into the parsing class, and the parsing class calls the statement parsing model; The business layer statement is input into a statement parsing model to obtain the target statement.

5. The database processing method according to claim 4, characterized in that: The method further comprises: Acquire a business layer statement sample set, wherein the business layer statement sample set includes a plurality of business layer statement samples, and each of the business layer statement samples is marked with a corresponding target statement; Input all business-layer statement samples in the business statement sample set into the statement parsing model one by one to obtain output target statements; According to the output target sentence and the marked target sentence, the parameters of the sentence parsing model are updated until a predetermined end condition is reached, and the training is terminated to obtain a trained sentence parsing model.

6. The database processing method according to claim 1, characterized in that: Before inputting the business layer statement into the parsing class to obtain the target statement, the method further includes: According to the database type, a corresponding database object is instantiated and a connection is established with the corresponding database.

7. The database processing method according to claim 1, characterized in that: Before inputting the business layer statement into the parsing class to obtain the target statement, the method further includes: Inputting the business layer statements into the warehouse layer; The parsing class is called at the repository layer.

8. A database processing method and device, characterized in that: The database processing method device comprises: A file acquisition module, used for acquiring a configuration file in response to the startup of the service, wherein the configuration file includes a database type; A parsing calling module, used to call a corresponding parsing class according to the database type, each parsing class corresponding to a different type of database; A statement parsing module, used to input the business layer statement into the parsing class to obtain a target statement, wherein the target statement is an SQL statement corresponding to the database type; The statement sending module is used to send the target statement to the corresponding database so that the corresponding database executes the target statement.

9. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the database processing method according to any one of claims 1 to 7 is implemented.

10. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, enables the one or more processors to implement the database processing method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Data comparison method, device and equipment and computer readable medium

    CN120316140A