WO2024098858A1 - Database access system and method, computer device, and storage medium - Google Patents

Database access system and method, computer device, and storage medium Download PDF

Info

Publication number
WO2024098858A1
WO2024098858A1 PCT/CN2023/111555 CN2023111555W WO2024098858A1 WO 2024098858 A1 WO2024098858 A1 WO 2024098858A1 CN 2023111555 W CN2023111555 W CN 2023111555W WO 2024098858 A1 WO2024098858 A1 WO 2024098858A1
Authority
WO
WIPO (PCT)
Prior art keywords
orm
database
operation request
framework
execution engine
Prior art date
Application number
PCT/CN2023/111555
Other languages
French (fr)
Chinese (zh)
Inventor
谭锦志
邱炜伟
盛威锋
戴唯威
胡麦芳
Original Assignee
杭州趣链科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 杭州趣链科技有限公司 filed Critical 杭州趣链科技有限公司
Publication of WO2024098858A1 publication Critical patent/WO2024098858A1/en

Links

Definitions

  • the present application relates to the field of computer technology, and in particular to a database access system, method, computer device and storage medium.
  • each application system can interact directly with the database.
  • Each application system is integrated with an ORM (Object Relational Mapping) framework.
  • the ORM framework can automatically compile the object-oriented programming language written by the technician into a database operation language that can be recognized by the database.
  • the technician can write an object-oriented business program in the application system, and then the ORM framework will execute the business program to automatically compile the business program into an operation program that can be recognized by the database, and execute the operation program to access the database.
  • each of the multiple application systems needs to configure the database account and password. Then each application system will know the database account and password. The widespread use of such private data will bring great security risks to the database, thereby reducing the security of the database.
  • the purpose of the embodiments of the present application is to provide a database access system, method, computer device and storage medium, including but not limited to solving the problem of low database security.
  • a database access system comprising an application system and an object relation mapping (ORM) execution engine, the application system comprising a first ORM framework, the ORM execution engine comprising a second ORM framework, the ORM execution engine being in communication connection with a database;
  • ORM object relation mapping
  • the first ORM framework is used to generate an operation request according to the business statement, and send the operation request to the ORM execution engine, wherein the operation request is used to request to operate the data in the database;
  • the second ORM framework is used to parse the operation request after obtaining the operation request to obtain an SQL (Structured Query Language) statement; execute the SQL statement to access the data in the database to obtain the execution result of the SQL statement.
  • SQL Structured Query Language
  • a database access method is provided, which is applied to a relational object mapping (ORM) execution engine, wherein the ORM execution engine includes a second ORM framework, the ORM execution engine is communicatively connected to an application system, the ORM execution engine is communicatively connected to a database, the application system includes a first ORM framework, and the method includes:
  • the second ORM framework obtains an operation request sent by the first ORM framework, where the operation request is generated by the first ORM framework according to a business statement, and is used to request an operation to be performed on the data in the database;
  • the second ORM framework parses the operation request to obtain a structured query language SQL statement
  • the second ORM framework executes the SQL statement to access the data in the database and obtains the execution result of the SQL statement.
  • a computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the above-mentioned database access method when executed by the processor.
  • a computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned database access method is implemented.
  • a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the steps of the above-mentioned database access method.
  • the beneficial effect of the database access system is that the application system includes a first ORM framework, the ORM execution engine includes a second ORM framework, and the ORM execution engine is connected to the database for communication.
  • the first ORM framework generates an operation request based on the business statement, and then sends the operation request to the ORM execution engine, that is, the application system sends an operation request to the ORM execution engine when it needs to access the database.
  • the second ORM framework in the ORM execution engine receives the operation request, it parses the operation request to obtain an SQL statement, which is a statement that the database can recognize.
  • the second ORM framework executes the SQL statement to access the data in the database.
  • the application system does not need to directly connect to the database, so there is no need to configure the database password in the application system, and only the ORM execution engine needs to interact with the database to access the database, thereby ensuring the security of the database.
  • the ORM execution engine includes a second ORM framework, the ORM execution engine is connected to the application system for communication, and the ORM execution engine is connected to the database for communication, and the application system includes a first ORM framework.
  • the second ORM framework in the ORM execution engine obtains the operation request sent by the first ORM framework, and the operation request is generated by the first ORM framework according to the business statement, that is, the application system sends an operation request to the ORM execution engine when it needs to access the database.
  • the second ORM framework parses the operation request to obtain an SQL statement, which is a statement that can be recognized by the database.
  • the second ORM framework executes the SQL statement to access the data in the database. In this way, the application system does not need to directly connect to the database, so there is no need to configure the database password in the application system, but only the ORM execution engine needs to interact with the database to achieve access to the database, thereby ensuring the security of the database.
  • FIG1 is a schematic diagram of the structure of a database access system provided in an embodiment of the present application.
  • FIG2 is a flow chart of a database access method provided in an embodiment of the present application.
  • FIG3 is a schematic diagram of an operation request provided in an embodiment of the present application.
  • FIG4 is a schematic diagram of the interaction between an application system and an ORM execution engine provided in an embodiment of the present application
  • FIG5 is a flow chart of another database access method provided in an embodiment of the present application.
  • FIG6 is a flowchart of another database access method provided in an embodiment of the present application.
  • FIG. 7 is a flowchart of another database access method provided in an embodiment of the present application.
  • FIG8 is a schematic diagram of another interaction between an application system and an ORM execution engine provided in an embodiment of the present application.
  • FIG9 is a schematic diagram of the structure of another database access system provided in an embodiment of the present application.
  • FIG. 10 is a schematic diagram of the structure of another database access system provided in an embodiment of the present application.
  • FIG11 is a schematic diagram of a middleware module provided in an embodiment of the present application.
  • FIG. 12 is a schematic diagram of the structure of another database access system provided in an embodiment of the present application.
  • FIG. 13 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application.
  • the business logic layer and the user interface layer are object-oriented.
  • a database including but not limited to a relational database.
  • object-oriented languages cannot be used to update the data in the database. Therefore, it is necessary to write a very complex database language to update the data in the database.
  • the ORM framework is a technology that solves the language mismatch between object-oriented and database. Specifically, it automatically persists objects in the program to the database by describing the metadata mapping between the object and the database.
  • the ORM framework is a bridge connecting the business logic layer and the database.
  • a persistent class in the metadata corresponds to a table in the database
  • each instance of the class corresponds to a record in the table
  • each attribute of the class corresponds to each field in the table.
  • ORM framework provides a mapping between a database and an object, we no longer need to deal with complex database languages when operating the data in the database. We can just operate it like we normally operate an object.
  • the ORM framework can make development more object-oriented. For technical personnel, they only need to write object-oriented business programs, which makes program writing more convenient, thus improving development efficiency and reducing development costs.
  • an application system based on an ORM framework accesses a database by directly communicating with the database.
  • the ORM framework in the application system executes the business program written by the technician to automatically compile the business program into an operation statement (SQL statement in the embodiment of the present application) that can be recognized by the database, and executes the operation statement to access the database.
  • SQL statement in the embodiment of the present application
  • the database account and password must be configured in each application system that accesses the same database.
  • the configuration complexity of the application system will be increased, and on the other hand, each application system will know the database account and password, which will bring great security risks to the database.
  • the database is set with a maximum number of TCP (Transmission Control Protocol) connections, which means that the database only allows a limited number of application systems to connect.
  • TCP Transmission Control Protocol
  • Each connection between an application system and the database will consume the database's TCP connection number, and the number of TCP connections consumed by the application system is defined by itself, which means that the application system can define the number of TCP connections between itself and the database.
  • the overall number of TCP connections is uncontrollable.
  • the application system itself does not have the ability to cache data. Furthermore, since an application system's operations on database tables may be modified by other application systems at any time, the effectiveness of the cache cannot be guaranteed even if the data is cached in the application system.
  • the embodiment of the present application provides a database access method.
  • the application system can send an operation request to the ORM execution engine, and then the ORM execution engine can process the operation request, and then the ORM execution engine interacts with the database to achieve access to the database.
  • the application system does not need to directly connect to the database, so there is no need to configure the database password in the application system, thereby ensuring the security of the database.
  • FIG1 is a schematic diagram of a database access system provided in an embodiment of the present application.
  • the database access system includes: an application system 101 and an ORM execution engine 102 .
  • the application system 101 includes a first ORM framework, which is used to generate an operation request when access to the database 103 is required.
  • the application system 101 can be deployed on a terminal or a server.
  • the application system 101 can be connected to an ORM execution engine.
  • 102 communicates via a wired connection or a wireless connection.
  • the number of application systems 101 can be one or more, and the multiple application systems 101 all communicate with the ORM execution engine 102.
  • the database access system may include one ORM execution engine 102, or may include multiple ORM execution engines 102, and the multiple ORM execution engines 102 as a whole act as an ORM execution engine cluster to communicate with one or more application systems 101, and the multiple ORM execution engines 102 as a whole act as an ORM execution engine cluster to communicate with the database 103.
  • the ORM execution engine 102 includes a second ORM framework, and the second ORM framework is used to process the received operation request and interact with the database 103.
  • the ORM execution engine 102 can be deployed on a server, which can be a single server or a server cluster consisting of multiple servers.
  • the ORM execution engine 102 may communicate with the database 103 through a wired connection or a wireless connection, and may also communicate with the application system 101 through a wired connection or a wireless connection.
  • the first ORM framework in the application system 101 when the application system 101 needs to access the data in the database 103, the first ORM framework in the application system 101 generates an operation request to access the database 103 and sends it to the ORM execution engine 102. After receiving the operation request, the second ORM framework in the ORM execution engine 102 processes the operation request and interacts with the database 103 to implement the operation on the data in the database 103.
  • the ORM execution engine 102 directly communicates with the database 103, and the application system 101 does not need to directly communicate with the database 103, but accesses the database 103 through the ORM execution engine 102, so there is no need to configure the password of the database 103 in the application system 101, and it is only necessary to configure the password of the database 103 in the ORM execution engine 102.
  • the database access system configureds the password of the database 103 in the ORM execution engine 102, which can improve the security of the database 103.
  • Fig. 2 is a flow chart of a database access method provided in an embodiment of the present application.
  • the database access method is applied to the database access system described in the embodiment of Fig. 1 above. Referring to Fig. 2, the method includes the following steps.
  • Step 201 The first ORM framework generates an operation request according to the business statement.
  • the business statement is a statement written by the technician using an object-oriented programming language.
  • the first ORM framework integrated in the application system can be an ORM-based SDK (Software Development Kit) deployed in the application system.
  • the technician can directly use the ORM programming syntax to write object-oriented business statements.
  • the first ORM framework can generate an operation request based on the business statement written by the technician. The operation request is used to request an operation on the data in the database.
  • the first ORM framework parses the business statement and encapsulates the parsed result to obtain an operation request.
  • the operation request will include information related to the business statement, that is, it will include relevant information on the operation of the database.
  • the operation request may include information such as the object identifier, the operation type, the original data of the object identified by the object identifier, and the updated data of the object identified by the object identifier.
  • the object identifier is the identifier of the object in the database to be accessed by the application system.
  • the object identifier can be the name of a table in the database, which is not limited in the embodiments of the present application.
  • the operation type is the type of operation performed by the application system on the object in the database.
  • the operation type can include adding (INSERT), deleting (DELETE), updating (UPDATE), and finding (FIND).
  • FIG3 is a data diagram of an operation request.
  • the operation request shown in FIG3 includes information related to database operations, such as operation type, table name, original table data, original SQL data, and update data.
  • Step 202 The first ORM framework sends the operation request to the ORM execution engine.
  • the first ORM framework provides an interface for communicating with the ORM execution engine.
  • the first ORM framework in the application system can send the operation request to the ORM execution engine through the interface.
  • the user can click an order information query button in an application system to trigger the operation of accessing the order information of the account in the database.
  • the application system will call the business statement for querying the order information, and the first ORM framework can encapsulate the business statement to obtain the corresponding operation request and send the operation request to
  • the ORM execution engine the operation request is a request to query the order information of the user's account from the database.
  • the ORM execution engine can perform corresponding processing, specifically, the following steps 203-205 can be executed.
  • Step 203 The second ORM framework in the ORM execution engine obtains the operation request.
  • the second ORM framework is an ORM framework integrated in the ORM execution engine, and is used to process the operation request after obtaining the operation request, so as to implement the access operation to the database.
  • the first ORM framework in the application system can communicate directly with the second ORM framework in the ORM execution engine.
  • the operation request sent by the first ORM framework to the ORM execution engine can be directly received by the second ORM framework, that is, the second ORM framework can directly receive the operation request sent by the first ORM framework.
  • the ORM execution engine includes a middleware module, and the middleware module can communicate with the application system, that is, the middleware module can communicate directly with the first ORM framework.
  • the operation request sent by the first ORM framework to the ORM execution engine can be directly received by the middleware module.
  • the middleware module can first receive the operation request sent by the first ORM framework, and then send the operation request to the second ORM framework when the database access condition is met.
  • the database access conditions can be set in advance, and the database access conditions can be set by the technical staff according to the business needs.
  • the database access conditions can include but are not limited to at least one of the following:
  • the number of database accesses is less than the first count threshold.
  • the first number threshold is the maximum number of times a database can be accessed within a certain period (such as one day, one month, etc.).
  • the first number threshold can be set in advance, and the first number threshold can be set by a technician according to business needs.
  • the middleware module can send the operation request to the second ORM framework. If the number of database accesses is greater than or equal to the first number threshold, it means that the number of database accesses has exceeded the maximum number of times the database can be accessed, so the database cannot continue to be accessed, and the middleware module cannot send the operation request to the second ORM framework.
  • the middleware module can send the operation request to the second ORM framework.
  • the access count of the object to be accessed by the operation request is less than a second count threshold.
  • the second number threshold is the maximum number of times the object to be accessed by the operation request can be accessed within a certain period (such as one day, one month, etc.)
  • the second number threshold can be set in advance, and the second number threshold can be set by the technical staff according to business needs.
  • the number of accesses to the object to be accessed by the operation request is less than the second number threshold, indicating that the number of accesses to the object to be accessed by the operation request has not reached the maximum number of times the object to be accessed by the operation request can be accessed, so the database can continue to be accessed, and the middleware module can send the operation request to the second ORM framework.
  • the number of accesses to the object to be accessed by the operation request is greater than or equal to the second number threshold, indicating that the number of accesses to the object to be accessed by the operation request has exceeded the maximum number of times the object to be accessed by the operation request can be accessed, so the database cannot be accessed, and the middleware module cannot send the operation request to the second ORM framework.
  • the second count threshold is 5
  • the number of accesses to the object to be accessed by the current operation request is 3
  • the number of accesses to the object to be accessed by the current operation request (3) is less than the second count threshold (5)
  • the application system has access rights to the object that the operation request wants to access.
  • the access rights of the object to be accessed by the operation request are used to restrict the access of some application systems to the object to be accessed by the operation request, that is, the application system with the access rights of the object to be accessed by the operation request is allowed to access the object, while the application system without the access rights of the object to be accessed by the operation request is not allowed to access the object.
  • the access rights of the object to be accessed by the operation request can be set by the technician according to business needs.
  • the middleware module After the middleware module receives the operation request, it can first check whether the application system that sent the operation request has the access rights to the object that the operation request wants to access. If the application system has the access rights to the object that the operation request wants to access, it means that the application system is allowed to access the object that the operation request wants to access, and then it can continue to access the database. The middleware module can then send the operation request to If the application system does not have the access rights to the object to be accessed by the operation request, it means that the application system is not allowed to access the object to be accessed by the operation request, and then the database cannot be accessed, and the middleware module cannot send the operation request to the second ORM framework.
  • the application system has access rights to the database.
  • the access rights of a database are used to restrict the access of some application systems to the database. That is, application systems with access rights to the database are allowed to access the database, while application systems without access rights to the database are not allowed to access the database.
  • the access rights of the database can be set by the technical staff according to the business needs.
  • the middleware module After the middleware module receives the operation request, it can first check whether the application system that sends the operation request has the access rights to the database. If the application system has the access rights to the database, it means that the application system is allowed to access the database, and then it can continue to access the database, and the middleware module can send the operation request to the second ORM framework. If the application system does not have the access rights to the database, it means that the application system is not allowed to access the database, and then it cannot continue to access the database, and the middleware module cannot send the operation request to the second ORM framework.
  • the operation type in the operation request is the operation type that the database allows to be performed on the object to be accessed by the operation request.
  • the middleware module can first check whether the operation type in the operation request is the operation type that the database allows to perform on the object to be accessed by the operation request. If the operation type in the operation request is the operation type that the database allows to perform on the object to be accessed by the operation request, it means that the operation type that the operation request wants to perform on the object is an allowed operation type, then the database can continue to be accessed, and the middleware module can send the operation request to the second ORM framework.
  • the operation type in the operation request is not the operation type that the database allows to perform on the object to be accessed by the operation request, it means that the operation type that the operation request wants to perform on the object is an unallowed operation type, then the database cannot be accessed, and the middleware module cannot send the operation request to the second ORM framework.
  • the middleware module can send the operation request to the second ORM framework when any one of the above five conditions is met; or, the middleware module sends the operation request to the second ORM framework only when multiple of the above five conditions are met at the same time.
  • the technician can also set other conditions, which are not limited in the embodiment of the present application.
  • database access conditions are set in advance in the middleware module. Only when the database access conditions are met will the middleware module send the operation request to the second ORM framework. In this case, the middleware module can coordinate and manage the access to the entire database well, while meeting all business needs and supporting more advanced, special, and customized management and control configurations.
  • Step 204 The second ORM framework parses the operation request to obtain an SQL statement.
  • SQL statements are used to operate on data in a database.
  • the SQL statement can be a DML (Data Manipulation Language) statement.
  • the SQL statement can be used to add, delete, update, and search for data in a database.
  • the operation request is generated by the first ORM framework according to the object-oriented business statement
  • the operation request includes object-oriented operation information.
  • the second ORM framework in the ORM execution engine can parse the object-oriented operation request into an SQL statement, that is, parse the object-oriented operation request into an SQL statement that can be recognized by the database to access the data in the database.
  • the second ORM framework can obtain SQL statements that the database can recognize, and then interact with the database, so that the technician does not need to write complex SQL statements, which provides convenience for the technician and improves development efficiency.
  • the application system there is no need for the application system to communicate directly with the database, and there is no need to configure the database account password in the application system, thereby ensuring the security of the database.
  • the second ORM framework parses the operation request to obtain an SQL statement, which is similar to the operation of a device in the related art parsing an operation request to obtain an SQL statement, and the embodiment of the present application will not elaborate on this.
  • Step 205 The second ORM framework executes the SQL statement to access the data in the database and obtain the execution result of the SQL statement.
  • the second ORM framework provides an interface for communicating with the database, so the second ORM framework can communicate with the database through Access the database through this interface.
  • the second ORM framework executes the SQL statement, that is, interacts with the database through the interface provided in the second ORM framework, that is, operates on the object to be accessed by the operation request in the database, thereby obtaining the execution result, which is the request result of the operation request.
  • the second ORM framework may return the execution result of the SQL statement as the request result of the operation request to the application system to respond to the operation request sent by the application system.
  • Figure 4 is a schematic diagram of the interaction between the application system and the ORM execution engine.
  • Figure 4 includes an application system 401 and an ORM execution engine 402.
  • the application system 401 sends the operation request to the ORM execution engine 402, and the second ORM framework in the ORM execution engine 402 executes the SQL statement obtained by parsing the operation request, and after obtaining the execution result, sends the execution result of the SQL statement as the request result of the operation request to the application system 401.
  • the ORM execution engine may further include a cache module.
  • the above steps 204-205 may be directly executed to obtain the request result of the operation request. If the operation type in the operation request is a query type, the above steps 204-205 may not be executed first, but the cache module may be queried first to see if there is the data to be queried by the operation request.
  • the cache module is in communication connection with the ORM execution engine, and the cache module stores multiple key-value pairs, and each of the multiple key-value pairs stores the request result of an operation request whose operation type is a query type.
  • the key value in each of the multiple key-value pairs is a hash value obtained by hashing the operation request whose operation type is a query type, and the value value in each of the multiple key-value pairs is the request result of the operation request whose operation type is a query type.
  • the key value in this key-value pair is a hash value of an operation request whose operation type is a query type, and the value value in this key-value pair is the request result of this operation request, that is, the data queried from the database by this operation request.
  • the cache module can be a key-value storage system, for example, the cache module can be a redis (REmoteDIctionary Server, data structure server) cache system.
  • the second ORM framework After the second ORM framework obtains the operation request, if the operation type in the operation request is a query type, the second ORM framework performs a hash operation on the operation request to obtain a hash value; queries the cache module for a key value identical to the hash value; if a key value identical to the hash value is queried from the cache module, the value in the key-value pair of the key value identical to the hash value in the cache module is determined as the request result of the operation request.
  • the above steps 204-205 are executed, that is, the operation request is parsed to obtain the SQL statement, and the SQL statement is executed to access the data in the database, and the execution result of the SQL statement is obtained as the request result of the operation request.
  • a target key-value pair can also be generated and stored in the cache module.
  • the key value in the target key-value pair is the hash value of the operation request.
  • the value value in the target key-value pair is the execution result of the SQL statement, that is, the request result of the operation request, that is, the data queried from the database after executing the SQL statement.
  • the cache module contains the request result of the operation request, that is, the data that the application system wants to query. Then the value in the key-value pair containing the key value that is the same as the hash value in the cache module can be determined as the request result of the operation request, and the request result of the operation request can be further returned to the application system.
  • the second ORM framework can parse the operation request, obtain the SQL statement, execute the SQL statement to access the data in the database, and obtain the execution result of the SQL statement as the request result of the operation request, and then generate the target key-value pair, and store the target key-value pair in the cache module. At this time, the request result of the operation request exists in the cache module. Furthermore, the second ORM framework can return the request result of the operation request to the application system.
  • the access pressure of the database can be reduced through the cache module. And for the users of the application system, they will not perceive the existence of the cache module when accessing the database.
  • the ORM execution engine accesses the cache module much faster than the database, when the data to be queried exists in the cache module, the data stored in the cache module is directly returned to the application system, which can improve the data query efficiency, which is equivalent to improving the database access efficiency for the application system.
  • Fig. 5 is a flowchart of accessing a database when the operation type in the operation request is a query type. Referring to Fig. 5 , it includes steps 501 to 506 .
  • Step 501 The second ORM framework performs a hash operation on the operation request to obtain a hash value.
  • Step 502 The second ORM framework queries the cache module for a key value that is the same as the hash value.
  • Step 503 If the second ORM framework finds a key value identical to the hash value from the cache module, the value in the key-value pair where the key value is located is determined as the request result of the operation request and returned to the application system.
  • Step 504 If the second ORM framework does not find the key value identical to the hash value from the cache module, it reads the data to be queried by the operation request from the database.
  • the second ORM framework parses the operation request to obtain the SQL statement, executes the SQL statement to read the data to be queried by the operation request from the database, and obtains the execution result of the SQL statement. Afterwards, the second ORM framework continues to execute step 505.
  • Step 505 the second ORM framework determines the execution result of the SQL statement as the request result of the operation request and returns it to the application system, and the second ORM framework executes step 506 .
  • Step 506 The second ORM framework generates a target key-value pair and stores the target key-value pair in a cache module.
  • the key-value pairs in the cache module can be deleted, which are specifically described below:
  • the key-value pair when storing a key-value pair in the cache module, may be stored in association with the object identifier of the object to which the value in the key-value pair belongs.
  • the value in the key-value pair stored in association with the object identifier of an object in the cache module is the data of the object.
  • the association relationship between the key-value pairs and object identifiers in the cache module is shown in Table 1.
  • the object identifier of the object to which the value in each of the three key-value pairs in Table 1 belongs is Table1, so the three key-value pairs are all associated with Table1 for storage.
  • the embodiment of the present application only uses Table 1 above as an example to illustrate the association between the key-value pairs and the object identifiers in the cache module. Table 1 above does not limit the embodiment of the present application.
  • the first possible implementation method is that after the second ORM framework obtains the operation request, if the operation type in the operation request is an update type, it can first delete all key-value pairs stored in the cache module that are associated with the object identifier in the operation request, and then obtain the request result of the operation request through the above steps 204-205.
  • the purpose of this database access is to update the object identified by the object identifier in the operation request. If the data of the object identified by the object identifier in the operation request in the database changes, the value in the key-value pair associated with the object identifier in the operation request in the cache module will not be the latest data of the object identified by the object identifier. Therefore, all key-value pairs associated with the object identifier in the operation request in the cache module must be deleted.
  • a second possible implementation method is that after the second ORM framework obtains the operation request, if the operation type in the operation request is an update type, it first obtains the request result of the operation request through the above steps 204-205, and then deletes all key-value pairs stored in the cache module in association with the object identifier in the operation request.
  • FIG6 is a flowchart of accessing a database when the operation type in the operation request is an update type. Referring to FIG6 , it includes steps 601 to 603 .
  • Step 601 after obtaining the operation request, if the operation type in the operation request is an update type, the second ORM framework deletes all key-value pairs stored in the cache module in association with the object identifier in the operation request.
  • Step 602 The second ORM framework obtains the request result of the operation request through the above steps 204 to 205.
  • the second ORM framework parses the operation request to obtain the SQL statement, executes the SQL statement to update the object to be accessed by the operation request in the database, and obtains the execution result of the SQL statement.
  • the second ORM framework can determine the execution result of the SQL statement as the request result of the operation request and return it to the application system.
  • Step 603 The second ORM framework deletes again all key-value pairs stored in the cache module in association with the object identifier in the operation request.
  • the database access method provided by the embodiment of the present application does not need to configure the database account password in the application system, which reduces the configuration complexity of the application system, protects privacy data, and reduces data security risks.
  • the application system since the application system does not need to directly connect to the database, it no longer consumes the number of TCP connections of the database. For the database, the overall number of TCP connections is controllable and manageable.
  • the database can be changed directly in the ORM execution engine.
  • the application system will not perceive the change of the database, so it will not affect the application system.
  • the ORM execution engine includes a second ORM framework, the ORM execution engine is communicatively connected to the application system, and the ORM execution engine is communicatively connected to the database, and the application system includes a first ORM framework.
  • the second ORM framework in the ORM execution engine obtains an operation request sent by the first ORM framework, and the operation request is generated by the first ORM framework according to the business statement, that is, the application system sends an operation request to the ORM execution engine when it needs to access the database.
  • the second ORM framework parses the operation request to obtain an SQL statement, which is a statement that can be recognized by the database.
  • the second ORM framework executes the SQL statement to access the data in the database. In this way, the application system does not need to directly connect to the database, so there is no need to configure the database password in the application system, but only the ORM execution engine needs to interact with the database to access the database, thereby ensuring the security of the database.
  • a transaction is a collection of operations that form a single logical unit of work.
  • a transaction can contain one or more operations that form a logical whole. These operations that form the logical whole are either all executed successfully or not executed at all. In other words, all the operations that constitute a transaction either have an impact on the database or have no impact at all, so that the database can always maintain a consistent state regardless of whether the transaction is executed successfully.
  • Transactions have ACID characteristics, which are: Atomicity: All operations in a transaction are inseparable as a whole, either all succeed or all fail. Consistency: The execution result of a transaction must make the database go from one consistent state to another. Isolation: Concurrently executed transactions will not affect each other, and their impact on the database is the same as when they are executed serially. Durability: Once a transaction is committed, its updates to the database are persistent.
  • the ORM execution engine does not receive the start transaction statement, the transaction is automatically submitted, that is, a non-persistent transaction is executed. Specifically, each time the ORM execution engine receives an operation request, it will submit a SQL statement obtained by parsing the operation request after execution. At this time, each SQL statement obtained is actually executed as a transaction. That is, in the above step 205, the second ORM framework will instruct the database to submit the execution result of the SQL statement after obtaining the execution result of the SQL statement. In this case, the automatic submission mode in the database access mode is used to implement access to data in the database.
  • the ORM execution engine If the ORM execution engine receives a start transaction statement, it will not automatically commit the transaction, that is, execute a persistent transaction. Specifically, when the ORM execution engine receives multiple operation requests, it will execute the multiple SQL statements obtained by parsing these multiple operation requests as a transaction, and commit or roll back the execution results of these multiple SQL statements at the same time. In this case, the manual commit mode in the database access mode is used to access the data in the database. This situation is explained in detail below.
  • Fig. 7 is a flow chart of a database access method provided in an embodiment of the present application. Referring to Fig. 7, the method includes the following steps.
  • Step 701 The first ORM framework sends a start transaction statement to the ORM execution engine.
  • the start transaction statement is used to instruct the ORM execution engine to start a transaction to resolve multiple operation requests subsequently sent by the first ORM framework.
  • the multiple SQL statements obtained by the analysis are executed as a transaction, that is, multiple SQL statements are committed or rolled back at the same time.
  • the first ORM framework in the application system will send a start transaction statement to the ORM execution engine to instruct the ORM execution engine to create a transaction, thereby implementing the execution of multiple SQL statements obtained by parsing multiple operation requests subsequently sent by the first ORM framework as a transaction.
  • the application system and the ORM execution engine can communicate through the GRPC (Google Remote Procedure Call) protocol.
  • GRPC Google Remote Procedure Call
  • ORM execution engine cluster including multiple ORM execution engines
  • an application system establishes a connection with an ORM execution engine in the ORM execution engine cluster for the first time, the communication connection between the application system and the ORM execution engine is not interrupted, and the application system can continuously send multiple operation requests to the ORM execution engine.
  • the ORM execution engine can execute the multiple SQL statements obtained by parsing the received multiple operation requests in the same transaction.
  • Step 702 After obtaining the start transaction statement, the second ORM framework in the ORM execution engine creates a target transaction.
  • the middleware module in the ORM execution engine may receive a start transaction statement sent by the first ORM framework, and then send the start transaction statement to the second ORM framework.
  • the second ORM framework in the ORM execution engine will create a target transaction.
  • the second ORM framework can use the multiple SQL statements obtained by parsing the multiple operation requests subsequently sent by the first ORM framework as SQL statements to be executed by the target transaction.
  • Multiple SQL statements in the target transaction can be committed or rolled back at the same time. That is, target transaction commit means committing the execution results of multiple SQL statements in the target transaction at the same time; target transaction rollback means rolling back the execution results of multiple SQL statements in the target transaction at the same time.
  • the operation of the second ORM framework to create a target transaction is similar to the operation of a device creating a transaction in the related art, and the embodiment of the present application will not elaborate on this.
  • Step 703 The first ORM framework sends multiple operation requests to the ORM execution engine.
  • the first ORM framework may continuously send multiple operation requests to the ORM execution engine through the GRPC protocol, each of the multiple operation requests being used to request an operation on data in the database.
  • Step 704 Whenever the second ORM framework obtains an operation request, it parses the obtained operation request to obtain the SQL statement belonging to the target transaction, and executes the latest obtained SQL statement belonging to the target transaction.
  • the middleware module in the ORM execution engine may receive an operation request sent by the first ORM framework, and each time the middleware module receives an operation request, it may send the operation request to the second ORM framework if the database access condition is met.
  • the first ORM framework sends an operation request to the ORM execution engine.
  • the processing process of the second ORM framework in the ORM execution engine on this operation request can refer to the relevant operations in the embodiment of Figure 2 above, and the embodiment of this application will not be repeated here.
  • each time the second ORM framework obtains an operation request it parses the operation request, obtains the SQL statement belonging to the target transaction, executes the latest SQL statement belonging to the target transaction, and obtains the execution result.
  • the second ORM framework executes the SQL statement obtained by parsing each of the multiple operation requests, and obtains the execution results of multiple SQL statements in the target transaction.
  • the execution result of an SQL statement can be returned to the application system as the request result of the corresponding operation request.
  • each time the second ORM framework obtains the execution result of an SQL statement it does not instruct the database to submit the execution result of the SQL statement.
  • FIG8 is a schematic diagram of the interaction between the application system and the ORM execution engine.
  • FIG8 includes an application system 801 and an ORM execution engine 802.
  • the application system 801 sends a start transaction statement to the ORM execution engine 802, it sends multiple operation requests.
  • the second ORM framework in the ORM execution engine 802 obtains an operation request, it executes the SQL statement belonging to the target transaction obtained by parsing the operation request, obtains the execution result of the SQL statement, and then sends the execution result of the SQL statement as the request result of the operation request to the application system 801, thereby sending the request result of each operation request in the multiple operation requests to the application system 801.
  • Step 705 The first ORM framework sends a commit statement or a rollback statement to the ORM execution engine.
  • the commit statement is used to instruct the target transaction to be committed, that is, to instruct the database to perform the execution results of all SQL statements in the target transaction.
  • the rollback statement is used to instruct the target transaction to be rolled back, that is, to instruct the database to roll back the execution results of all SQL statements in the target transaction.
  • Step 706 If the second ORM framework obtains the commit statement, it instructs the database to commit the execution results of all SQL statements in the target transaction.
  • the middleware module in the ORM execution engine may receive a commit statement sent by the first ORM framework, and then send the commit statement to the second ORM framework.
  • the second ORM framework executes these SQL statements, which is manifested as the database recording the operation information of multiple operations on the objects in the database. Only when the database receives the commit instruction, will it submit the execution results of all SQL statements in the target transaction, that is, it truly realizes the operation on the data in the database, and performs multiple operations on the database at the same time.
  • Step 707 If the second ORM framework obtains a rollback statement, it instructs the database to roll back the execution results of all SQL statements in the target transaction.
  • the middleware module in the ORM execution engine may receive a rollback statement sent by the first ORM framework, and then send the rollback statement to the second ORM framework.
  • the database rolls back the execution results of all SQL statements in the target transaction, that is, cancels the operations performed on the data in the database by all SQL statements in the target transaction.
  • the operation information recorded in the database that performs multiple operations on the objects in the database is deleted.
  • the following example illustrates the beneficial effects of multiple accesses to data in a database within one transaction.
  • a user purchases a product in an application system.
  • payment is required and order information is generated after the purchase.
  • it is necessary to reduce the user's account balance and add a new order information to the user's order list.
  • the application system first sends an operation request to modify the balance to the ORM execution engine.
  • the ORM execution engine parses the operation request to obtain a SQL statement to modify the balance, then executes the SQL statement and submits the execution result to complete the modification of the user's account balance.
  • the application system then sends an operation request to add order information to the ORM execution engine.
  • the ORM execution engine parses the operation request to obtain a SQL statement to add order information.
  • a network failure occurs when the ORM execution engine executes the SQL statement.
  • the operation of adding a new order information to the user's order list cannot be completed. In this case, the user can find that his account balance has decreased, but cannot find the order information for the purchased goods.
  • the application system first sends a start transaction statement to the ORM execution engine, and then the ORM execution engine creates a target transaction.
  • the application system then sends an operation request to modify the balance and an operation request to add order information to the ORM execution engine.
  • the ORM execution engine parses the operation request to obtain an SQL statement to modify the balance, executes the SQL statement but does not submit the execution result.
  • the ORM execution engine parses the operation request to obtain an SQL statement to add order information, executes the SQL statement but does not submit the execution result.
  • the application system sends a commit statement to the ORM execution engine, and the ORM execution engine instructs the database to submit the execution results of the two SQL statements in the target transaction to truly modify the user account balance and add order information to the order list.
  • the user can query that the balance of his account has decreased and there is order information for purchasing goods in the order list.
  • the ORM execution engine will not instruct the database to submit the execution results of the two SQL statements in the target transaction before receiving the commit statement, so that the data in the database will not change.
  • the user will find that the balance of his account has not decreased, and no new order information will be added to the order list. In this way, executing multiple operations in one transaction can ensure the consistency of multiple operations during execution.
  • the first ORM framework sends a start transaction statement to the ORM execution engine to instruct the second ORM framework to create a target transaction, so that multiple SQL statements obtained by parsing multiple operation requests subsequently sent by the first ORM framework can be executed in the target transaction.
  • the first ORM framework sends a commit statement or a rollback statement to the ORM execution engine so that the second ORM framework instructs the database to simultaneously commit or roll back the execution results of all SQL statements in the target transaction.
  • FIG9 is a schematic diagram of the structure of a database access system provided in an embodiment of the present application.
  • the database access system includes The ORM execution engine cluster includes multiple application systems 101 and an ORM execution engine cluster.
  • the ORM execution engine cluster can be composed of multiple ORM execution engines 102.
  • Any application system 101 among the multiple application systems 101 can communicate with any ORM execution engine 102 in the ORM execution engine cluster.
  • the application system 101 is explained below:
  • Each of the multiple application systems 101 includes a first ORM framework.
  • the first ORM framework can generate an operation request according to a business statement and send the operation request to the ORM execution engine 102.
  • the operation request is used to request to operate the data in the database 103.
  • the first ORM framework sends the operation request to the ORM execution engine 102 to send the operation request to any one of the ORM execution engines 102 in the ORM execution engine cluster.
  • the first ORM framework generates an operation request according to the business statement, and the relevant content of sending the operation request to the ORM execution engine 102 has been described in detail in steps 201 and 202 in the embodiment of FIG. 2 , and will not be repeated in the embodiment of the present application.
  • the application system 101 only needs to generate an operation request according to the business statement written by the technician using the object-oriented language, and send the operation request to the ORM execution engine 102. There is no need to parse the business statement written by the technician using the object-oriented language. In this way, the business pressure of the application system 101 can be reduced, thereby improving the performance of the application system 101.
  • the ORM execution engine 102 is explained below:
  • Each of the multiple ORM execution engines 102 in the ORM execution engine cluster is in communication connection with the database 103.
  • the multiple ORM execution engines 102 in the ORM execution engine cluster can communicate with each other to achieve data sharing.
  • Each of the multiple ORM execution engines 102 in the ORM execution engine cluster includes a second ORM framework.
  • the second ORM framework can execute steps 203 to 205 in the embodiment of FIG. 2 , that is, to obtain the operation request sent by the first ORM framework, parse the operation request, obtain an SQL statement, execute the SQL statement, access the data in the database 103, and obtain the execution result of the SQL statement.
  • the ORM execution engine 102 acts as a bridge between the application system 101 and the database 103, so that the application system 101 does not need to directly connect to the database 103, but the ORM execution engine 102 communicates with the database 103 to access the database 103. Therefore, there is no need to configure the account password of the database 103 in the application system 101, which improves the security of the database 103.
  • the application system 101 and the ORM execution engine 102 can communicate via the GRPC protocol.
  • it can be ensured that multiple operation requests sent by the first ORM framework in an application system 101 are all sent to the same ORM execution engine 102, thereby ensuring that the SQL statements obtained by parsing the multiple operation requests can be executed in one transaction.
  • the above-mentioned embodiment of Figure 7 explains the process of executing multiple SQL statements obtained by parsing multiple operation requests in one transaction, and the embodiment of this application will not be repeated here.
  • the database access system may further include a middleware module 1001 , and the middleware module 1001 is in communication connection with the application system 101 , that is, the middleware module 1001 may directly communicate with the first ORM framework.
  • the middleware module 1001 may send the operation request to the second ORM framework 1002 if the database access condition is met.
  • Fig. 11 is a schematic diagram of the middleware module 1001.
  • Fig. 11 includes an application system 101, a middleware module 1001, and a second ORM framework 1002.
  • the following database access conditions can be set in the middleware module 1001:
  • the number of accesses to the database 103 is less than a first number threshold (flow control).
  • the application system 101 has access rights (table authority control) to the object to be accessed by the operation request.
  • the application system 101 has access rights to the database 103 (account system authentication).
  • the operation type in the operation request is the type of operation that the database 103 allows to perform on the object to be accessed by the operation request (controlled by ORM syntax).
  • the middleware module 1001 After receiving the operation request, the middleware module 1001 first determines whether the operation request satisfies the set database access condition. Only when the operation request satisfies the database access condition does the middleware module 1001 send the operation request to the second ORM framework 1002.
  • step 203 of the embodiment of FIG. 2 The relevant contents about the database access conditions have been explained in step 203 of the embodiment of FIG. 2 , and will not be described in detail in the embodiment of the present application.
  • the ORM execution engine 102 can well coordinate and manage the access to the entire database 103, while meeting all business requirements and supporting more advanced, special, and customized management. Control configuration.
  • the database access system may further include a cache module 1201, which is in communication connection with the ORM execution engine 102.
  • the cache module 1201 stores a plurality of key-value pairs, and each of the plurality of key-value pairs stores a request result of an operation request of a query type. That is, the key value in each of the plurality of key-value pairs is a hash value obtained by performing a hash operation on the operation request of a query type, and the value value in each of the plurality of key-value pairs is a request result of an operation request of a query type.
  • the key value in the key-value pair is a hash value of an operation request of a query type
  • the value value in the key-value pair is a request result of the operation request, that is, the data queried from the database 103 by the operation request.
  • the second ORM framework 1002 can directly execute the above steps 204 to 205 to obtain the request result of the operation request.
  • the second ORM framework may first perform a hash operation on the operation request to obtain a hash value; and query the cache module 1201 for a key value identical to the hash value. If a key value identical to the hash value is queried from the cache module 1201, the value in the key-value pair of the key value identical to the hash value in the cache module 1201 is determined as the request result of the operation request.
  • the second ORM framework executes the above steps 204-205, that is, parses the operation request to obtain the SQL statement, executes the SQL statement to access the data in the database, and obtains the execution result of the SQL statement as the request result of the operation request.
  • a target key-value pair may also be generated and stored in the cache module 1201.
  • the second ORM framework may delete all key-value pairs stored in the cache module 1201 in association with the object identifier in the operation request.
  • the database access system includes the cache module 1201
  • the access pressure of the database 103 can be reduced through the cache module 1201.
  • the existence of the cache module 1201 will not be perceived when accessing the database 103.
  • the speed of the ORM execution engine 102 accessing the cache module 1201 is much faster than the speed of accessing the database 103, when the cache module 1201 contains the data to be queried, the data stored in the cache module 1201 is directly returned to the application system, which can improve the data query efficiency, which is equivalent to improving the database access efficiency for the application system 101.
  • the application system 101 in the database access system does not need to be directly connected to the database 103, but accesses the database 103 by setting an ORM execution engine 102 between the application system 101 and the database 103.
  • the application system 101 sends an operation request to the ORM execution engine 102 to request access to the data in the database 103, and then the ORM execution engine 102 communicates with the database 103 to achieve access to the database 103.
  • the account password of the database 103 in the application system 101 which reduces the configuration complexity of the application system 101, protects privacy data, reduces data security risks, and thus ensures the security of the database 103.
  • the application system includes a first ORM framework
  • the ORM execution engine includes a second ORM framework
  • the ORM execution engine is connected to the database for communication.
  • the first ORM framework generates an operation request based on the business statement, and then sends the operation request to the ORM execution engine, that is, the application system sends an operation request to the ORM execution engine when it needs to access the database.
  • the second ORM framework in the ORM execution engine receives the operation request, it parses the operation request to obtain an SQL statement, which is a statement that the database can recognize.
  • the second ORM framework executes the SQL statement to access the data in the database. In this way, the application system does not need to directly connect to the database, so there is no need to configure the database password in the application system, and only the ORM execution engine needs to interact with the database to access the database, thereby ensuring the security of the database.
  • FIG13 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application.
  • the computer device 13 includes: a processor 130, a memory 131, and a computer program 132 stored in the memory 131 and executable on the processor 130.
  • 130 implements the steps executed by the ORM execution engine in the database access method in the above embodiment.
  • the computer device 13 may be a general-purpose computer device or a special-purpose computer device. In a specific implementation, the computer device 13 may be a network server. Those skilled in the art will appreciate that FIG. 13 is merely an example of the computer device 13 and does not constitute a limitation on the computer device 13.
  • the computer device 13 may include more or fewer components than shown in the figure, or may combine certain components, or different components, such as input and output devices, network access devices, etc.
  • the processor 130 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • a general-purpose processor may be a microprocessor or any conventional processor.
  • the memory 131 may be an internal storage unit of the computer device 13, such as a hard disk or memory of the computer device 13. In other embodiments, the memory 131 may also be an external storage device of the computer device 13, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card (Flash Card), etc. equipped on the computer device 13. Further, the memory 131 may also include both an internal storage unit of the computer device 13 and an external storage device. The memory 131 is used to store an operating system, an application program, a boot loader (Boot Loader), data, and other programs. The memory 131 may also be used to temporarily store data that has been output or is to be output.
  • Boot Loader boot loader
  • An embodiment of the present application also provides a computer device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, and when the processor executes the computer program, the steps in any of the above-mentioned method embodiments are implemented.
  • An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program.
  • the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
  • An embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the steps in the above-mentioned method embodiments.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
  • the present application implements all or part of the processes in the above method embodiments, which can be completed by instructing the relevant hardware through a computer program.
  • the computer program can be stored in a computer-readable storage medium.
  • the steps of each of the above method embodiments can be implemented.
  • the computer program includes computer program code, which can be in source code form, object code form, executable file or some intermediate form.
  • the computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera/terminal device, recording medium, computer memory, ROM (Read-Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read-Only Memory), magnetic tape, floppy disk and optical data storage device.
  • the computer-readable storage medium mentioned in the present application can be a non-volatile storage medium, in other words, a non-transient storage medium.
  • the disclosed devices/computer equipment and methods can be implemented in other ways.
  • the device/computer equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
  • Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present application relates to the technical field of computers, and discloses a database access system and method, a computer device, and a storage medium. The database access system comprises an application system 101 and an ORM execution engine 102. The application system 101 comprises a first ORM framework, the ORM execution engine 102 comprises a second ORM framework, and the ORM execution engine 102 is communicatively connected to a database 103. The first ORM framework is used for generating an operation request according to a service statement, and sending the operation request to the ORM execution engine 102. The second ORM framework is used for performing parsing after acquiring the operation request, to obtain an SQL statement, and executing the SQL statement to access data in the database 103. In the present application, the application system 101 does not need to be directly connected to the database 103, and only the ORM execution engine 102 needs to interact with the database 103, so as to achieve an access to the database 103, thereby ensuring the security of the database 103.

Description

数据库访问系统、方法、计算机设备和存储介质Database access system, method, computer device and storage medium
本申请要求于2022年11月08日在中国专利局提交的、申请号为202211391763.4、发明名称为“数据库访问系统、方法、计算机设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to the Chinese patent application filed with the China Patent Office on November 8, 2022, with application number 202211391763.4 and invention name “Database access system, method, computer device and storage medium”, the entire contents of which are incorporated by reference in this application.
技术领域Technical Field
本申请涉及计算机技术领域,具体涉及一种数据库访问系统、方法、计算机设备和存储介质。The present application relates to the field of computer technology, and in particular to a database access system, method, computer device and storage medium.
背景技术Background technique
对于一个应用系统来说,数据库中存储有大量的业务数据,一个应用系统在进行业务操作时往往需要对数据库进行访问,以实现对业务数据的读取、修改或存储。For an application system, a large amount of business data is stored in the database. When performing business operations, an application system often needs to access the database to read, modify or store the business data.
相关技术中,在每个应用系统中配置数据库的账号密码后,应用系统就可以直接和数据库交互了。每个应用系统中集成有ORM(Object Relational Mapping,对象关系映射)框架。ORM框架可以将技术人员编写的面向对象的程序语言自动编译成数据库可以识别的数据库操作语言。这种情况下,技术人员可以在应用系统编写面向对象的业务程序,之后由ORM框架执行该业务程序,以将该业务程序自动编译为数据库可以识别的操作程序,并执行该操作程序,以对数据库进行访问。In the related art, after configuring the database account and password in each application system, the application system can interact directly with the database. Each application system is integrated with an ORM (Object Relational Mapping) framework. The ORM framework can automatically compile the object-oriented programming language written by the technician into a database operation language that can be recognized by the database. In this case, the technician can write an object-oriented business program in the application system, and then the ORM framework will execute the business program to automatically compile the business program into an operation program that can be recognized by the database, and execute the operation program to access the database.
然而,在多个应用系统均需要访问同一个数据库的情况下,该多个应用系统中的每个应用系统均需要配置数据库的账号密码,那么每个应用系统都会知道数据库的账号密码,这种隐私数据的广泛使用,会给数据库带来极大的安全隐患,从而降低数据库的安全性。However, when multiple application systems need to access the same database, each of the multiple application systems needs to configure the database account and password. Then each application system will know the database account and password. The widespread use of such private data will bring great security risks to the database, thereby reducing the security of the database.
申请内容Application Contents
本申请实施例的目的在于:提供一种数据库访问系统、方法、计算机设备和存储介质,包括但不限于解决数据库安全性低的问题。The purpose of the embodiments of the present application is to provide a database access system, method, computer device and storage medium, including but not limited to solving the problem of low database security.
本申请实施例采用的技术方案是:The technical solution adopted in the embodiment of the present application is:
第一方面,提供了一种数据库访问系统,所述数据库访问系统包括应用系统和关系对象映射ORM执行引擎,所述应用系统包括第一ORM框架,所述ORM执行引擎包括第二ORM框架,所述ORM执行引擎与数据库进行通信连接;In a first aspect, a database access system is provided, the database access system comprising an application system and an object relation mapping (ORM) execution engine, the application system comprising a first ORM framework, the ORM execution engine comprising a second ORM framework, the ORM execution engine being in communication connection with a database;
所述第一ORM框架,用于根据业务语句生成操作请求,向所述ORM执行引擎发送所述操作请求,所述操作请求用于请求对所述数据库中的数据进行操作;The first ORM framework is used to generate an operation request according to the business statement, and send the operation request to the ORM execution engine, wherein the operation request is used to request to operate the data in the database;
所述第二ORM框架,用于在获取到所述操作请求后,对所述操作请求进行解析,得到SQL(Structured Query Language,结构化查询语言)语句;执行所述SQL语句,以访问所述数据库中的数据,得到所述SQL语句的执行结果。The second ORM framework is used to parse the operation request after obtaining the operation request to obtain an SQL (Structured Query Language) statement; execute the SQL statement to access the data in the database to obtain the execution result of the SQL statement.
第二方面,提供了一种数据库访问方法,应用于关系对象映射ORM执行引擎,所述ORM执行引擎包括第二ORM框架,所述ORM执行引擎与应用系统进行通信连接,所述ORM执行引擎与数据库进行通信连接,所述应用系统包括第一ORM框架,所述方法包括:In a second aspect, a database access method is provided, which is applied to a relational object mapping (ORM) execution engine, wherein the ORM execution engine includes a second ORM framework, the ORM execution engine is communicatively connected to an application system, the ORM execution engine is communicatively connected to a database, the application system includes a first ORM framework, and the method includes:
所述第二ORM框架获取所述第一ORM框架发送的操作请求,所述操作请求是所述第一ORM框架根据业务语句生成的,所述操作请求用于请求对所述数据库中的数据进行操作;The second ORM framework obtains an operation request sent by the first ORM framework, where the operation request is generated by the first ORM framework according to a business statement, and is used to request an operation to be performed on the data in the database;
所述第二ORM框架在获取到所述操作请求后,对所述操作请求进行解析,得到结构化查询语言SQL语句;After acquiring the operation request, the second ORM framework parses the operation request to obtain a structured query language SQL statement;
所述第二ORM框架执行所述SQL语句,以访问所述数据库中的数据,得到所述SQL语句的执行结果。The second ORM framework executes the SQL statement to access the data in the database and obtains the execution result of the SQL statement.
第三方面,提供一种计算机设备,所述计算机设备包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行时实现上述的数据库访问方法。 In a third aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the above-mentioned database access method when executed by the processor.
第四方面,提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现上述的数据库访问方法。In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned database access method is implemented.
第五方面,提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述的数据库访问方法的步骤。In a fifth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the steps of the above-mentioned database access method.
本申请实施例提供的数据库访问系统的有益效果在于:应用系统包括第一ORM框架,ORM执行引擎包括第二ORM框架,并且ORM执行引擎与数据库进行通信连接。第一ORM框架根据业务语句生成操作请求,再将该操作请求发送给ORM执行引擎,也即是应用系统在需要访问数据库时向ORM执行引擎发送操作请求。之后ORM执行引擎中的第二ORM框架接收到该操作请求之后,对操作请求进行解析得到SQL语句,该SQL语句是数据库可以识别的语句。之后第二ORM框架执行该SQL语句,以访问数据库中的数据。如此,应用系统无需直接连接数据库,因而应用系统中无需配置数据库的密码,而只需ORM执行引擎与数据库进行交互,以实现对数据库的访问,从而保证了数据库的安全性。The beneficial effect of the database access system provided by the embodiment of the present application is that the application system includes a first ORM framework, the ORM execution engine includes a second ORM framework, and the ORM execution engine is connected to the database for communication. The first ORM framework generates an operation request based on the business statement, and then sends the operation request to the ORM execution engine, that is, the application system sends an operation request to the ORM execution engine when it needs to access the database. After that, after the second ORM framework in the ORM execution engine receives the operation request, it parses the operation request to obtain an SQL statement, which is a statement that the database can recognize. After that, the second ORM framework executes the SQL statement to access the data in the database. In this way, the application system does not need to directly connect to the database, so there is no need to configure the database password in the application system, and only the ORM execution engine needs to interact with the database to access the database, thereby ensuring the security of the database.
本申请实施例提供的数据库访问方法的有益效果在于:ORM执行引擎包括第二ORM框架,ORM执行引擎与应用系统进行通信连接,并且ORM执行引擎与数据库进行通信连接,应用系统包括第一ORM框架。ORM执行引擎中的第二ORM框架获取第一ORM框架发送的操作请求,该操作请求为第一ORM框架根据业务语句生成,也即是应用系统在需要访问数据库时向ORM执行引擎发送操作请求。之后第二ORM框架对该操作请求进行解析得到SQL语句,该SQL语句是数据库可以识别的语句。第二ORM框架执行该SQL语句,以访问数据库中的数据。如此,应用系统无需直接连接数据库,因而应用系统中无需配置数据库的密码,而只需ORM执行引擎与数据库进行交互,以实现对数据库的访问,从而保证了数据库的安全性。The beneficial effect of the database access method provided by the embodiment of the present application is that the ORM execution engine includes a second ORM framework, the ORM execution engine is connected to the application system for communication, and the ORM execution engine is connected to the database for communication, and the application system includes a first ORM framework. The second ORM framework in the ORM execution engine obtains the operation request sent by the first ORM framework, and the operation request is generated by the first ORM framework according to the business statement, that is, the application system sends an operation request to the ORM execution engine when it needs to access the database. Afterwards, the second ORM framework parses the operation request to obtain an SQL statement, which is a statement that can be recognized by the database. The second ORM framework executes the SQL statement to access the data in the database. In this way, the application system does not need to directly connect to the database, so there is no need to configure the database password in the application system, but only the ORM execution engine needs to interact with the database to achieve access to the database, thereby ensuring the security of the database.
可以理解的是,上述第三方面、第四方面、第五方面的有益效果可以参见上述第二方面中的相关描述,在此不再赘述。It can be understood that the beneficial effects of the third, fourth and fifth aspects mentioned above can be found in the relevant description of the second aspect mentioned above, and will not be repeated here.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例或示范性技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or exemplary technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
图1是本申请实施例提供的一种数据库访问系统的结构示意图;FIG1 is a schematic diagram of the structure of a database access system provided in an embodiment of the present application;
图2是本申请实施例提供的一种数据库访问方法的流程图;FIG2 is a flow chart of a database access method provided in an embodiment of the present application;
图3是本申请实施例提供的一种操作请求的示意图;FIG3 is a schematic diagram of an operation request provided in an embodiment of the present application;
图4是本申请实施例提供的一种应用系统与ORM执行引擎的交互示意图;FIG4 is a schematic diagram of the interaction between an application system and an ORM execution engine provided in an embodiment of the present application;
图5是本申请实施例提供的另一种数据库访问方法的流程图;FIG5 is a flow chart of another database access method provided in an embodiment of the present application;
图6是本申请实施例提供的又一种数据库访问方法的流程图;FIG6 is a flowchart of another database access method provided in an embodiment of the present application;
图7是本申请实施例提供的再一种数据库访问方法的流程图;7 is a flowchart of another database access method provided in an embodiment of the present application;
图8是本申请实施例提供的另一种应用系统与ORM执行引擎的交互示意图;FIG8 is a schematic diagram of another interaction between an application system and an ORM execution engine provided in an embodiment of the present application;
图9是本申请实施例提供的另一种数据库访问系统的结构示意图;FIG9 is a schematic diagram of the structure of another database access system provided in an embodiment of the present application;
图10是本申请实施例提供的又一种数据库访问系统的结构示意图;10 is a schematic diagram of the structure of another database access system provided in an embodiment of the present application;
图11是本申请实施例提供的一种中间件模块的示意图;FIG11 is a schematic diagram of a middleware module provided in an embodiment of the present application;
图12是本申请实施例提供的再一种数据库访问系统的结构示意图;12 is a schematic diagram of the structure of another database access system provided in an embodiment of the present application;
图13是本申请实施例提供的一种计算机设备的结构示意图。FIG. 13 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application.
具体实施方式Detailed ways
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本申请。In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present application.
应当理解的是,本申请提及的“多个”是指两个或两个以上。在本申请的描述中,除非另有说明,“/”表示或的意思,比如,A/B可以表示A或B;本文中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,比如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在 B这三种情况。另外,为了便于清楚描述本申请的技术方案,采用了“第一”、“第二”等字样对功能和作用基本相同的相同项或相似项进行区分。本领域技术人员可以理解“第一”、“第二”等字样并不对数量和执行次序进行限定,并且“第一”、“第二”等字样也并不限定一定不同。It should be understood that the "multiple" mentioned in this application refers to two or more. In the description of this application, unless otherwise specified, "/" means or, for example, A/B can mean A or B; "and/or" in this article is just a way to describe the association relationship of related objects, indicating that there can be three relationships, for example, A and/or B can mean: A exists alone, A and B exist at the same time, and A exists alone. B. In addition, in order to clearly describe the technical solution of the present application, the words "first", "second" and the like are used to distinguish the same or similar items with substantially the same functions and effects. Those skilled in the art can understand that the words "first", "second" and the like do not limit the quantity and execution order, and the words "first", "second" and the like do not necessarily limit the difference.
在对本申请实施例进行详细地解释说明之前,先对本申请实施例的应用场景予以说明。Before explaining the embodiments of the present application in detail, the application scenarios of the embodiments of the present application are first described.
下面先对应用场景涉及的ORM框架进行说明。The following is an explanation of the ORM framework involved in the application scenario.
业务逻辑层和用户界面层是面向对象的,当对象的信息发生变化的时候,就需要把对象的信息保存在数据库(包括但不限于关系型数据库)中,但是要对数据库中的数据进行更新不能采用面向对象的语言,如此就需要编写非常复杂的数据库语言才能对数据库中的数据进行更新。The business logic layer and the user interface layer are object-oriented. When the information of an object changes, it is necessary to save the object information in a database (including but not limited to a relational database). However, object-oriented languages cannot be used to update the data in the database. Therefore, it is necessary to write a very complex database language to update the data in the database.
ORM框架就是一种为了解决面向对象与数据库存在的语言互不匹配的现象的技术。具体是通过描述对象和数据库之间映射的元数据,将程序中的对象自动持久化到数据库中,也即ORM框架是连接业务逻辑层和数据库的桥梁。一般情况下,元数据中的一个持久化类和数据库中的一个表对应,类的每个实例对应表中的一条记录,类的每个属性对应表的每个字段。The ORM framework is a technology that solves the language mismatch between object-oriented and database. Specifically, it automatically persists objects in the program to the database by describing the metadata mapping between the object and the database. In other words, the ORM framework is a bridge connecting the business logic layer and the database. In general, a persistent class in the metadata corresponds to a table in the database, each instance of the class corresponds to a record in the table, and each attribute of the class corresponds to each field in the table.
由于ORM框架提供了一个数据库和对象之间的映射,所以我们在操作数据库中的数据时,就不需要再去和复杂的数据库语言打交道,只要像平时操作对象一样操作它即可。ORM框架能够使开发更加对象化,对于技术人员来说只需编写面向对象的业务程序,使得程序编写更加方便,如此能够提高开发效率,降低开发成本。Since the ORM framework provides a mapping between a database and an object, we no longer need to deal with complex database languages when operating the data in the database. We can just operate it like we normally operate an object. The ORM framework can make development more object-oriented. For technical personnel, they only need to write object-oriented business programs, which makes program writing more convenient, thus improving development efficiency and reducing development costs.
一般情况下,基于ORM框架的应用系统是通过与数据库直接进行通信连接来实现对数据库的访问的。具体是:应用系统中的ORM框架执行技术人员编写的业务程序,以将该业务程序自动编译为数据库可以识别的操作语句(在本申请实施例中为SQL语句),并执行该操作语句,以对数据库进行访问。这种情况下会存在以下问题。Generally, an application system based on an ORM framework accesses a database by directly communicating with the database. Specifically, the ORM framework in the application system executes the business program written by the technician to automatically compile the business program into an operation statement (SQL statement in the embodiment of the present application) that can be recognized by the database, and executes the operation statement to access the database. In this case, the following problems may occur.
第一,访问同一数据库的每个应用系统中都要配置数据库的账号密码,这种情况下,一方面会增加应用系统的配置复杂度,另一方面每个应用系统都会知道数据库的账号密码,这会给数据库带来极大的安全隐患。First, the database account and password must be configured in each application system that accesses the same database. In this case, on the one hand, the configuration complexity of the application system will be increased, and on the other hand, each application system will know the database account and password, which will bring great security risks to the database.
第二,数据库设置有最大TCP(Transmission Control Protocol,传输控制协议)连接数,也即数据库只允许有限数量个应用系统连接。每个应用系统与数据库的连接都会消耗数据库的TCP连接数,并且应用系统消耗的TCP连接数是自身定义的,也即应用系统可以定义自身与数据库的TCP连接数,这对数据库来说,整体的TCP连接数是不可控的。考虑一种极端情况,如果一个应用系统定义的TCP连接数就是数据库可支持的最大TCP连接数,那么这会导致其余应用系统无法连接数据库,从而影响其余应用系统的性能。Second, the database is set with a maximum number of TCP (Transmission Control Protocol) connections, which means that the database only allows a limited number of application systems to connect. Each connection between an application system and the database will consume the database's TCP connection number, and the number of TCP connections consumed by the application system is defined by itself, which means that the application system can define the number of TCP connections between itself and the database. For the database, the overall number of TCP connections is uncontrollable. Consider an extreme case, if the number of TCP connections defined by an application system is the maximum number of TCP connections that the database can support, then this will cause the other application systems to be unable to connect to the database, thereby affecting the performance of the other application systems.
第三,这种应用系统与数据库直连的方式,无法统筹管理整个数据库访问。虽然数据库自带了一些管控配置,但无法满足所有业务需求,无法实现对整个数据库访问增加更高级的、特殊的、自定义的限制功能,例如用户体系认证、黑白名单、流量控制等。Third, this direct connection between the application system and the database cannot coordinate the management of the entire database access. Although the database comes with some control configurations, it cannot meet all business needs and cannot add more advanced, special, and customized restrictions to the entire database access, such as user system authentication, blacklists and whitelists, and traffic control.
第四,若数据库本身需要被更换(例如从MySQL数据库更换为PostgreSQL数据库),则所有应用系统都需要同步更新数据库层面相关的代码和配置。这种情况下,应用系统的复杂性较高,并且如果同步更新出现问题,那么很容易导致部署、运维、开发等方面出现问题。Fourth, if the database itself needs to be replaced (for example, from a MySQL database to a PostgreSQL database), all application systems need to update the database-related code and configuration simultaneously. In this case, the application system is more complex, and if there is a problem with the synchronous update, it is easy to cause problems in deployment, operation and maintenance, and development.
第五,应用系统本身不具有数据缓存能力,并且,由于一个应用系统对数据库的表操作可能会随时被其他应用系统修改,所以即使在应用系统中对数据进行缓存也无法保证缓存的有效性。Fifth, the application system itself does not have the ability to cache data. Furthermore, since an application system's operations on database tables may be modified by other application systems at any time, the effectiveness of the cache cannot be guaranteed even if the data is cached in the application system.
为此,本申请实施例提供了一种数据库访问方法,在需要访问数据库时,应用系统可以向ORM执行引擎发送操作请求,之后ORM执行引擎可以对该操作请求进行处理,再由ORM执行引擎与数据库进行交互,以实现对数据库的访问。如此,应用系统无需直接连接数据库,因而应用系统中无需配置数据库的密码,从而保证了数据库的安全性。To this end, the embodiment of the present application provides a database access method. When accessing a database is required, the application system can send an operation request to the ORM execution engine, and then the ORM execution engine can process the operation request, and then the ORM execution engine interacts with the database to achieve access to the database. In this way, the application system does not need to directly connect to the database, so there is no need to configure the database password in the application system, thereby ensuring the security of the database.
下面对本申请实施例涉及的系统架构予以说明。The system architecture involved in the embodiments of the present application is described below.
图1是本申请实施例提供的一种数据库访问系统的示意图。参见图1,该数据库访问系统包括:应用系统101和ORM执行引擎102。FIG1 is a schematic diagram of a database access system provided in an embodiment of the present application. Referring to FIG1 , the database access system includes: an application system 101 and an ORM execution engine 102 .
应用系统101中包括第一ORM框架,第一ORM框架用于在需要对数据库103进行访问时,生成操作请求。应用系统101可以部署于终端,也可以部署于服务器,应用系统101可以与ORM执行引擎 102通过有线连接或无线连接进行通信。应用系统101的数量可以为一个或多个,多个应用系统101均与ORM执行引擎102进行通信。The application system 101 includes a first ORM framework, which is used to generate an operation request when access to the database 103 is required. The application system 101 can be deployed on a terminal or a server. The application system 101 can be connected to an ORM execution engine. 102 communicates via a wired connection or a wireless connection. The number of application systems 101 can be one or more, and the multiple application systems 101 all communicate with the ORM execution engine 102.
该数据库访问系统中可以包括一个ORM执行引擎102,也可以包括多个ORM执行引擎102,多个ORM执行引擎102整体作为一个ORM执行引擎集群来与一个或多个应用系统101进行通信,并且,多个ORM执行引擎102整体作为一个ORM执行引擎集群来与数据库103进行通信。ORM执行引擎102包括第二ORM框架,第二ORM框架用于对接收到的操作请求进行处理,并与数据库103进行交互。ORM执行引擎102可以部署于服务器,该服务器可以是一台服务器,也可以是由多台服务器组成的服务器集群。The database access system may include one ORM execution engine 102, or may include multiple ORM execution engines 102, and the multiple ORM execution engines 102 as a whole act as an ORM execution engine cluster to communicate with one or more application systems 101, and the multiple ORM execution engines 102 as a whole act as an ORM execution engine cluster to communicate with the database 103. The ORM execution engine 102 includes a second ORM framework, and the second ORM framework is used to process the received operation request and interact with the database 103. The ORM execution engine 102 can be deployed on a server, which can be a single server or a server cluster consisting of multiple servers.
ORM执行引擎102可以通过有线连接或无线连接与数据库103进行通信,也可以通过有线连接或无线连接与应用系统101进行通信。The ORM execution engine 102 may communicate with the database 103 through a wired connection or a wireless connection, and may also communicate with the application system 101 through a wired connection or a wireless connection.
例如:应用系统101需要访问数据库103中的数据时,应用系统101中的第一ORM框架生成访问数据库103的操作请求,并发送给ORM执行引擎102,ORM执行引擎102中的第二ORM框架接收到该操作请求后,对该操作请求进行处理,并与数据库103进行交互,以实现对数据库103中的数据的操作。For example: when the application system 101 needs to access the data in the database 103, the first ORM framework in the application system 101 generates an operation request to access the database 103 and sends it to the ORM execution engine 102. After receiving the operation request, the second ORM framework in the ORM execution engine 102 processes the operation request and interacts with the database 103 to implement the operation on the data in the database 103.
在本申请实施例中,由ORM执行引擎102直接与数据库103通信,应用系统101无需直接与数据库103通信,而是通过ORM执行引擎102实现对数据库103的访问,因而应用系统101中无需配置数据库103的密码,只需在ORM执行引擎102中配置数据库103的密码。在本申请实施例中,在该数据库访问系统中只存在一个ORM执行引擎102的情况下,只需在这个ORM执行引擎102中配置数据库103的密码即可;在该数据库访问系统中存在多个ORM执行引擎102的情况下,只需在由该多个ORM执行引擎102构成的ORM执行引擎集群中配置数据库103的密码即可。应用系统作为面向用户的系统,其安全等级低于ORM执行引擎102,即ORM执行引擎102的安全等级较高,因而相比于相关技术中由多个应用系统直接与数据库通信且在多个应用系统中配置数据库的密码的方案,本申请实施例提供的数据库访问系统在ORM执行引擎102中配置数据库103的密码,可以提高数据库103的安全性。In the embodiment of the present application, the ORM execution engine 102 directly communicates with the database 103, and the application system 101 does not need to directly communicate with the database 103, but accesses the database 103 through the ORM execution engine 102, so there is no need to configure the password of the database 103 in the application system 101, and it is only necessary to configure the password of the database 103 in the ORM execution engine 102. In the embodiment of the present application, when there is only one ORM execution engine 102 in the database access system, it is only necessary to configure the password of the database 103 in this ORM execution engine 102; when there are multiple ORM execution engines 102 in the database access system, it is only necessary to configure the password of the database 103 in the ORM execution engine cluster composed of the multiple ORM execution engines 102. As a user-oriented system, the security level of the application system is lower than that of the ORM execution engine 102, that is, the security level of the ORM execution engine 102 is higher. Therefore, compared with the solution in the related art in which multiple application systems directly communicate with the database and configure the database password in multiple application systems, the database access system provided in the embodiment of the present application configures the password of the database 103 in the ORM execution engine 102, which can improve the security of the database 103.
下面对本申请实施例提供的数据库访问方法进行详细地解释说明。The database access method provided in the embodiment of the present application is explained in detail below.
图2是本申请实施例提供的一种数据库访问方法的流程图。该数据库访问方法应用于上文图1实施例所述的数据库访问系统。参见图2,该方法包括以下步骤。Fig. 2 is a flow chart of a database access method provided in an embodiment of the present application. The database access method is applied to the database access system described in the embodiment of Fig. 1 above. Referring to Fig. 2, the method includes the following steps.
步骤201:第一ORM框架根据业务语句生成操作请求。Step 201: The first ORM framework generates an operation request according to the business statement.
业务语句是技术人员使用面向对象的程序语言编写的语句。可选地,在应用系统中集成的第一ORM框架可以是在应用系统中部署的基于ORM的SDK(Software Development Kit,软件开发工具包)。这种情况下,技术人员可以直接采用ORM的程序语法编写面向对象的业务语句。之后第一ORM框架可以根据技术人员编写的业务语句生成操作请求。该操作请求用于请求对数据库中的数据进行操作。The business statement is a statement written by the technician using an object-oriented programming language. Optionally, the first ORM framework integrated in the application system can be an ORM-based SDK (Software Development Kit) deployed in the application system. In this case, the technician can directly use the ORM programming syntax to write object-oriented business statements. After that, the first ORM framework can generate an operation request based on the business statement written by the technician. The operation request is used to request an operation on the data in the database.
在本申请实施例中,第一ORM框架在应用系统调用业务语句时,对业务语句进行解析之后,对解析得到的结果进行封装,来得到操作请求。如此,该操作请求会包括与业务语句相关的信息,也即会包括对数据库的操作的相关信息。可选地,该操作请求可以包括对象标识、操作类型、对象标识所标识的对象的原始数据、对象标识所标识的对象的更新数据等信息。In an embodiment of the present application, when the application system calls a business statement, the first ORM framework parses the business statement and encapsulates the parsed result to obtain an operation request. In this way, the operation request will include information related to the business statement, that is, it will include relevant information on the operation of the database. Optionally, the operation request may include information such as the object identifier, the operation type, the original data of the object identified by the object identifier, and the updated data of the object identified by the object identifier.
对象标识为应用系统所要访问的数据库中的对象的标识,例如,该对象标识可以为数据库中的表名称,本申请实施例对此不作限定。操作类型为应用系统对数据库中的对象进行操作的类型,例如,操作类型可以包括新增(INSERT)、删除(DELETE)、更新(UPDATE)、查找(FIND)。The object identifier is the identifier of the object in the database to be accessed by the application system. For example, the object identifier can be the name of a table in the database, which is not limited in the embodiments of the present application. The operation type is the type of operation performed by the application system on the object in the database. For example, the operation type can include adding (INSERT), deleting (DELETE), updating (UPDATE), and finding (FIND).
例如,图3为操作请求的数据示意图,图3示出的操作请求包括操作类型、表名称、原始表数据、原始SQL数据、更新数据等与数据库的操作相关的信息。For example, FIG3 is a data diagram of an operation request. The operation request shown in FIG3 includes information related to database operations, such as operation type, table name, original table data, original SQL data, and update data.
步骤202:第一ORM框架向ORM执行引擎发送该操作请求。Step 202: The first ORM framework sends the operation request to the ORM execution engine.
在本申请实施例中,第一ORM框架提供了与ORM执行引擎进行通信连接的接口。如此,应用系统中的第一ORM框架在生成该操作请求后,可以通过该接口向ORM执行引擎发送该操作请求。In the embodiment of the present application, the first ORM framework provides an interface for communicating with the ORM execution engine. Thus, after generating the operation request, the first ORM framework in the application system can send the operation request to the ORM execution engine through the interface.
作为一种示例,用户想要查看账户的订单信息,那么该用户可以在一个应用系统中点击订单信息的查询按钮,以触发访问数据库中账户的订单信息的操作。此时应用系统会调用查询订单信息的业务语句,那么第一ORM框架就可以对该业务语句进行封装,来得到对应的操作请求,将该操作请求发送给 ORM执行引擎,该操作请求即是从数据库中查询这个用户的账户的订单信息的请求。ORM执行引擎接收到该操作请求后就可以进行相应的处理了,具体可以执行如下步骤203-步骤205。As an example, if a user wants to view the order information of an account, the user can click an order information query button in an application system to trigger the operation of accessing the order information of the account in the database. At this time, the application system will call the business statement for querying the order information, and the first ORM framework can encapsulate the business statement to obtain the corresponding operation request and send the operation request to The ORM execution engine, the operation request is a request to query the order information of the user's account from the database. After receiving the operation request, the ORM execution engine can perform corresponding processing, specifically, the following steps 203-205 can be executed.
步骤203:ORM执行引擎中的第二ORM框架获取该操作请求。Step 203: The second ORM framework in the ORM execution engine obtains the operation request.
第二ORM框架是集成在ORM执行引擎的ORM框架,用于在获取到该操作请求后,对该操作请求进行处理,以实现对数据库的访问操作。The second ORM framework is an ORM framework integrated in the ORM execution engine, and is used to process the operation request after obtaining the operation request, so as to implement the access operation to the database.
这种情况下,ORM执行引擎中的第二ORM框架获取到该操作请求后,可以知道应用系统想要访问数据库。In this case, after the second ORM framework in the ORM execution engine obtains the operation request, it can know that the application system wants to access the database.
一种可能的实现方式,应用系统中的第一ORM框架可以与ORM执行引擎中的第二ORM框架直接进行通信。这种情况下,第一ORM框架发送至ORM执行引擎的操作请求可以直接被第二ORM框架接收到,也即,第二ORM框架可以直接接收到第一ORM框架发送的操作请求。In a possible implementation, the first ORM framework in the application system can communicate directly with the second ORM framework in the ORM execution engine. In this case, the operation request sent by the first ORM framework to the ORM execution engine can be directly received by the second ORM framework, that is, the second ORM framework can directly receive the operation request sent by the first ORM framework.
另一种可能的实现方式,ORM执行引擎包括中间件模块,中间件模块可以与应用系统进行通信连接,也即,中间件模块可以与第一ORM框架直接进行通信。这种情况下,第一ORM框架发送至ORM执行引擎的操作请求可以直接被中间件模块接收到。中间件模块可以先接收第一ORM框架发送的操作请求,在满足数据库访问条件的情况下,再向第二ORM框架发送该操作请求。In another possible implementation, the ORM execution engine includes a middleware module, and the middleware module can communicate with the application system, that is, the middleware module can communicate directly with the first ORM framework. In this case, the operation request sent by the first ORM framework to the ORM execution engine can be directly received by the middleware module. The middleware module can first receive the operation request sent by the first ORM framework, and then send the operation request to the second ORM framework when the database access condition is met.
数据库访问条件可以预先进行设置,数据库访问条件可以由技术人员根据业务需求进行设置。可选地,数据库访问条件可以包括但不限于以下多项中的至少一项:The database access conditions can be set in advance, and the database access conditions can be set by the technical staff according to the business needs. Optionally, the database access conditions can include but are not limited to at least one of the following:
第一,数据库的访问次数小于第一次数阈值。First, the number of database accesses is less than the first count threshold.
第一次数阈值为数据库在一定周期(比如一天、一个月等)内可以被访问的最多次数,第一次数阈值可以预先进行设置,且第一次数阈值可以由技术人员根据业务需求进行设置。The first number threshold is the maximum number of times a database can be accessed within a certain period (such as one day, one month, etc.). The first number threshold can be set in advance, and the first number threshold can be set by a technician according to business needs.
这种情况下,数据库的访问次数小于第一次数阈值,说明数据库的访问次数还未达到数据库可以被访问的最多次数,那么就可以继续访问数据库,则中间件模块可以将该操作请求发送给第二ORM框架。数据库的访问次数大于或等于第一次数阈值,说明数据库的访问次数已超过数据库可以被访问的最多次数,那么就不能继续访问数据库了,则中间件模块不能将该操作请求发送给第二ORM框架。In this case, if the number of database accesses is less than the first number threshold, it means that the number of database accesses has not reached the maximum number of times the database can be accessed, so the database can continue to be accessed, and the middleware module can send the operation request to the second ORM framework. If the number of database accesses is greater than or equal to the first number threshold, it means that the number of database accesses has exceeded the maximum number of times the database can be accessed, so the database cannot continue to be accessed, and the middleware module cannot send the operation request to the second ORM framework.
例如,第一次数阈值为10,当前数据库的访问次数为5,当前数据库的访问次数(5)小于第一次数阈值(10),则可以确定此次访问满足数据库访问条件,则中间件模块可以向第二ORM框架发送该操作请求。For example, if the first number threshold is 10, the current database access number is 5, and the current database access number (5) is less than the first number threshold (10), it can be determined that this access meets the database access condition, and the middleware module can send the operation request to the second ORM framework.
第二,该操作请求所要访问的对象的访问次数小于第二次数阈值。Second, the access count of the object to be accessed by the operation request is less than a second count threshold.
第二次数阈值为该操作请求所要访问的对象在一定周期(比如一天、一个月等)内可以被访问的最多次数。第二次数阈值可以预先进行设置,且第二次数阈值可以由技术人员根据业务需要进行设置。The second number threshold is the maximum number of times the object to be accessed by the operation request can be accessed within a certain period (such as one day, one month, etc.) The second number threshold can be set in advance, and the second number threshold can be set by the technical staff according to business needs.
这种情况下,该操作请求所要访问的对象的访问次数小于第二次数阈值,说明该操作请求所要访问的对象的访问次数还未达到该操作请求所要访问的对象可以被访问的最多次数,那么就可以继续访问数据库,则中间件模块可以将该操作请求发送给第二ORM框架。该操作请求所要访问的对象的访问次数大于或等于第二次数阈值,说明该操作请求所要访问的对象的访问次数已超过该操作请求所要访问的对象可以被访问的最多次数,那么就不能继续访问数据库,则中间件模块不能将该操作请求发送给第二ORM框架。In this case, the number of accesses to the object to be accessed by the operation request is less than the second number threshold, indicating that the number of accesses to the object to be accessed by the operation request has not reached the maximum number of times the object to be accessed by the operation request can be accessed, so the database can continue to be accessed, and the middleware module can send the operation request to the second ORM framework. The number of accesses to the object to be accessed by the operation request is greater than or equal to the second number threshold, indicating that the number of accesses to the object to be accessed by the operation request has exceeded the maximum number of times the object to be accessed by the operation request can be accessed, so the database cannot be accessed, and the middleware module cannot send the operation request to the second ORM framework.
例如,第二次数阈值为5,当前该操作请求所要访问的对象的访问次数为3,当前该操作请求所要访问的对象的访问次数(3)小于第二次数阈值(5),那么可以确定该操作请求满足数据库访问条件,则中间件模块可以向第二ORM框架发送该操作请求。For example, the second count threshold is 5, the number of accesses to the object to be accessed by the current operation request is 3, and the number of accesses to the object to be accessed by the current operation request (3) is less than the second count threshold (5), then it can be determined that the operation request meets the database access condition, and the middleware module can send the operation request to the second ORM framework.
第三,应用系统具有该操作请求所要访问的对象的访问权限。Third, the application system has access rights to the object that the operation request wants to access.
该操作请求所要访问的对象的访问权限用于限制部分应用系统对该操作请求所要访问的对象的访问,也即,具有该操作请求所要访问的对象的访问权限的应用系统被允许访问该对象,而不具有该操作请求所要访问的对象的访问权限的应用系统不被允许访问该对象。该操作请求所要访问的对象的访问权限可以由技术人员根据业务需求进行设置。The access rights of the object to be accessed by the operation request are used to restrict the access of some application systems to the object to be accessed by the operation request, that is, the application system with the access rights of the object to be accessed by the operation request is allowed to access the object, while the application system without the access rights of the object to be accessed by the operation request is not allowed to access the object. The access rights of the object to be accessed by the operation request can be set by the technician according to business needs.
在中间件模块接收到该操作请求后,可以先检验发送该操作请求的应用系统是否具有该操作请求所要访问的对象的访问权限。若应用系统具有该操作请求所要访问的对象的访问权限,说明应用系统被允许访问该操作请求所要访问的对象,那么就可以继续访问数据库,则中间件模块可以将该操作请求发 送给第二ORM框架。若应用系统不具有该操作请求所要访问的对象的访问权限,说明应用系统不被允许访问该操作请求所要访问的对象,那么就不能继续访问数据库,则中间件模块不能将该操作请求发送给第二ORM框架。After the middleware module receives the operation request, it can first check whether the application system that sent the operation request has the access rights to the object that the operation request wants to access. If the application system has the access rights to the object that the operation request wants to access, it means that the application system is allowed to access the object that the operation request wants to access, and then it can continue to access the database. The middleware module can then send the operation request to If the application system does not have the access rights to the object to be accessed by the operation request, it means that the application system is not allowed to access the object to be accessed by the operation request, and then the database cannot be accessed, and the middleware module cannot send the operation request to the second ORM framework.
第四,应用系统具有数据库的访问权限。Fourth, the application system has access rights to the database.
数据库的访问权限用于限制部分应用系统对数据库的访问。也即,具有数据库的访问权限的应用系统被允许访问数据库,而不具有数据库的访问权限的应用系统不被允许访问数据库。数据库的访问权限可以由技术人员根据业务需求进行设置。The access rights of a database are used to restrict the access of some application systems to the database. That is, application systems with access rights to the database are allowed to access the database, while application systems without access rights to the database are not allowed to access the database. The access rights of the database can be set by the technical staff according to the business needs.
在中间件模块接收到该操作请求后,可以先检验发送该操作请求的应用系统是否具有数据库的访问权限。若应用系统具有数据库的访问权限,说明应用系统被允许访问数据库,那么就可以继续访问数据库,则中间件模块可以将该操作请求发送给第二ORM框架。若应用系统不具有数据库的访问权限,说明应用系统不被允许访问数据库,那么就不能继续访问数据库,则中间件模块不能将该操作请求发送给第二ORM框架。After the middleware module receives the operation request, it can first check whether the application system that sends the operation request has the access rights to the database. If the application system has the access rights to the database, it means that the application system is allowed to access the database, and then it can continue to access the database, and the middleware module can send the operation request to the second ORM framework. If the application system does not have the access rights to the database, it means that the application system is not allowed to access the database, and then it cannot continue to access the database, and the middleware module cannot send the operation request to the second ORM framework.
第五,该操作请求中的操作类型是数据库允许对该操作请求所要访问的对象进行的操作类型。Fifth, the operation type in the operation request is the operation type that the database allows to be performed on the object to be accessed by the operation request.
技术人员可以根据业务需求设置数据库中的对象可以被操作的操作类型,以此来限制应用系统对数据库中的对象的操作。Technical personnel can set the types of operations that can be performed on objects in the database according to business needs, thereby limiting the operations of the application system on objects in the database.
中间件模块接收到该操作请求后,可以先检查该操作请求中的操作类型是否为数据库允许对该操作请求所要访问的对象进行的操作类型。若该操作请求中的操作类型是数据库允许对该操作请求所要访问的对象进行的操作类型,说明该操作请求想要对该对象进行的操作类型是被允许的操作类型,那么就可以继续访问数据库,则中间件模块可以将该操作请求发送给第二ORM框架。若该操作请求中的操作类型不是数据库允许对该操作请求所要访问的对象进行的操作类型,说明该操作请求想要对该对象进行的操作类型是不被允许的操作类型,那么就不能继续访问数据库,则中间件模块不能将该操作请求发送给第二ORM框架。After receiving the operation request, the middleware module can first check whether the operation type in the operation request is the operation type that the database allows to perform on the object to be accessed by the operation request. If the operation type in the operation request is the operation type that the database allows to perform on the object to be accessed by the operation request, it means that the operation type that the operation request wants to perform on the object is an allowed operation type, then the database can continue to be accessed, and the middleware module can send the operation request to the second ORM framework. If the operation type in the operation request is not the operation type that the database allows to perform on the object to be accessed by the operation request, it means that the operation type that the operation request wants to perform on the object is an unallowed operation type, then the database cannot be accessed, and the middleware module cannot send the operation request to the second ORM framework.
当然,在本申请实施例中,在满足上述五项条件中的任意一项条件时中间件模块可以将该操作请求发送给第二ORM框架;或者,在同时满足上述五项条件中的多项条件时中间件模块才将该操作请求发送给第二ORM框架。另外,除上述五项条件之外,技术人员还可以设置其他的条件,本申请实施例对此不作限定。Of course, in the embodiment of the present application, the middleware module can send the operation request to the second ORM framework when any one of the above five conditions is met; or, the middleware module sends the operation request to the second ORM framework only when multiple of the above five conditions are met at the same time. In addition, in addition to the above five conditions, the technician can also set other conditions, which are not limited in the embodiment of the present application.
本申请实施例中,在中间件模块中提前设置数据库访问条件,在满足数据库访问条件的情况下,中间件模块才将该操作请求发送给第二ORM框架,这种情况下,中间件模块能够很好的统筹管理整个数据库的访问,同时满足所有业务化需求,支持更高级的、特殊的、自定义的管控配置。In an embodiment of the present application, database access conditions are set in advance in the middleware module. Only when the database access conditions are met will the middleware module send the operation request to the second ORM framework. In this case, the middleware module can coordinate and manage the access to the entire database well, while meeting all business needs and supporting more advanced, special, and customized management and control configurations.
步骤204:第二ORM框架对该操作请求进行解析,得到SQL语句。Step 204: The second ORM framework parses the operation request to obtain an SQL statement.
SQL语句用于对数据库中的数据进行操作。比如,该SQL语句可以是DML(Data Manipulation Language,数据操纵语言)语句,具体来讲,该SQL语句可以用于对数据库中的数据进行新增、删除、更新、查找。SQL statements are used to operate on data in a database. For example, the SQL statement can be a DML (Data Manipulation Language) statement. Specifically, the SQL statement can be used to add, delete, update, and search for data in a database.
由于该操作请求是第一ORM框架根据面向对象的业务语句生成的,所以该操作请求中包括的是基于面向对象的操作信息。这种情况下,ORM执行引擎中的第二ORM框架可以将基于面向对象的操作请求解析成SQL语句,也即是将基于面向对象的操作请求解析成数据库可以识别的SQL语句,以实现访问数据库中的数据。Since the operation request is generated by the first ORM framework according to the object-oriented business statement, the operation request includes object-oriented operation information. In this case, the second ORM framework in the ORM execution engine can parse the object-oriented operation request into an SQL statement, that is, parse the object-oriented operation request into an SQL statement that can be recognized by the database to access the data in the database.
这种情况下,第二ORM框架可以得到数据库能够识别的SQL语句,之后再与数据库进行交互,如此技术人员无需编写复杂的SQL语句,这为技术人员提供了方便,从而提高开发效率。并且,本申请实施例中无需应用系统与数据库进行直接通信,也就不需要在应用系统中配置数据库的账号密码,从而保证了数据库的安全性。In this case, the second ORM framework can obtain SQL statements that the database can recognize, and then interact with the database, so that the technician does not need to write complex SQL statements, which provides convenience for the technician and improves development efficiency. In addition, in the embodiment of the present application, there is no need for the application system to communicate directly with the database, and there is no need to configure the database account password in the application system, thereby ensuring the security of the database.
第二ORM框架对该操作请求进行解析,得到SQL语句的操作与相关技术中某个设备对某个操作请求进行解析得到SQL语句的操作类似,本申请实施例对此不进行详细阐述。The second ORM framework parses the operation request to obtain an SQL statement, which is similar to the operation of a device in the related art parsing an operation request to obtain an SQL statement, and the embodiment of the present application will not elaborate on this.
步骤205:第二ORM框架执行该SQL语句,以访问数据库中的数据,得到该SQL语句的执行结果。Step 205: The second ORM framework executes the SQL statement to access the data in the database and obtain the execution result of the SQL statement.
在本申请实施例中,第二ORM框架中提供了与数据库进行通信的接口,则第二ORM框架可以通 过该接口访问数据库。In the embodiment of the present application, the second ORM framework provides an interface for communicating with the database, so the second ORM framework can communicate with the database through Access the database through this interface.
这种情况下,第二ORM框架执行该SQL语句,也即是通过第二ORM框架中提供的接口与数据库进行交互,也即是对数据库中该操作请求所要访问的对象进行操作,从而得到执行结果,该执行结果即是该操作请求的请求结果。In this case, the second ORM framework executes the SQL statement, that is, interacts with the database through the interface provided in the second ORM framework, that is, operates on the object to be accessed by the operation request in the database, thereby obtaining the execution result, which is the request result of the operation request.
进一步地,第二ORM框架得到该SQL语句的执行结果后,可以将该SQL语句的执行结果作为该操作请求的请求结果返回给应用系统,以响应应用系统发送的该操作请求。Furthermore, after obtaining the execution result of the SQL statement, the second ORM framework may return the execution result of the SQL statement as the request result of the operation request to the application system to respond to the operation request sent by the application system.
例如,图4为应用系统与ORM执行引擎的交互示意图。参见图4,图4中包括应用系统401、ORM执行引擎402。应用系统401向ORM执行引擎402发送该操作请求,ORM执行引擎402中的第二ORM框架在执行解析该操作请求得到的SQL语句,得到执行结果后,将这个SQL语句的执行结果作为该操作请求的请求结果发送给应用系统401。For example, Figure 4 is a schematic diagram of the interaction between the application system and the ORM execution engine. Referring to Figure 4, Figure 4 includes an application system 401 and an ORM execution engine 402. The application system 401 sends the operation request to the ORM execution engine 402, and the second ORM framework in the ORM execution engine 402 executes the SQL statement obtained by parsing the operation request, and after obtaining the execution result, sends the execution result of the SQL statement as the request result of the operation request to the application system 401.
可选地,ORM执行引擎还可以包括缓存模块。这种情况下,第二ORM框架在获取到该操作请求后,在该操作请求中的操作类型为除查询类型之外的其他类型的情况下,可以直接执行上述步骤204-步骤205来获得该操作请求的请求结果。而在该操作请求中的操作类型为查询类型的情况下,可以先不执行上述步骤204-步骤205,而是可以先查询缓存模块中是否具有该操作请求所要查询的数据。Optionally, the ORM execution engine may further include a cache module. In this case, after the second ORM framework obtains the operation request, if the operation type in the operation request is other than the query type, the above steps 204-205 may be directly executed to obtain the request result of the operation request. If the operation type in the operation request is a query type, the above steps 204-205 may not be executed first, but the cache module may be queried first to see if there is the data to be queried by the operation request.
缓存模块与ORM执行引擎进行通信连接,缓存模块存储了多个键值对,多个键值对中的每个键值对存储的是操作类型为查询类型的操作请求的请求结果。多个键值对中每个键值对中的key值为对操作类型为查询类型的操作请求进行哈希运算得到的哈希值,多个键值对中每个键值对中的value值为操作类型为查询类型的操作请求的请求结果。也即,对于缓存模块中存储的任意一个键值对,这个键值对中的key值为操作类型为查询类型的一个操作请求的哈希值,这个键值对中的value值为这个操作请求的请求结果,也即为这个操作请求从数据库查询到的数据。示例地,该缓存模块可以为一个key-value存储系统,例如该缓存模块可以为redis(REmoteDIctionary Server,数据结构服务器)缓存系统。The cache module is in communication connection with the ORM execution engine, and the cache module stores multiple key-value pairs, and each of the multiple key-value pairs stores the request result of an operation request whose operation type is a query type. The key value in each of the multiple key-value pairs is a hash value obtained by hashing the operation request whose operation type is a query type, and the value value in each of the multiple key-value pairs is the request result of the operation request whose operation type is a query type. That is, for any key-value pair stored in the cache module, the key value in this key-value pair is a hash value of an operation request whose operation type is a query type, and the value value in this key-value pair is the request result of this operation request, that is, the data queried from the database by this operation request. By way of example, the cache module can be a key-value storage system, for example, the cache module can be a redis (REmoteDIctionary Server, data structure server) cache system.
具体地,第二ORM框架在获取到该操作请求后,在该操作请求中的操作类型为查询类型的情况下,第二ORM框架对该操作请求进行哈希运算,得到哈希值;从缓存模块中查询与该哈希值相同的key值;若从缓存模块中查询到与该哈希值相同的key值,则将缓存模块中与该哈希值相同的key值所在的键值对中的value值确定为该操作请求的请求结果。若从缓存模块中未查询到与该哈希值相同的key值,则执行上述步骤204-步骤205,也即,对该操作请求进行解析,得到该SQL语句,执行该SQL语句,以访问数据库中的数据,得到该SQL语句的执行结果作为该操作请求的请求结果,这种情况下,还可以生成目标键值对,将目标键值对存储至缓存模块。Specifically, after the second ORM framework obtains the operation request, if the operation type in the operation request is a query type, the second ORM framework performs a hash operation on the operation request to obtain a hash value; queries the cache module for a key value identical to the hash value; if a key value identical to the hash value is queried from the cache module, the value in the key-value pair of the key value identical to the hash value in the cache module is determined as the request result of the operation request. If a key value identical to the hash value is not queried from the cache module, the above steps 204-205 are executed, that is, the operation request is parsed to obtain the SQL statement, and the SQL statement is executed to access the data in the database, and the execution result of the SQL statement is obtained as the request result of the operation request. In this case, a target key-value pair can also be generated and stored in the cache module.
目标键值对中的key值为该操作请求的哈希值。目标键值对中的value值为该SQL语句的执行结果,也即为该操作请求的请求结果,也就是在执行该SQL语句后从数据库中查询到的数据。The key value in the target key-value pair is the hash value of the operation request. The value value in the target key-value pair is the execution result of the SQL statement, that is, the request result of the operation request, that is, the data queried from the database after executing the SQL statement.
若从缓存模块中查询到与该哈希值相同的key值,说明缓存模块中存在该操作请求的请求结果,也即是存在应用系统所要查询的数据。则可以将缓存模块中与该哈希值相同的key值所在的键值对中的value值确定为该操作请求的请求结果,进一步地可以将该操作请求的请求结果返回给应用系统。If the key value that is the same as the hash value is found in the cache module, it means that the cache module contains the request result of the operation request, that is, the data that the application system wants to query. Then the value in the key-value pair containing the key value that is the same as the hash value in the cache module can be determined as the request result of the operation request, and the request result of the operation request can be further returned to the application system.
若从缓存模块中未查询到与该哈希值相同的key值,说明缓存模块中不存在该操作请求的请求结果,也即是不存在应用系统所要查询的数据。则第二ORM框架可以对该操作请求进行解析,得到该SQL语句,执行该SQL语句,以访问数据库中的数据,得到该SQL语句的执行结果作为该操作请求的请求结果,之后再生成目标键值对,将目标键值对存储至缓存模块,此时缓存模块中就存在了该操作请求的请求结果。进一步地,第二ORM框架可以将该操作请求的请求结果返回给应用系统。If the key value identical to the hash value is not found in the cache module, it means that the request result of the operation request does not exist in the cache module, that is, the data to be queried by the application system does not exist. The second ORM framework can parse the operation request, obtain the SQL statement, execute the SQL statement to access the data in the database, and obtain the execution result of the SQL statement as the request result of the operation request, and then generate the target key-value pair, and store the target key-value pair in the cache module. At this time, the request result of the operation request exists in the cache module. Furthermore, the second ORM framework can return the request result of the operation request to the application system.
如此,在应用系统需要频繁、大量查询数据的情况下,通过缓存模块可以减轻数据库的访问压力。且对于应用系统的用户而言,在访问数据库时不会感知到缓存模块的存在。另外,由于ORM执行引擎访问缓存模块的速度比访问数据库的速度快很多,所以在缓存模块中存在所要查询的数据的情况下,直接将缓存模块中存储的数据返回给应用系统,可以提高数据查询效率,对于应用系统而言即相当于提高了数据库访问效率。In this way, when the application system needs to frequently and massively query data, the access pressure of the database can be reduced through the cache module. And for the users of the application system, they will not perceive the existence of the cache module when accessing the database. In addition, since the ORM execution engine accesses the cache module much faster than the database, when the data to be queried exists in the cache module, the data stored in the cache module is directly returned to the application system, which can improve the data query efficiency, which is equivalent to improving the database access efficiency for the application system.
例如,图5为操作请求中的操作类型为查询类型时访问数据库的流程图。参见图5,包括步骤501-步骤506。For example, Fig. 5 is a flowchart of accessing a database when the operation type in the operation request is a query type. Referring to Fig. 5 , it includes steps 501 to 506 .
步骤501:第二ORM框架对该操作请求进行哈希运算,得到哈希值。 Step 501: The second ORM framework performs a hash operation on the operation request to obtain a hash value.
步骤502:第二ORM框架从缓存模块中查询与该哈希值相同的key值。Step 502: The second ORM framework queries the cache module for a key value that is the same as the hash value.
步骤503:第二ORM框架若从缓存模块中查询到与该哈希值相同的key值,则将该key值所在的键值对中的value值确定为该操作请求的请求结果返回给应用系统。Step 503: If the second ORM framework finds a key value identical to the hash value from the cache module, the value in the key-value pair where the key value is located is determined as the request result of the operation request and returned to the application system.
步骤504:第二ORM框架若从缓存模块中未查询到与该哈希值相同的key值,则从数据库中读取该操作请求所要查询的数据。Step 504: If the second ORM framework does not find the key value identical to the hash value from the cache module, it reads the data to be queried by the operation request from the database.
具体地,第二ORM框架对该操作请求进行解析,得到该SQL语句,执行该SQL语句,以从数据库中读取该操作请求所要查询的数据,得到该SQL语句的执行结果。之后,第二ORM框架继续执行步骤505。Specifically, the second ORM framework parses the operation request to obtain the SQL statement, executes the SQL statement to read the data to be queried by the operation request from the database, and obtains the execution result of the SQL statement. Afterwards, the second ORM framework continues to execute step 505.
步骤505:第二ORM框架将该SQL语句的执行结果确定为该操作请求的请求结果返回给应用系统,并且,第二ORM框架执行步骤506。Step 505 : the second ORM framework determines the execution result of the SQL statement as the request result of the operation request and returns it to the application system, and the second ORM framework executes step 506 .
步骤506:第二ORM框架生成目标键值对,将目标键值对存储至缓存模块。Step 506: The second ORM framework generates a target key-value pair and stores the target key-value pair in a cache module.
本申请实施例中在一些情况下可以删除缓存模块中的键值对,具体在下面说明:In some cases in the embodiment of the present application, the key-value pairs in the cache module can be deleted, which are specifically described below:
可选地,在缓存模块中存储一个键值对时可以将这个键值对与这个键值对中的value值所属的对象的对象标识进行关联存储。这种情况下,在缓存模块中与一个对象的对象标识关联存储的键值对中的value值是这个对象的数据。Optionally, when storing a key-value pair in the cache module, the key-value pair may be stored in association with the object identifier of the object to which the value in the key-value pair belongs. In this case, the value in the key-value pair stored in association with the object identifier of an object in the cache module is the data of the object.
例如,缓存模块中的键值对与对象标识的关联关系如表1所示,如下表1中的这三个键值对中每个键值对中的value值所属的对象的对象标识均为Table1,所以这三个键值对均与Table1进行关联存储。For example, the association relationship between the key-value pairs and object identifiers in the cache module is shown in Table 1. The object identifier of the object to which the value in each of the three key-value pairs in Table 1 belongs is Table1, so the three key-value pairs are all associated with Table1 for storage.
表1
Table 1
本申请实施例仅以上表1为例来对缓存模块中的键值对与对象标识的关联关系进行举例说明,上表1并不对本申请实施例构成限定。The embodiment of the present application only uses Table 1 above as an example to illustrate the association between the key-value pairs and the object identifiers in the cache module. Table 1 above does not limit the embodiment of the present application.
第一种可能的实现方式,第二ORM框架在获取到该操作请求后,在该操作请求中的操作类型为更新类型的情况下,可以先删除缓存模块中与该操作请求中的对象标识关联存储的所有键值对,再通过上述步骤204-步骤205获得该操作请求的请求结果。The first possible implementation method is that after the second ORM framework obtains the operation request, if the operation type in the operation request is an update type, it can first delete all key-value pairs stored in the cache module that are associated with the object identifier in the operation request, and then obtain the request result of the operation request through the above steps 204-205.
由于该操作请求中的操作类型为更新类型,所以此次数据库访问的目的是要对该操作请求中的对象标识所标识的对象进行更新,如此数据库中该操作请求中的对象标识所标识的对象的数据会发生变化,那么缓存模块中与该操作请求中的对象标识关联存储的键值对中的value值将不是该对象标识所标识的对象的最新数据,因而要对缓存模块中与该操作请求中的对象标识关联存储的所有键值对进行删除。Since the operation type in the operation request is an update type, the purpose of this database access is to update the object identified by the object identifier in the operation request. If the data of the object identified by the object identifier in the operation request in the database changes, the value in the key-value pair associated with the object identifier in the operation request in the cache module will not be the latest data of the object identified by the object identifier. Therefore, all key-value pairs associated with the object identifier in the operation request in the cache module must be deleted.
第二种可能的实现方式,第二ORM框架在获取到该操作请求后,在该操作请求中的操作类型为更新类型的情况下,先通过上述步骤204-步骤205获得该操作请求的请求结果,再删除缓存模块中与该操作请求中的对象标识关联存储的所有键值对。A second possible implementation method is that after the second ORM framework obtains the operation request, if the operation type in the operation request is an update type, it first obtains the request result of the operation request through the above steps 204-205, and then deletes all key-value pairs stored in the cache module in association with the object identifier in the operation request.
第三种可能的实现方式,例如,图6为操作请求中的操作类型为更新类型时访问数据库的流程图。参见图6,包括步骤601-步骤603。A third possible implementation manner, for example, FIG6 is a flowchart of accessing a database when the operation type in the operation request is an update type. Referring to FIG6 , it includes steps 601 to 603 .
步骤601:第二ORM框架在获取到该操作请求后,在该操作请求中的操作类型为更新类型的情况下,删除缓存模块中与该操作请求中的对象标识关联存储的所有键值对。Step 601: after obtaining the operation request, if the operation type in the operation request is an update type, the second ORM framework deletes all key-value pairs stored in the cache module in association with the object identifier in the operation request.
步骤602:第二ORM框架通过上述步骤204-步骤205获得该操作请求的请求结果。Step 602: The second ORM framework obtains the request result of the operation request through the above steps 204 to 205.
也即,第二ORM框架对该操作请求进行解析,得到该SQL语句,执行该SQL语句,以更新数据库中的该操作请求所要访问的对象,得到该SQL语句的执行结果。第二ORM框架可以将该SQL语句的执行结果确定为该操作请求的请求结果返回给应用系统。That is, the second ORM framework parses the operation request to obtain the SQL statement, executes the SQL statement to update the object to be accessed by the operation request in the database, and obtains the execution result of the SQL statement. The second ORM framework can determine the execution result of the SQL statement as the request result of the operation request and return it to the application system.
步骤603:第二ORM框架再次删除缓存模块中与该操作请求中的对象标识关联存储的所有键值对。 Step 603: The second ORM framework deletes again all key-value pairs stored in the cache module in association with the object identifier in the operation request.
考虑一种情况,若第二ORM框架第一次删除缓存模块中与该操作请求中的对象标识关联存储的所有键值对之后,存在另一个应用系统查询该操作请求中的对象标识所标识的对象的数据,另一个应用系统在读取到需要查询的数据后,会重新在缓存模块中存储一个键值对,这个键值对与该操作请求中的对象标识关联存储。但是此时第二ORM框架还未更新数据库中的该操作请求所要访问的对象。这种情况下,在更新数据库中的该操作请求所要访问的对象后,数据库中存储的该对象的数据与缓存模块中缓存的这个键值对中的value值不同,那么再次删除缓存模块中与该操作请求中的对象标识关联存储的所有键值对,可以保证数据更新后缓存模块中没有存储与该操作请求中的对象标识关联存储的键值对,从而保证数据库中的数据与缓存模块中缓存的数据的一致性。Consider a situation where, after the second ORM framework deletes all key-value pairs stored in the cache module in association with the object identifier in the operation request for the first time, there is another application system that queries the data of the object identified by the object identifier in the operation request. After reading the data to be queried, the other application system will re-store a key-value pair in the cache module, and this key-value pair is stored in association with the object identifier in the operation request. However, at this time, the second ORM framework has not yet updated the object to be accessed by the operation request in the database. In this case, after updating the object to be accessed by the operation request in the database, the data of the object stored in the database is different from the value in the key-value pair cached in the cache module. Then, by deleting all key-value pairs stored in association with the object identifier in the operation request in the cache module again, it can be ensured that after the data is updated, no key-value pairs stored in association with the object identifier in the operation request are stored in the cache module, thereby ensuring the consistency of the data in the database and the data cached in the cache module.
值得注意的一点是,本申请实施例提供的数据库访问方法无需将数据库的账号密码配置在应用系统中,减轻了应用系统的配置复杂度,同时保护了隐私数据,减少了数据的安全隐患。另外,由于应用系统无需直接连接数据库,所以不再消耗数据库的TCP连接数,这对于数据库来说,整体的TCP连接数是可控的,可管理的。It is worth noting that the database access method provided by the embodiment of the present application does not need to configure the database account password in the application system, which reduces the configuration complexity of the application system, protects privacy data, and reduces data security risks. In addition, since the application system does not need to directly connect to the database, it no longer consumes the number of TCP connections of the database. For the database, the overall number of TCP connections is controllable and manageable.
值得注意的另一点是,当有更换数据库的需求时,可以直接在ORM执行引擎中对数据库进行变更,对于应用系统来说,应用系统不会感知到数据库的变更,所以不会对应用系统造成影响。Another point worth noting is that when there is a need to change the database, the database can be changed directly in the ORM execution engine. For the application system, the application system will not perceive the change of the database, so it will not affect the application system.
在本申请实施例中,ORM执行引擎包括第二ORM框架,ORM执行引擎与应用系统进行通信连接,并且ORM执行引擎与数据库进行通信连接,应用系统包括第一ORM框架。ORM执行引擎中的第二ORM框架获取第一ORM框架发送的操作请求,该操作请求为第一ORM框架根据业务语句生成,也即是应用系统在需要访问数据库时向ORM执行引擎发送操作请求。之后第二ORM框架对该操作请求进行解析得到SQL语句,该SQL语句是数据库可以识别的语句。第二ORM框架执行该SQL语句,以访问数据库中的数据。如此,应用系统无需直接连接数据库,因而应用系统中无需配置数据库的密码,而只需ORM执行引擎与数据库进行交互,以实现对数据库的访问,从而保证了数据库的安全性。In an embodiment of the present application, the ORM execution engine includes a second ORM framework, the ORM execution engine is communicatively connected to the application system, and the ORM execution engine is communicatively connected to the database, and the application system includes a first ORM framework. The second ORM framework in the ORM execution engine obtains an operation request sent by the first ORM framework, and the operation request is generated by the first ORM framework according to the business statement, that is, the application system sends an operation request to the ORM execution engine when it needs to access the database. Afterwards, the second ORM framework parses the operation request to obtain an SQL statement, which is a statement that can be recognized by the database. The second ORM framework executes the SQL statement to access the data in the database. In this way, the application system does not need to directly connect to the database, so there is no need to configure the database password in the application system, but only the ORM execution engine needs to interact with the database to access the database, thereby ensuring the security of the database.
上面对应用系统向ORM执行引擎发送一个操作请求时,ORM执行引擎对这个操作请求的处理过程进行了解释说明。下面对应用系统向ORM执行引擎发送多个操作请求时,ORM执行引擎对这多个操作请求的处理过程进行解释说明。The above explains how the ORM execution engine processes an operation request when the application system sends it. The following explains how the ORM execution engine processes multiple operation requests when the application system sends them.
先对本申请实施例涉及的事务的有关概念进行说明。First, the relevant concepts of the affairs involved in the embodiments of the present application are explained.
事务是构成单一逻辑工作单元的操作集合。事务可以包含一个或多个操作,这些操作构成一个逻辑上的整体。构成逻辑整体的这些操作,要么全部执行成功,要么全部不执行。也即,构成事务的所有操作,要么全都对数据库产生影响,要么全都不产生影响,从而不管事务是否执行成功,数据库总能保持一致性状态。A transaction is a collection of operations that form a single logical unit of work. A transaction can contain one or more operations that form a logical whole. These operations that form the logical whole are either all executed successfully or not executed at all. In other words, all the operations that constitute a transaction either have an impact on the database or have no impact at all, so that the database can always maintain a consistent state regardless of whether the transaction is executed successfully.
事务具有ACID特征,分别为:原子性(Atomicity):事务中的所有操作作为一个整体像原子一样不可分割,要么全部成功,要么全部失败。一致性(Consistency):事务的执行结果必须使数据库从一个一致性状态到另一个一致性状态。隔离性(Isolation):并发执行的事务不会相互影响,其对数据库的影响和它们串行执行时一样。持久性(Durability):事务一旦提交,其对数据库的更新就是持久的。Transactions have ACID characteristics, which are: Atomicity: All operations in a transaction are inseparable as a whole, either all succeed or all fail. Consistency: The execution result of a transaction must make the database go from one consistent state to another. Isolation: Concurrently executed transactions will not affect each other, and their impact on the database is the same as when they are executed serially. Durability: Once a transaction is committed, its updates to the database are persistent.
在一些实施例中,事务使用会有两种情况,通过启动事务语句来决定是否自动提交事务。In some embodiments, there are two situations in which transactions are used, and whether to automatically commit the transaction is determined by starting a transaction statement.
若ORM执行引擎未接收到启动事务语句,则自动提交事务,即执行非持续性事务,具体是ORM执行引擎每接收到一个操作请求,就会将对这个操作请求解析得到的一个SQL语句在执行后提交,此时实际上是将每次得到的一个SQL语句作为一个事务进行执行。也即,在上述步骤205中第二ORM框架每在得到一个SQL语句的执行结果后就会指示数据库提交这个SQL语句的执行结果。这种情况下,是采用数据库访问模式中的自动提交模式来实现对数据库中的数据的访问。If the ORM execution engine does not receive the start transaction statement, the transaction is automatically submitted, that is, a non-persistent transaction is executed. Specifically, each time the ORM execution engine receives an operation request, it will submit a SQL statement obtained by parsing the operation request after execution. At this time, each SQL statement obtained is actually executed as a transaction. That is, in the above step 205, the second ORM framework will instruct the database to submit the execution result of the SQL statement after obtaining the execution result of the SQL statement. In this case, the automatic submission mode in the database access mode is used to implement access to data in the database.
若ORM执行引擎接收到启动事务语句,则不自动提交事务,即执行持续性事务,具体是ORM执行引擎在接收到多个操作请求时,将对这多个操作请求解析得到的多个SQL语句整体作为一个事务进行执行,对这多个SQL语句的执行结果同时提交或回滚。这种情况下,是采用数据库访问模式中的手动提交模式来实现对数据库中的数据的访问。下面对这种情况进行详细地解释说明。If the ORM execution engine receives a start transaction statement, it will not automatically commit the transaction, that is, execute a persistent transaction. Specifically, when the ORM execution engine receives multiple operation requests, it will execute the multiple SQL statements obtained by parsing these multiple operation requests as a transaction, and commit or roll back the execution results of these multiple SQL statements at the same time. In this case, the manual commit mode in the database access mode is used to access the data in the database. This situation is explained in detail below.
图7是本申请实施例提供的一种数据库访问方法的流程图。参见图7,该方法包括以下步骤。Fig. 7 is a flow chart of a database access method provided in an embodiment of the present application. Referring to Fig. 7, the method includes the following steps.
步骤701:第一ORM框架向ORM执行引擎发送启动事务语句。Step 701: The first ORM framework sends a start transaction statement to the ORM execution engine.
启动事务语句用于指示ORM执行引擎启动事务,以将第一ORM框架后续发送的多个操作请求解 析得到的多个SQL语句作为一个事务进行执行,也即对多个SQL语句同时进行提交或回滚。The start transaction statement is used to instruct the ORM execution engine to start a transaction to resolve multiple operation requests subsequently sent by the first ORM framework. The multiple SQL statements obtained by the analysis are executed as a transaction, that is, multiple SQL statements are committed or rolled back at the same time.
应用系统确定需要在一个事务中执行多个数据库操作时,应用系统中的第一ORM框架会向ORM执行引擎发送启动事务语句,以指示ORM执行引擎创建一个事务,从而实现将第一ORM框架后续发送的多个操作请求解析得到的多个SQL语句作为一个事务进行执行。When the application system determines that multiple database operations need to be performed in one transaction, the first ORM framework in the application system will send a start transaction statement to the ORM execution engine to instruct the ORM execution engine to create a transaction, thereby implementing the execution of multiple SQL statements obtained by parsing multiple operation requests subsequently sent by the first ORM framework as a transaction.
可选地,应用系统与ORM执行引擎可以通过GRPC(Google Remote Procedure Call,远程过程调用)协议进行通信。Optionally, the application system and the ORM execution engine can communicate through the GRPC (Google Remote Procedure Call) protocol.
这种情况下,在存在包含有多个ORM执行引擎的ORM执行引擎集群的情况下,若一个应用系统第一次与ORM执行引擎集群中的一个ORM执行引擎建立连接,则这个应用系统与这个ORM执行引擎之间的通信连接不中断,此时这个应用系统可以不断地向这个ORM执行引擎发送多个操作请求。如此,可以保证第一ORM框架在发送启动事务语句后发送的多个操作请求均是发送给同一个ORM执行引擎,从而这个ORM执行引擎可以将接收到的该多个操作请求解析得到的多个SQL语句在同一个事务中执行。In this case, when there is an ORM execution engine cluster including multiple ORM execution engines, if an application system establishes a connection with an ORM execution engine in the ORM execution engine cluster for the first time, the communication connection between the application system and the ORM execution engine is not interrupted, and the application system can continuously send multiple operation requests to the ORM execution engine. In this way, it can be ensured that the multiple operation requests sent by the first ORM framework after sending the start transaction statement are all sent to the same ORM execution engine, so that the ORM execution engine can execute the multiple SQL statements obtained by parsing the received multiple operation requests in the same transaction.
步骤702:ORM执行引擎中的第二ORM框架在获取到启动事务语句后,创建目标事务。Step 702: After obtaining the start transaction statement, the second ORM framework in the ORM execution engine creates a target transaction.
可选地,ORM执行引擎中的中间件模块可以接收第一ORM框架发送的启动事务语句,然后将该启动事务语句发送给第二ORM框架。Optionally, the middleware module in the ORM execution engine may receive a start transaction statement sent by the first ORM framework, and then send the start transaction statement to the second ORM framework.
ORM执行引擎中的第二ORM框架在获取到启动事务语句后,会创建目标事务。之后第二ORM框架可将第一ORM框架后续发送的多个操作请求解析得到的多个SQL语句均作为需目标事务执行的SQL语句。目标事务中的多个SQL语句可以同时进行提交或回滚。也即,目标事务提交,是指同时提交目标事务中多个SQL语句的执行结果;目标事务回滚,是指同时回滚目标事务中多个SQL语句的执行结果。After obtaining the start transaction statement, the second ORM framework in the ORM execution engine will create a target transaction. After that, the second ORM framework can use the multiple SQL statements obtained by parsing the multiple operation requests subsequently sent by the first ORM framework as SQL statements to be executed by the target transaction. Multiple SQL statements in the target transaction can be committed or rolled back at the same time. That is, target transaction commit means committing the execution results of multiple SQL statements in the target transaction at the same time; target transaction rollback means rolling back the execution results of multiple SQL statements in the target transaction at the same time.
第二ORM框架创建目标事务的操作与相关技术中某个设备创建一个事务的操作类似,本申请实施例对此不进行详细阐述。The operation of the second ORM framework to create a target transaction is similar to the operation of a device creating a transaction in the related art, and the embodiment of the present application will not elaborate on this.
步骤703:第一ORM框架向ORM执行引擎发送多个操作请求。Step 703: The first ORM framework sends multiple operation requests to the ORM execution engine.
可选地,第一ORM框架在向ORM执行引擎发送启动事务语句后,可以通过GRPC协议向ORM执行引擎不断发送多个操作请求,该多个操作请求中的每个操作请求均用于请求对数据库中的数据进行操作。Optionally, after sending a start transaction statement to the ORM execution engine, the first ORM framework may continuously send multiple operation requests to the ORM execution engine through the GRPC protocol, each of the multiple operation requests being used to request an operation on data in the database.
步骤704:第二ORM框架每获取到一个操作请求,对获取到的这个操作请求进行解析,得到属于目标事务的SQL语句,执行最新得到的属于目标事务的SQL语句。Step 704: Whenever the second ORM framework obtains an operation request, it parses the obtained operation request to obtain the SQL statement belonging to the target transaction, and executes the latest obtained SQL statement belonging to the target transaction.
可选地,ORM执行引擎中的中间件模块可以接收第一ORM框架发送的操作请求,且中间件模块每接收到一个操作请求,可以在满足数据库访问条件的情况下,将这个操作请求发送给第二ORM框架。Optionally, the middleware module in the ORM execution engine may receive an operation request sent by the first ORM framework, and each time the middleware module receives an operation request, it may send the operation request to the second ORM framework if the database access condition is met.
其中,第一ORM框架向ORM执行引擎发送一个操作请求,ORM执行引擎中的第二ORM框架对这个操作请求的处理过程可以参考上文图2实施例中的相关操作,本申请实施例对此不再赘述。Among them, the first ORM framework sends an operation request to the ORM execution engine. The processing process of the second ORM framework in the ORM execution engine on this operation request can refer to the relevant operations in the embodiment of Figure 2 above, and the embodiment of this application will not be repeated here.
具体来讲,第二ORM框架每获取到一个操作请求,对这个操作请求进行解析,得到属于目标事务的SQL语句,执行最新得到的属于目标事务的SQL语句,得到执行结果。这种情况下,第一ORM框架向ORM执行引擎发送多个操作请求后,第二ORM框架执行该多个操作请求中每个操作请求解析得到的SQL语句,会得到目标事务中的多个SQL语句的执行结果,且每得到一个SQL语句的执行结果,可以将这个SQL语句的执行结果作为对应的一个操作请求的请求结果返回给应用系统。并且,这种情况下,第二ORM框架每得到一个SQL语句的执行结果后并不指示数据库提交这个SQL语句的执行结果。Specifically, each time the second ORM framework obtains an operation request, it parses the operation request, obtains the SQL statement belonging to the target transaction, executes the latest SQL statement belonging to the target transaction, and obtains the execution result. In this case, after the first ORM framework sends multiple operation requests to the ORM execution engine, the second ORM framework executes the SQL statement obtained by parsing each of the multiple operation requests, and obtains the execution results of multiple SQL statements in the target transaction. Each time the execution result of an SQL statement is obtained, the execution result of the SQL statement can be returned to the application system as the request result of the corresponding operation request. In addition, in this case, each time the second ORM framework obtains the execution result of an SQL statement, it does not instruct the database to submit the execution result of the SQL statement.
例如,图8为应用系统与ORM执行引擎的交互示意图。参见图8,图8中包括应用系统801、ORM执行引擎802。应用系统801向ORM执行引擎802发送启动事务语句后,发送多个操作请求。ORM执行引擎802中的第二ORM框架每获取到一个操作请求,就执行解析这个操作请求得到的属于目标事务的SQL语句,得到这个SQL语句的执行结果,之后再将这个SQL语句的执行结果作为这个操作请求的请求结果发送给应用系统801,从而向应用系统801发送该多个操作请求中每个操作请求的请求结果。For example, FIG8 is a schematic diagram of the interaction between the application system and the ORM execution engine. Referring to FIG8 , FIG8 includes an application system 801 and an ORM execution engine 802. After the application system 801 sends a start transaction statement to the ORM execution engine 802, it sends multiple operation requests. Every time the second ORM framework in the ORM execution engine 802 obtains an operation request, it executes the SQL statement belonging to the target transaction obtained by parsing the operation request, obtains the execution result of the SQL statement, and then sends the execution result of the SQL statement as the request result of the operation request to the application system 801, thereby sending the request result of each operation request in the multiple operation requests to the application system 801.
步骤705:第一ORM框架向ORM执行引擎发送提交语句或回滚语句。Step 705: The first ORM framework sends a commit statement or a rollback statement to the ORM execution engine.
提交语句用于指示提交目标事务,即用于指示数据库对目标事务中的所有SQL语句的执行结果进 行提交。回滚语句用于指示回滚目标事务,即用于指示数据库对目标事务中的所有SQL语句的执行结果进行回滚。The commit statement is used to instruct the target transaction to be committed, that is, to instruct the database to perform the execution results of all SQL statements in the target transaction. The rollback statement is used to instruct the target transaction to be rolled back, that is, to instruct the database to roll back the execution results of all SQL statements in the target transaction.
步骤706:第二ORM框架若获取到提交语句,则指示数据库对目标事务中所有SQL语句的执行结果进行提交。Step 706: If the second ORM framework obtains the commit statement, it instructs the database to commit the execution results of all SQL statements in the target transaction.
可选地,ORM执行引擎中的中间件模块可以接收第一ORM框架发送的提交语句,然后将该提交语句发送给第二ORM框架。Optionally, the middleware module in the ORM execution engine may receive a commit statement sent by the first ORM framework, and then send the commit statement to the second ORM framework.
在一些实施例中,在没有提交目标事务中所有SQL语句的执行结果之前,实质上没有完成对数据库中的数据的操作,第二ORM框架执行这些SQL语句表现为数据库记录了对数据库中的对象进行多次操作的操作信息。只有数据库在接收到提交指示时,数据库才会对目标事务中所有SQL语句的执行结果进行提交,也即是真正实现对数据库中的数据的操作,且是同时对数据库进行多次操作。In some embodiments, before the execution results of all SQL statements in the target transaction are submitted, the operation on the data in the database is not actually completed, and the second ORM framework executes these SQL statements, which is manifested as the database recording the operation information of multiple operations on the objects in the database. Only when the database receives the commit instruction, will it submit the execution results of all SQL statements in the target transaction, that is, it truly realizes the operation on the data in the database, and performs multiple operations on the database at the same time.
步骤707:第二ORM框架若获取到回滚语句,则指示数据库对目标事务中所有SQL语句的执行结果进行回滚。Step 707: If the second ORM framework obtains a rollback statement, it instructs the database to roll back the execution results of all SQL statements in the target transaction.
可选地,ORM执行引擎中的中间件模块可以接收第一ORM框架发送的回滚语句,然后将该回滚语句发送给第二ORM框架。Optionally, the middleware module in the ORM execution engine may receive a rollback statement sent by the first ORM framework, and then send the rollback statement to the second ORM framework.
这种情况下,数据库对目标事务中所有SQL语句的执行结果进行回滚,也即是撤销目标事务中所有SQL语句对数据库中的数据进行的操作。在一些实施例中,即是删除数据库中记录的对数据库中的对象进行多次操作的操作信息。In this case, the database rolls back the execution results of all SQL statements in the target transaction, that is, cancels the operations performed on the data in the database by all SQL statements in the target transaction. In some embodiments, the operation information recorded in the database that performs multiple operations on the objects in the database is deleted.
下面举例说明在一个事务中对数据库中的数据进行多次访问的有益效果。The following example illustrates the beneficial effects of multiple accesses to data in a database within one transaction.
假设用户在一个应用系统中购买商品,购买商品时需要付款,购买后会生成订单信息。那么此时需要进行减少用户账户余额的操作,以及在该用户的订单列表中新增一条订单信息的操作。Suppose a user purchases a product in an application system. When purchasing a product, payment is required and order information is generated after the purchase. At this time, it is necessary to reduce the user's account balance and add a new order information to the user's order list.
若这两个操作不在一个事务中执行,那么应用系统先向ORM执行引擎发送需要修改余额的操作请求,则ORM执行引擎对该操作请求进行解析得到一个修改余额的SQL语句,之后执行这个SQL语句并提交执行结果,完成对该用户的账户余额的修改。之后应用系统向ORM执行引擎发送需要新增订单信息的操作请求,则ORM执行引擎对该操作请求进行解析得到一个新增订单信息的SQL语句。但是在ORM执行引擎执行该SQL语句时发生了网络故障,那么此时在用户的订单列表中新增一条订单信息的操作就不能完成。这种情况下,用户可以查询到自己的账户余额减少,但是查询不到购买商品的订单信息。If these two operations are not performed in the same transaction, the application system first sends an operation request to modify the balance to the ORM execution engine. The ORM execution engine parses the operation request to obtain a SQL statement to modify the balance, then executes the SQL statement and submits the execution result to complete the modification of the user's account balance. The application system then sends an operation request to add order information to the ORM execution engine. The ORM execution engine parses the operation request to obtain a SQL statement to add order information. However, a network failure occurs when the ORM execution engine executes the SQL statement. At this time, the operation of adding a new order information to the user's order list cannot be completed. In this case, the user can find that his account balance has decreased, but cannot find the order information for the purchased goods.
若这两个操作在一个事务中执行,那么应用系统先向ORM执行引擎发送启动事务语句,之后ORM执行引擎创建目标事务。应用系统再向ORM执行引擎发送修改余额的操作请求以及新增订单信息的操作请求,则ORM执行引擎在接收到修改余额的操作请求后,对该操作请求进行解析得到一个修改余额的SQL语句,执行这个SQL语句但不提交执行结果。之后ORM执行引擎在接收到新增订单信息的操作请求后,再对该操作请求进行解析得到一个新增订单信息的SQL语句,执行这个SQL语句但不提交执行结果。在一些实施例中,应用系统会向ORM执行引擎发送提交语句,则ORM执行引擎会指示数据库对目标事务中的两个SQL语句的执行结果进行提交,以真正实现对用户账户余额的修改,以及在订单列表中新增订单信息。此时用户可以查询到自己账户余额减少、且订单列表中有购买商品的订单信息。在另一些实施例中,即使发生网络故障,ORM执行引擎在没有接收到提交语句之前也不会指示数据库对目标事务中的两个SQL语句的执行结果进行提交,那么数据库的数据就不会发生改变。用户此时会查询到自己账户的余额没有减少,订单列表中也不会新增订单信息。如此,将多个操作在一个事务中执行,可以保证多个操作在执行时的一致性。If these two operations are executed in one transaction, the application system first sends a start transaction statement to the ORM execution engine, and then the ORM execution engine creates a target transaction. The application system then sends an operation request to modify the balance and an operation request to add order information to the ORM execution engine. After receiving the operation request to modify the balance, the ORM execution engine parses the operation request to obtain an SQL statement to modify the balance, executes the SQL statement but does not submit the execution result. Afterwards, after receiving the operation request to add order information, the ORM execution engine parses the operation request to obtain an SQL statement to add order information, executes the SQL statement but does not submit the execution result. In some embodiments, the application system sends a commit statement to the ORM execution engine, and the ORM execution engine instructs the database to submit the execution results of the two SQL statements in the target transaction to truly modify the user account balance and add order information to the order list. At this time, the user can query that the balance of his account has decreased and there is order information for purchasing goods in the order list. In other embodiments, even if a network failure occurs, the ORM execution engine will not instruct the database to submit the execution results of the two SQL statements in the target transaction before receiving the commit statement, so that the data in the database will not change. At this time, the user will find that the balance of his account has not decreased, and no new order information will be added to the order list. In this way, executing multiple operations in one transaction can ensure the consistency of multiple operations during execution.
在本申请实施例中,第一ORM框架向ORM执行引擎发送启动事务语句,以指示第二ORM框架创建目标事务,从而使第一ORM框架后续发送的多个操作请求解析得到的多个SQL语句可以在目标事务中执行。之后第一ORM框架向ORM执行引擎发送提交语句或回滚语句,以使第二ORM框架指示数据库对目标事务中的所有SQL语句的执行结果进行同时提交或回滚。如此,可以保证具有关联的多个操作能够同时在数据库中被提交,保证这多个操作在执行时的一致性,从而保证数据库的一致性。In an embodiment of the present application, the first ORM framework sends a start transaction statement to the ORM execution engine to instruct the second ORM framework to create a target transaction, so that multiple SQL statements obtained by parsing multiple operation requests subsequently sent by the first ORM framework can be executed in the target transaction. After that, the first ORM framework sends a commit statement or a rollback statement to the ORM execution engine so that the second ORM framework instructs the database to simultaneously commit or roll back the execution results of all SQL statements in the target transaction. In this way, it can be ensured that multiple operations with associations can be submitted in the database at the same time, ensuring the consistency of these multiple operations during execution, thereby ensuring the consistency of the database.
下面对本申请实施例提供的数据库访问系统进行解释说明。The database access system provided in the embodiment of the present application is explained below.
图9是本申请实施例提供的一种数据库访问系统的结构示意图。参见图9,该数据库访问系统包 括多个应用系统101和ORM执行引擎集群,ORM执行引擎集群可以是由多个ORM执行引擎102构成的。FIG9 is a schematic diagram of the structure of a database access system provided in an embodiment of the present application. Referring to FIG9, the database access system includes The ORM execution engine cluster includes multiple application systems 101 and an ORM execution engine cluster. The ORM execution engine cluster can be composed of multiple ORM execution engines 102.
该多个应用系统101中任意的一个应用系统101可以与该ORM执行引擎集群中任意的一个ORM执行引擎102进行通信。Any application system 101 among the multiple application systems 101 can communicate with any ORM execution engine 102 in the ORM execution engine cluster.
下面对应用系统101进行解释说明:The application system 101 is explained below:
多个应用系统101中的每个应用系统101中包括第一ORM框架。第一ORM框架可以根据业务语句生成操作请求,向ORM执行引擎102发送操作请求。Each of the multiple application systems 101 includes a first ORM framework. The first ORM framework can generate an operation request according to a business statement and send the operation request to the ORM execution engine 102.
该操作请求用于请求对数据库103中的数据进行操作。第一ORM框架向ORM执行引擎102发送该操作请求是向ORM执行引擎集群中任意的一个ORM执行引擎102发送该操作请求。The operation request is used to request to operate the data in the database 103. The first ORM framework sends the operation request to the ORM execution engine 102 to send the operation request to any one of the ORM execution engines 102 in the ORM execution engine cluster.
第一ORM框架根据业务语句生成操作请求,向ORM执行引擎102发送操作请求的相关内容已经在图2实施例中的步骤201和步骤202进行详细说明,本申请实施例对此不再赘述。The first ORM framework generates an operation request according to the business statement, and the relevant content of sending the operation request to the ORM execution engine 102 has been described in detail in steps 201 and 202 in the embodiment of FIG. 2 , and will not be repeated in the embodiment of the present application.
这种情况下,应用系统101只需根据技术人员使用面向对象语言编写的业务语句生成操作请求,并将该操作请求发送给ORM执行引擎102。而无需对技术人员使用面向对象语言编写的业务语句进行解析。如此,可以减轻应用系统101的业务压力,从而提升应用系统101的性能。In this case, the application system 101 only needs to generate an operation request according to the business statement written by the technician using the object-oriented language, and send the operation request to the ORM execution engine 102. There is no need to parse the business statement written by the technician using the object-oriented language. In this way, the business pressure of the application system 101 can be reduced, thereby improving the performance of the application system 101.
下面对ORM执行引擎102进行解释说明:The ORM execution engine 102 is explained below:
ORM执行引擎集群中的多个ORM执行引擎102中的每个ORM执行引擎102均与数据库103进行通信连接,在一些实施例中,ORM执行引擎集群中的多个ORM执行引擎102可以互相通信,以实现数据共享。Each of the multiple ORM execution engines 102 in the ORM execution engine cluster is in communication connection with the database 103. In some embodiments, the multiple ORM execution engines 102 in the ORM execution engine cluster can communicate with each other to achieve data sharing.
ORM执行引擎集群中的多个ORM执行引擎102中的每个ORM执行引擎102包括第二ORM框架。第二ORM框架可以执行上述图2实施例中的步骤203-步骤205,也即是获取到第一ORM框架发送的操作请求,对该操作请求进行解析,得到SQL语句,执行该SQL语句,以访问数据库103中的数据,得到该SQL语句的执行结果。Each of the multiple ORM execution engines 102 in the ORM execution engine cluster includes a second ORM framework. The second ORM framework can execute steps 203 to 205 in the embodiment of FIG. 2 , that is, to obtain the operation request sent by the first ORM framework, parse the operation request, obtain an SQL statement, execute the SQL statement, access the data in the database 103, and obtain the execution result of the SQL statement.
这种情况下,ORM执行引擎102充当应用系统101与数据库103之间的桥梁,使得应用系统101无需直接连接数据库103,而是由ORM执行引擎102与数据库103进行通信连接,实现对数据库103的访问。因此无需在应用系统101中配置数据库103的账号密码,提高了数据库103的安全性。In this case, the ORM execution engine 102 acts as a bridge between the application system 101 and the database 103, so that the application system 101 does not need to directly connect to the database 103, but the ORM execution engine 102 communicates with the database 103 to access the database 103. Therefore, there is no need to configure the account password of the database 103 in the application system 101, which improves the security of the database 103.
可选地,应用系统101与ORM执行引擎102可以通过GRPC协议进行通信。如此,可以保证一个应用系统101中的第一ORM框架发送的多个操作请求均是发送给同一个ORM执行引擎102,从而保证该多个操作请求解析得到的SQL语句可以在一个事务中执行。上述图7实施例对在一个事务中执行多个操作请求解析得到的多个SQL语句的过程进行了解释说明,本申请实施例对此不再赘述。Optionally, the application system 101 and the ORM execution engine 102 can communicate via the GRPC protocol. In this way, it can be ensured that multiple operation requests sent by the first ORM framework in an application system 101 are all sent to the same ORM execution engine 102, thereby ensuring that the SQL statements obtained by parsing the multiple operation requests can be executed in one transaction. The above-mentioned embodiment of Figure 7 explains the process of executing multiple SQL statements obtained by parsing multiple operation requests in one transaction, and the embodiment of this application will not be repeated here.
一种可能的情况下,参见图10,该数据库访问系统中还可以包括中间件模块1001,中间件模块1001与应用系统101进行通信连接,也即,中间件模块1001可以与第一ORM框架直接进行通信。In one possible case, referring to FIG. 10 , the database access system may further include a middleware module 1001 , and the middleware module 1001 is in communication connection with the application system 101 , that is, the middleware module 1001 may directly communicate with the first ORM framework.
中间件模块1001可以在接收到应用系统101发送的操作请求后,在满足数据库访问条件的情况下,向第二ORM框架1002发送该操作请求。After receiving the operation request sent by the application system 101 , the middleware module 1001 may send the operation request to the second ORM framework 1002 if the database access condition is met.
示例地,图11为中间件模块1001的示意图。参见图11,图11包括应用系统101、中间件模块1001、第二ORM框架1002。示例地,中间件模块1001中可以设置如下数据库访问条件:For example, Fig. 11 is a schematic diagram of the middleware module 1001. Referring to Fig. 11, Fig. 11 includes an application system 101, a middleware module 1001, and a second ORM framework 1002. For example, the following database access conditions can be set in the middleware module 1001:
数据库103的访问次数小于第一次数阈值(流量控制)。The number of accesses to the database 103 is less than a first number threshold (flow control).
应用系统101具有该操作请求所要访问的对象的访问权限(表权限控制)。The application system 101 has access rights (table authority control) to the object to be accessed by the operation request.
应用系统101具有数据库103的访问权限(账户体系认证)。The application system 101 has access rights to the database 103 (account system authentication).
该操作请求中的操作类型是数据库103允许对该操作请求所要访问的对象进行的操作类型(ORM语法控制)。The operation type in the operation request is the type of operation that the database 103 allows to perform on the object to be accessed by the operation request (controlled by ORM syntax).
中间件模块1001在接收到该操作请求后,先判断该操作请求是否满足设置的数据库访问条件,在该操作请求满足数据库访问条件的情况下,中间件模块1001才将该操作请求发送给第二ORM框架1002。After receiving the operation request, the middleware module 1001 first determines whether the operation request satisfies the set database access condition. Only when the operation request satisfies the database access condition does the middleware module 1001 send the operation request to the second ORM framework 1002.
关于数据库访问条件的相关内容已经在图2实施例中的步骤203进行解释说明,本申请实施例对此不再赘述。The relevant contents about the database access conditions have been explained in step 203 of the embodiment of FIG. 2 , and will not be described in detail in the embodiment of the present application.
这种情况下,通过在中间件模块1001中设置数据库访问条件,可以使ORM执行引擎102能够很好的统筹管理整个数据库103的访问,同时满足所有业务化需求,支持更高级的、特殊的、自定义的管 控配置。In this case, by setting the database access conditions in the middleware module 1001, the ORM execution engine 102 can well coordinate and manage the access to the entire database 103, while meeting all business requirements and supporting more advanced, special, and customized management. Control configuration.
一种可能的情况下,参见图12,该数据库访问系统还可以包括缓存模块1201,缓存模块1201与ORM执行引擎102进行通信连接。缓存模块1201存储了多个键值对,多个键值对中的每个键值对存储的是操作类型为查询类型的操作请求的请求结果。也即是多个键值对中每个键值对中的key值为对操作类型为查询类型的操作请求进行哈希运算得到的哈希值,多个键值对中每个键值对中的value值为操作类型为查询类型的操作请求的请求结果。也即,对于缓存模块1201中存储的任意一个键值对,这个键值对中的key值为操作类型为查询类型的一个操作请求的哈希值,这个键值对中的value值为这个操作请求的请求结果,也即为这个操作请求从数据库103查询到的数据。In one possible case, referring to FIG. 12 , the database access system may further include a cache module 1201, which is in communication connection with the ORM execution engine 102. The cache module 1201 stores a plurality of key-value pairs, and each of the plurality of key-value pairs stores a request result of an operation request of a query type. That is, the key value in each of the plurality of key-value pairs is a hash value obtained by performing a hash operation on the operation request of a query type, and the value value in each of the plurality of key-value pairs is a request result of an operation request of a query type. That is, for any key-value pair stored in the cache module 1201, the key value in the key-value pair is a hash value of an operation request of a query type, and the value value in the key-value pair is a request result of the operation request, that is, the data queried from the database 103 by the operation request.
这种情况下,在该操作请求中的操作类型为除查询类型之外的其他类型的情况下,第二ORM框架1002可以直接执行上述步骤204-步骤205来获得该操作请求的请求结果。In this case, when the operation type in the operation request is other types except the query type, the second ORM framework 1002 can directly execute the above steps 204 to 205 to obtain the request result of the operation request.
而在该操作请求中的操作类型为查询类型的情况下,第二ORM框架可以先对该操作请求进行哈希运算,得到哈希值;从缓存模块1201中查询与该哈希值相同的key值。若从缓存模块1201中查询到与该哈希值相同的key值,则将缓存模块1201中与该哈希值相同的key值所在的键值对中的value值确定为该操作请求的请求结果。若从缓存模块1201中未查询到与该哈希值相同的key值,则第二ORM框架执行上述步骤204-步骤205,也即,对该操作请求进行解析,得到该SQL语句,执行该SQL语句,以访问数据库中的数据,得到该SQL语句的执行结果作为该操作请求的请求结果,这种情况下,还可以生成目标键值对,将目标键值对存储至缓存模块1201。In the case where the operation type in the operation request is a query type, the second ORM framework may first perform a hash operation on the operation request to obtain a hash value; and query the cache module 1201 for a key value identical to the hash value. If a key value identical to the hash value is queried from the cache module 1201, the value in the key-value pair of the key value identical to the hash value in the cache module 1201 is determined as the request result of the operation request. If a key value identical to the hash value is not queried from the cache module 1201, the second ORM framework executes the above steps 204-205, that is, parses the operation request to obtain the SQL statement, executes the SQL statement to access the data in the database, and obtains the execution result of the SQL statement as the request result of the operation request. In this case, a target key-value pair may also be generated and stored in the cache module 1201.
在该操作请求中的操作类型为更新类型的情况下,第二ORM框架可以删除缓存模块1201中与该操作请求中的对象标识关联存储的所有键值对。In the case where the operation type in the operation request is an update type, the second ORM framework may delete all key-value pairs stored in the cache module 1201 in association with the object identifier in the operation request.
ORM执行引擎102与缓存模块1201的交互过程已经在图2实施例中的步骤205进行解释说明,本申请实施例对此不再赘述。The interaction process between the ORM execution engine 102 and the cache module 1201 has been explained in step 205 of the embodiment of FIG. 2 , and will not be described in detail in the embodiment of the present application.
在该数据库访问系统包括缓存模块1201的情况下,若应用系统101需要频繁、大量查询数据,通过缓存模块1201可以减轻数据库103的访问压力。且对于应用系统101的用户而言,在访问数据库103时不会感知到缓存模块1201的存在。另外,由于ORM执行引擎102访问缓存模块1201的速度比访问数据库103的速度快很多,所以在缓存模块1201中存在所要查询的数据的情况下,直接将缓存模块1201中存储的数据返回给应用系统,可以提高数据查询效率,对于应用系统101而言即相当于提高了数据库访问效率。In the case where the database access system includes the cache module 1201, if the application system 101 needs to frequently and massively query data, the access pressure of the database 103 can be reduced through the cache module 1201. And for the user of the application system 101, the existence of the cache module 1201 will not be perceived when accessing the database 103. In addition, since the speed of the ORM execution engine 102 accessing the cache module 1201 is much faster than the speed of accessing the database 103, when the cache module 1201 contains the data to be queried, the data stored in the cache module 1201 is directly returned to the application system, which can improve the data query efficiency, which is equivalent to improving the database access efficiency for the application system 101.
值得注意的一点是,本申请实施例提供的数据库访问系统中的应用系统101无需与数据库103直接连接,而是通过在应用系统101与数据库103之间设置ORM执行引擎102访问数据库103,具体由应用系统101向ORM执行引擎102发送操作请求,以请求访问数据库103中的数据,之后由ORM执行引擎102与数据库103进行通信,来实现对数据库103的访问。如此无需将数据库103的账号密码配置在应用系统101中,降低了应用系统101的配置复杂度,同时保护了隐私数据,减少了数据的安全隐患,从而保证了数据库103的安全性。It is worth noting that the application system 101 in the database access system provided in the embodiment of the present application does not need to be directly connected to the database 103, but accesses the database 103 by setting an ORM execution engine 102 between the application system 101 and the database 103. Specifically, the application system 101 sends an operation request to the ORM execution engine 102 to request access to the data in the database 103, and then the ORM execution engine 102 communicates with the database 103 to achieve access to the database 103. In this way, there is no need to configure the account password of the database 103 in the application system 101, which reduces the configuration complexity of the application system 101, protects privacy data, reduces data security risks, and thus ensures the security of the database 103.
值得注意的另一点是,由于应用系统101无需直接连接数据库103,所以不再消耗数据库103的TCP连接数,这对于数据库103来说,整体的TCP连接数是可控制的、可管理的。同时由于本申请实施例提供的数据库访问系统中的应用系统101和ORM执行引擎102通过GRPC协议进行通信,GRPC协议是一种高效的多路复用技术,所以降低了应用系统101的连接池管理难度。Another point worth noting is that since the application system 101 does not need to directly connect to the database 103, the number of TCP connections of the database 103 is no longer consumed, which makes the overall number of TCP connections controllable and manageable for the database 103. At the same time, since the application system 101 and the ORM execution engine 102 in the database access system provided in the embodiment of the present application communicate through the GRPC protocol, which is an efficient multiplexing technology, the difficulty of connection pool management of the application system 101 is reduced.
在本申请实施例中,应用系统包括第一ORM框架,ORM执行引擎包括第二ORM框架,并且ORM执行引擎与数据库进行通信连接。第一ORM框架根据业务语句生成操作请求,再将该操作请求发送给ORM执行引擎,也即是应用系统在需要访问数据库时向ORM执行引擎发送操作请求。之后ORM执行引擎中的第二ORM框架接收到该操作请求之后,对该操作请求进行解析得到SQL语句,该SQL语句是数据库可以识别的语句。之后第二ORM框架执行该SQL语句,以访问数据库中的数据。如此,应用系统无需直接连接数据库,因而应用系统中无需配置数据库的密码,而只需ORM执行引擎与数据库进行交互,以实现对数据库的访问,从而保证了数据库的安全性。In an embodiment of the present application, the application system includes a first ORM framework, the ORM execution engine includes a second ORM framework, and the ORM execution engine is connected to the database for communication. The first ORM framework generates an operation request based on the business statement, and then sends the operation request to the ORM execution engine, that is, the application system sends an operation request to the ORM execution engine when it needs to access the database. After that, after the second ORM framework in the ORM execution engine receives the operation request, it parses the operation request to obtain an SQL statement, which is a statement that the database can recognize. The second ORM framework then executes the SQL statement to access the data in the database. In this way, the application system does not need to directly connect to the database, so there is no need to configure the database password in the application system, and only the ORM execution engine needs to interact with the database to access the database, thereby ensuring the security of the database.
图13为本申请实施例提供的一种计算机设备的结构示意图。如图13所示,计算机设备13包括:处理器130、存储器131以及存储在存储器131中并可在处理器130上运行的计算机程序132,处理器 130执行计算机程序132时实现上述实施例中的数据库访问方法中由ORM执行引擎执行的步骤。FIG13 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. As shown in FIG13 , the computer device 13 includes: a processor 130, a memory 131, and a computer program 132 stored in the memory 131 and executable on the processor 130. When executing the computer program 132, 130 implements the steps executed by the ORM execution engine in the database access method in the above embodiment.
计算机设备13可以是一个通用计算机设备或一个专用计算机设备。在具体实现中,计算机设备13可以是网络服务器。本领域技术人员可以理解,图13仅仅是计算机设备13的举例,并不构成对计算机设备13的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,比如还可以包括输入输出设备、网络接入设备等。The computer device 13 may be a general-purpose computer device or a special-purpose computer device. In a specific implementation, the computer device 13 may be a network server. Those skilled in the art will appreciate that FIG. 13 is merely an example of the computer device 13 and does not constitute a limitation on the computer device 13. The computer device 13 may include more or fewer components than shown in the figure, or may combine certain components, or different components, such as input and output devices, network access devices, etc.
处理器130可以是中央处理单元(Central Processing Unit,CPU),处理器130还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者也可以是任何常规的处理器。The processor 130 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
存储器131在一些实施例中可以是计算机设备13的内部存储单元,比如计算机设备13的硬盘或内存。存储器131在另一些实施例中也可以是计算机设备13的外部存储设备,比如计算机设备13上配备的插接式硬盘、智能存储卡(Smart Media Card,SMC)、安全数字(Secure Digital,SD)卡、闪存卡(Flash Card)等。进一步地,存储器131还可以既包括计算机设备13的内部存储单元也包括外部存储设备。存储器131用于存储操作系统、应用程序、引导装载程序(Boot Loader)、数据以及其他程序等。存储器131还可以用于暂时地存储已经输出或者将要输出的数据。In some embodiments, the memory 131 may be an internal storage unit of the computer device 13, such as a hard disk or memory of the computer device 13. In other embodiments, the memory 131 may also be an external storage device of the computer device 13, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card (Flash Card), etc. equipped on the computer device 13. Further, the memory 131 may also include both an internal storage unit of the computer device 13 and an external storage device. The memory 131 is used to store an operating system, an application program, a boot loader (Boot Loader), data, and other programs. The memory 131 may also be used to temporarily store data that has been output or is to be output.
本申请实施例还提供了一种计算机设备,该计算机设备包括:至少一个处理器、存储器以及存储在该存储器中并可在该至少一个处理器上运行的计算机程序,该处理器执行该计算机程序时实现上述任意各个方法实施例中的步骤。An embodiment of the present application also provides a computer device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, and when the processor executes the computer program, the steps in any of the above-mentioned method embodiments are implemented.
本申请实施例还提供了一种计算机可读存储介质,该计算机可读存储介质存储有计算机程序,该计算机程序被处理器执行时可实现上述各个方法实施例中的步骤。An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
本申请实施例提供了一种计算机程序产品,当其在计算机上运行时,使得计算机执行上述各个方法实施例中的步骤。An embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the steps in the above-mentioned method embodiments.
集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述方法实施例中的全部或部分流程,可以通过计算机程序来指令相关的硬件来完成,该计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,该计算机程序包括计算机程序代码,该计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。该计算机可读介质至少可以包括:能够将计算机程序代码携带到拍照装置/终端设备的任何实体或装置、记录介质、计算机存储器、ROM(Read-Only Memory,只读存储器)、RAM(Random Access Memory,随机存取存储器)、CD-ROM(Compact Disc Read-Only Memory,只读光盘)、磁带、软盘和光数据存储设备等。本申请提到的计算机可读存储介质可以为非易失性存储介质,换句话说,可以是非瞬时性存储介质。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above method embodiments, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of each of the above method embodiments can be implemented. Among them, the computer program includes computer program code, which can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera/terminal device, recording medium, computer memory, ROM (Read-Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read-Only Memory), magnetic tape, floppy disk and optical data storage device. The computer-readable storage medium mentioned in the present application can be a non-volatile storage medium, in other words, a non-transient storage medium.
应当理解的是,实现上述实施例的全部或部分步骤可以通过软件、硬件、固件或者其任意结合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。该计算机程序产品包括一个或多个计算机指令。该计算机指令可以存储在上述计算机可读存储介质中。It should be understood that all or part of the steps to implement the above embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. The computer instructions can be stored in the above-mentioned computer readable storage medium.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
在本申请所提供的实施例中,应该理解到,所揭露的装置/计算机设备和方法,可以通过其它的方式实现。例如,以上所描述的装置/计算机设备实施例仅仅是示意性的,例如,模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。 In the embodiments provided in the present application, it should be understood that the disclosed devices/computer equipment and methods can be implemented in other ways. For example, the device/computer equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。以上仅为本申请的可选实施例而已,并不用于限制本申请。对于本领域的技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。 The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application is described in detail with reference to the aforementioned embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the protection scope of the present application. The above are only optional embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included in the scope of the claims of the present application.

Claims (15)

  1. 一种数据库访问系统,其特征在于,所述数据库访问系统包括应用系统和关系对象映射ORM执行引擎,所述应用系统包括第一ORM框架,所述ORM执行引擎包括第二ORM框架,所述ORM执行引擎与数据库进行通信连接;A database access system, characterized in that the database access system comprises an application system and an object relation mapping (ORM) execution engine, the application system comprises a first ORM framework, the ORM execution engine comprises a second ORM framework, and the ORM execution engine is in communication connection with a database;
    所述第一ORM框架,用于根据业务语句生成操作请求,向所述ORM执行引擎发送所述操作请求,所述操作请求用于请求对所述数据库中的数据进行操作;The first ORM framework is used to generate an operation request according to the business statement, and send the operation request to the ORM execution engine, wherein the operation request is used to request to operate the data in the database;
    所述第二ORM框架,用于在获取到所述操作请求后,对所述操作请求进行解析,得到结构化查询语言SQL语句;执行所述SQL语句,以访问所述数据库中的数据,得到所述SQL语句的执行结果。The second ORM framework is used to parse the operation request after obtaining the operation request to obtain a structured query language SQL statement; execute the SQL statement to access the data in the database to obtain the execution result of the SQL statement.
  2. 根据权利要求1所述的数据库访问系统,其特征在于,The database access system according to claim 1, characterized in that:
    所述第一ORM框架,用于向所述ORM执行引擎发送启动事务语句;The first ORM framework is used to send a start transaction statement to the ORM execution engine;
    所述第二ORM框架,用于在获取到所述启动事务语句后,创建目标事务;The second ORM framework is used to create a target transaction after obtaining the start transaction statement;
    所述第一ORM框架,用于在向所述ORM执行引擎发送所述启动事务语句后,向所述ORM执行引擎发送多个操作请求;The first ORM framework is used to send multiple operation requests to the ORM execution engine after sending the start transaction statement to the ORM execution engine;
    所述第二ORM框架,用于在创建所述目标事务后,每获取到一个操作请求,对所述一个操作请求进行解析,得到属于所述目标事务的SQL语句,执行最新得到的属于所述目标事务的SQL语句;The second ORM framework is used for, after creating the target transaction, parsing each operation request to obtain an SQL statement belonging to the target transaction and executing the latest obtained SQL statement belonging to the target transaction;
    所述第一ORM框架,用于向所述ORM执行引擎发送提交语句或回滚语句;The first ORM framework is used to send a commit statement or a rollback statement to the ORM execution engine;
    所述第二ORM框架,用于若获取到所述提交语句,则指示所述数据库对所述目标事务中所有SQL语句的执行结果进行提交;若获取到所述回滚语句,则指示所述数据库对所述目标事务中所有SQL语句的执行结果进行回滚。The second ORM framework is used to instruct the database to commit the execution results of all SQL statements in the target transaction if the commit statement is obtained; and to instruct the database to roll back the execution results of all SQL statements in the target transaction if the rollback statement is obtained.
  3. 根据权利要求1所述的数据库访问系统,其特征在于,所述应用系统与所述ORM执行引擎通过远程过程调用GRPC协议进行通信。The database access system according to claim 1 is characterized in that the application system communicates with the ORM execution engine through a remote procedure call GRPC protocol.
  4. 根据权利要求1至3任一所述的数据库访问系统,其特征在于,所述ORM执行引擎还包括中间件模块,所述中间件模块与所述应用系统进行通信连接;The database access system according to any one of claims 1 to 3, characterized in that the ORM execution engine further comprises a middleware module, and the middleware module is in communication connection with the application system;
    所述中间件模块,用于在接收到所述第一ORM框架发送的所述操作请求后,在满足数据库访问条件的情况下,向所述第二ORM框架发送所述操作请求。The middleware module is used for, after receiving the operation request sent by the first ORM framework, sending the operation request to the second ORM framework if a database access condition is met.
  5. 根据权利要求4所述的数据库访问系统,其特征在于,所述操作请求携带对象标识和操作类型,所述对象标识用于标识所述操作请求所要访问的对象;The database access system according to claim 4, characterized in that the operation request carries an object identifier and an operation type, and the object identifier is used to identify the object to be accessed by the operation request;
    所述数据库访问条件包括以下多项中的至少一项:The database access condition includes at least one of the following:
    所述数据库的访问次数小于第一次数阈值;The number of accesses to the database is less than a first number threshold;
    所述操作请求所要访问的对象的访问次数小于第二次数阈值;The access count of the object to be accessed by the operation request is less than the second count threshold;
    所述应用系统具有所述操作请求所要访问的对象的访问权限;The application system has access rights to the object to be accessed by the operation request;
    所述应用系统具有所述数据库的访问权限;The application system has access rights to the database;
    所述操作请求中的所述操作类型是所述数据库允许对所述操作请求所要访问的对象进行的操作类型。The operation type in the operation request is an operation type that the database allows to be performed on the object to be accessed by the operation request.
  6. 根据权利要求1至3任一所述的数据库访问系统,其特征在于,所述操作请求携带对象标识和操作类型,所述数据库访问系统还包括缓存模块;The database access system according to any one of claims 1 to 3, characterized in that the operation request carries an object identifier and an operation type, and the database access system further comprises a cache module;
    所述第二ORM框架,用于在所述操作请求中的所述操作类型为查询类型的情况下,对所述操作请求进行哈希运算,得到哈希值;从所述缓存模块中查询与所述哈希值相同的key值,根据查询结果确定所述操作请求的请求结果。The second ORM framework is used to perform a hash operation on the operation request to obtain a hash value when the operation type in the operation request is a query type; query the key value that is the same as the hash value from the cache module, and determine the request result of the operation request based on the query result.
  7. 根据权利要求6所述的数据库访问系统,其特征在于,若所述查询结果为从所述缓存模块中查询到与所述哈希值相同的key值,则将所述缓存模块中与所述哈希值相同的key值所在的键值对中的value值确定为所述操作请求的请求结果。The database access system according to claim 6 is characterized in that if the query result is a key value identical to the hash value queried from the cache module, the value value in the key-value pair in the cache module where the key value identical to the hash value is located is determined as the request result of the operation request.
  8. 根据权利要求6所述的数据库访问系统,其特征在于,若所述查询结果为从所述缓存模块中未查询到与所述哈希值相同的key值,则对所述操作请求进行解析,得到所述SQL语句,执行所述SQL语 句,以访问所述数据库中的数据,得到所述SQL语句的执行结果作为所述操作请求的请求结果。The database access system according to claim 6 is characterized in that if the query result is that the key value identical to the hash value is not found in the cache module, the operation request is parsed to obtain the SQL statement, and the SQL statement is executed. statement to access the data in the database, and obtain the execution result of the SQL statement as the request result of the operation request.
  9. 根据权利要求8所述的数据库访问系统,其特征在于,所述第二ORM框架还用于生成目标键值对,将所述目标键值对存储至所述缓存模块,所述目标键值对中的key值为所述哈希值,所述目标键值对中的value值为所述SQL语句的执行结果。The database access system according to claim 8 is characterized in that the second ORM framework is also used to generate a target key-value pair, store the target key-value pair in the cache module, the key value in the target key-value pair is the hash value, and the value value in the target key-value pair is the execution result of the SQL statement.
  10. 根据权利要求7所述的数据库访问系统,其特征在于,所述缓存模块用于将键值对与键值对中的value值所属的对象的对象标识进行关联存储;The database access system according to claim 7, characterized in that the cache module is used to associate and store the key-value pair with the object identifier of the object to which the value in the key-value pair belongs;
    所述第二ORM框架,用于在所述操作请求中的所述操作类型为更新类型的情况下,删除所述缓存模块中与所述操作请求中的所述对象标识关联存储的所有键值对。The second ORM framework is used to delete all key-value pairs stored in the cache module in association with the object identifier in the operation request when the operation type in the operation request is an update type.
  11. 一种数据库访问方法,其特征在于,应用于关系对象映射ORM执行引擎,所述ORM执行引擎包括第二ORM框架,所述ORM执行引擎与应用系统进行通信连接,所述ORM执行引擎与数据库进行通信连接,所述应用系统包括第一ORM框架,所述方法包括:A database access method, characterized in that it is applied to a relational object mapping (ORM) execution engine, the ORM execution engine includes a second ORM framework, the ORM execution engine is communicatively connected to an application system, the ORM execution engine is communicatively connected to a database, the application system includes a first ORM framework, and the method includes:
    所述第二ORM框架获取所述第一ORM框架发送的操作请求,所述操作请求是所述第一ORM框架根据业务语句生成的,所述操作请求用于请求对所述数据库中的数据进行操作;The second ORM framework obtains an operation request sent by the first ORM framework, where the operation request is generated by the first ORM framework according to a business statement, and is used to request an operation to be performed on the data in the database;
    所述第二ORM框架对所述操作请求进行解析,得到结构化查询语言SQL语句;The second ORM framework parses the operation request to obtain a structured query language SQL statement;
    所述第二ORM框架执行所述SQL语句,以访问所述数据库中的数据,得到所述SQL语句的执行结果。The second ORM framework executes the SQL statement to access the data in the database and obtains the execution result of the SQL statement.
  12. 根据权利要求11所述的方法,其特征在于,所述ORM执行引擎还包括中间件模块,所述中间件模块与所述应用系统进行通信连接;The method according to claim 11, characterized in that the ORM execution engine further comprises a middleware module, and the middleware module is in communication connection with the application system;
    所述第二ORM框架获取所述第一ORM框架发送的操作请求,包括:The second ORM framework obtains the operation request sent by the first ORM framework, including:
    所述中间件模块接收所述第一ORM框架发送的所述操作请求,在满足数据库访问条件的情况下,向所述第二ORM框架发送所述操作请求。The middleware module receives the operation request sent by the first ORM framework, and sends the operation request to the second ORM framework when a database access condition is met.
  13. 根据权利要求12所述的方法,其特征在于,所述操作请求携带对象标识和操作类型,所述对象标识用于标识所述操作请求所要访问的对象;The method according to claim 12, characterized in that the operation request carries an object identifier and an operation type, and the object identifier is used to identify the object to be accessed by the operation request;
    所述数据库访问条件包括以下多项中的至少一项:The database access condition includes at least one of the following:
    所述数据库的访问次数小于第一次数阈值;The number of accesses to the database is less than a first number threshold;
    所述操作请求所要访问的对象的访问次数小于第二次数阈值;The access count of the object to be accessed by the operation request is less than the second count threshold;
    所述应用系统具有所述操作请求所要访问的对象的访问权限;The application system has access rights to the object to be accessed by the operation request;
    所述应用系统具有所述数据库的访问权限;The application system has access rights to the database;
    所述操作请求中的所述操作类型是所述数据库允许对所述操作请求所要访问的对象进行的操作类型。The operation type in the operation request is an operation type that the database allows to be performed on the object to be accessed by the operation request.
  14. 一种计算机设备,其特征在于,所述计算机设备包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行时实现如权利要求11至13任一项所述的方法。A computer device, characterized in that the computer device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the method according to any one of claims 11 to 13 when executed by the processor.
  15. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求11至13任一项所述的方法。 A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the method according to any one of claims 11 to 13.
PCT/CN2023/111555 2022-11-08 2023-08-07 Database access system and method, computer device, and storage medium WO2024098858A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211391763.4 2022-11-08
CN202211391763.4A CN115729912A (en) 2022-11-08 2022-11-08 Database access system, database access method, computer device, and storage medium

Publications (1)

Publication Number Publication Date
WO2024098858A1 true WO2024098858A1 (en) 2024-05-16

Family

ID=85294860

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/111555 WO2024098858A1 (en) 2022-11-08 2023-08-07 Database access system and method, computer device, and storage medium

Country Status (2)

Country Link
CN (1) CN115729912A (en)
WO (1) WO2024098858A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115729912A (en) * 2022-11-08 2023-03-03 杭州趣链科技有限公司 Database access system, database access method, computer device, and storage medium
CN117112538A (en) * 2023-09-05 2023-11-24 中电金信软件有限公司 Database operation method, database operation device, computer equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101004683A (en) * 2007-01-31 2007-07-25 华为技术有限公司 Method and device for accessing database
US20120054227A1 (en) * 2010-08-31 2012-03-01 International Business Machines Corporation Use-case based configuration of an object-relational mapping framework
CN107016016A (en) * 2016-10-10 2017-08-04 阿里巴巴集团控股有限公司 A kind of method and device of data processing
CN115168836A (en) * 2022-06-14 2022-10-11 天元大数据信用管理有限公司 Data permission isolation method based on ORM framework
CN115729912A (en) * 2022-11-08 2023-03-03 杭州趣链科技有限公司 Database access system, database access method, computer device, and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101004683A (en) * 2007-01-31 2007-07-25 华为技术有限公司 Method and device for accessing database
US20120054227A1 (en) * 2010-08-31 2012-03-01 International Business Machines Corporation Use-case based configuration of an object-relational mapping framework
CN107016016A (en) * 2016-10-10 2017-08-04 阿里巴巴集团控股有限公司 A kind of method and device of data processing
CN115168836A (en) * 2022-06-14 2022-10-11 天元大数据信用管理有限公司 Data permission isolation method based on ORM framework
CN115729912A (en) * 2022-11-08 2023-03-03 杭州趣链科技有限公司 Database access system, database access method, computer device, and storage medium

Also Published As

Publication number Publication date
CN115729912A (en) 2023-03-03

Similar Documents

Publication Publication Date Title
KR102141234B1 (en) Versioned hierarchical data structure within a distributed data store
WO2024098858A1 (en) Database access system and method, computer device, and storage medium
US20220067025A1 (en) Ordering transaction requests in a distributed database according to an independently assigned sequence
US20200050613A1 (en) Relational Blockchain Database
US11550763B2 (en) Versioning schemas for hierarchical data structures
US11574070B2 (en) Application specific schema extensions for a hierarchical data structure
US20210157823A1 (en) Blockchain Node and Transaction Method
US9244951B2 (en) Managing tenant-specific data sets in a multi-tenant environment
US9990224B2 (en) Relaxing transaction serializability with statement-based data replication
EP2797013B1 (en) Database update execution according to power management schemes
US9342572B2 (en) Workflow processing system and method with database system support
US20120036166A1 (en) Effective dating for table or relationship modifications
WO2023231665A1 (en) Distributed transaction processing method, system and device, and readable storage medium
WO2022095366A1 (en) Redis-based data reading method and apparatus, device, and readable storage medium
WO2019015364A1 (en) Method and device for executing structured query language (sql) instruction
US11100129B1 (en) Providing a consistent view of associations between independently replicated data objects
WO2024041022A1 (en) Database table alteration method and apparatus, device and storage medium
WO2023160095A1 (en) Method and system for implementing structured data storage and queries in blockchain system
US11797523B2 (en) Schema and data modification concurrency in query processing pushdown
CN116561137A (en) Transaction processing method, device, computer equipment and storage medium
US11657088B1 (en) Accessible index objects for graph data structures
US10997160B1 (en) Streaming committed transaction updates to a data store
US20220237151A1 (en) Fast and efficient storage system implemented with multiple cloud services
CN112905601A (en) Routing method and device for database sub-tables
US20240143566A1 (en) Data processing method and apparatus, and computing system