Sentence query method and device, electronic equipment and computer readable medium
By retrieving and concatenating structured query statements from the PostgreSQL database and performing batch processing when the connection status allows, the problems of long-term resource locking and data leakage are solved, resulting in performance improvement and enhanced security.
Patent Information
- Application Number
- CN202310508348.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-05
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2043-05-05
AI Technical Summary
PostgreSQL databases suffer from prolonged resource locking and data leakage when handling complex transactions, especially with large data volumes and high-density queries, leading to performance degradation and increased resource consumption.
By obtaining structured query statements, using logical processing functions to concatenate and encrypt them, dynamic query statements are generated. These statements are then processed in batches when the database connection status allows, skipping return value checks to improve performance.
It improves the performance of big data processing, reduces resource consumption, supports higher concurrency, and reduces the risk of data leakage.
Smart Images

Figure CN116775679B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of this disclosure relate to the field of computer technology, and more specifically to statement query methods, apparatus, electronic devices, and computer-readable media. Background Technology
[0002] Batch processing is a technique in databases for handling batches of relatively complex transactions. Currently, when processing transactions that include multiple sub-transactions, it's necessary to execute a function in a single run to handle multiple transactions. However, functions in PostgreSQL databases can only execute one transaction at a time.
[0003] When processing complex transactions in a PostgreSQL database, the following technical issues often arise:
[0004] First, when dealing with large amounts of data, functions in PostgreSQL databases can only close transactions when the calling process ends. This results in data rows being locked for a long time during processing. Once there are concurrent processing operations, other processes will be blocked. Furthermore, if a single transaction is too large, the program will consume more and more resources, and the processing performance will gradually decline.
[0005] Second, when the database stores a large amount of data with a high security level, directly using the original structured query statement to query the data may lead to data leakage. Summary of the Invention
[0006] The summary portion of this disclosure is intended to provide a brief overview of the concepts, which will be described in detail in the detailed description portion. This summary portion is not intended to identify key or essential features of the claimed technical solutions, nor is it intended to limit the scope of the claimed technical solutions.
[0007] Some embodiments of this disclosure provide statement query methods, apparatuses, electronic devices, and computer-readable media to address one or more of the technical problems mentioned in the background section above.
[0008] In a first aspect, some embodiments of this disclosure provide a statement query method, which includes: obtaining a structured query statement for a target object-relational database to obtain a query statement to be processed; using a logical processing function to concatenate the query statement to be processed to obtain a concatenated query statement; passing the concatenated query statement as an input parameter to a batch processing function; establishing a database connection according to the connection status of the target object-relational database; concatenating an empty data operation statement after the concatenated query statement to obtain a dynamic query statement; and calling a database connection function to perform query processing based on the dynamic query statement.
[0009] Secondly, some embodiments of this disclosure provide a statement query apparatus, comprising: an acquisition unit configured to acquire a structured query statement for a target object-relational database to obtain a query statement to be processed; a first concatenation unit configured to concatenate the query statement to be processed using a logic processing function to obtain a concatenated query statement; a batch processing unit configured to pass the concatenated query statement as input parameters to a batch processing function; an establishment unit configured to establish a database connection based on the connection status of the target object-relational database; a second concatenation unit configured to concatenate an empty data operation statement after the concatenated query statement to obtain a dynamic query statement; and a query unit configured to call a database connection function to perform query processing based on the dynamic query statement.
[0010] Thirdly, some embodiments of this disclosure provide an electronic device, including: one or more processors; and a storage device having one or more programs stored thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation of the first aspect above.
[0011] Fourthly, some embodiments of this disclosure provide a computer-readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the method described in any of the implementations of the first aspect above.
[0012] The above embodiments of this disclosure have the following beneficial effects: Through the statement query method of some embodiments of this disclosure, for batch query statements, the problem of long-term resource non-release is avoided by processing them one by one. This results in a significant performance improvement in big data processing. While appropriately controlling the batch submission volume, it can support higher concurrency and reduce the resource pressure on the database. Based on this, the statement query method of some embodiments of this disclosure first obtains the structured query statement for the target object-relational database to obtain the query statement to be processed. Thus, the structured query statement for the target object-relational database is obtained one by one. Then, the query statement to be processed is concatenated using a logical processing function to obtain the concatenated query statement. Next, the concatenated query statement is passed as an input parameter to the batch processing function. Then, a database connection is established according to the connection status of the target object-relational database. Next, an empty data operation statement is concatenated after the concatenated query statement to obtain a dynamic query statement. Thus, the judgment of the return value can be skipped, facilitating batch processing. Finally, the database connection function is called to perform query processing based on the dynamic query statement. Therefore, for batch query statements, processing them one by one avoids the problem of resources not being released for a long time. This can significantly improve the performance of big data processing. While appropriately controlling the batch submission volume, it can support higher concurrency and reduce the resource pressure on the database. Attached Figure Description
[0013] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and elements are not necessarily drawn to scale.
[0014] Figure 1 This is a flowchart of some embodiments of the statement query method according to this disclosure;
[0015] Figure 2 This is a schematic diagram of the structure of some embodiments of the statement query device disclosed herein;
[0016] Figure 3 This is a schematic diagram of the structure of an electronic device suitable for implementing some embodiments of the present disclosure. Detailed Implementation
[0017] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0018] It should also be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings. Unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other.
[0019] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0020] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0021] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0022] This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.
[0023] refer to Figure 1 The diagram illustrates a flow 100 of some embodiments of a statement query method according to the present disclosure. This statement query method includes the following steps:
[0024] Step 101: Obtain the structured query statement for the target object - relational database, and obtain the query statement to be processed.
[0025] In some embodiments, the execution body of the statement query method can obtain a structured query statement for the target object-relational database through a wired or wireless connection, and obtain the query statement to be processed.
[0026] As an example, the target object—the relational database—could be a PostgreSQL database. The structured query statement could be an SQL statement (Structured Query Language).
[0027] Step 102: Use the logic processing function to concatenate the query statement to be processed, and obtain the concatenated query statement.
[0028] In some embodiments, the execution entity uses a logical processing function to concatenate the query statement to be processed to obtain a concatenated query statement, which may include the following steps:
[0029] The first step is to transform the data in the structured query statement according to its data type, resulting in the transformed query statement. This transformation can be achieved using a pre-defined data type conversion table.
[0030] The second step is to replace the empty values in the query statement after the data conversion with the target string to obtain the query statement to be processed.
[0031] As an example, the target character mentioned above could be $$. In practice, the target character can be set according to the actual application needs; there are no restrictions here.
[0032] In some optional implementations of certain embodiments, before the execution entity performs the concatenation process on the query statement to be processed using the logical processing function to obtain the concatenated query statement, it may also perform the following steps:
[0033] The first step is to determine the statement type of the query statement to be processed. This can be done by identifying the statement type based on the keywords that characterize the statement type within the query statement itself.
[0034] As an example, the statement type of the above query statement to be processed can be query, insert, delete, etc.
[0035] The second step involves encrypting the field types in the query statement based on the preset field mapping information and the determined statement type, thereby obtaining the encrypted statement. The field mapping information may include at least one replacement message. The replacement message included in the field mapping information may include both the original field and the replacement field.
[0036] The third step is to store the encrypted statements mentioned above.
[0037] The fourth step involves combining the encrypted statement with the associated log file to obtain exception file information in response to the detected database anomaly. This exception information can be used to detect database anomalies.
[0038] The fifth step is to send the aforementioned abnormal file information to the target terminal. The target terminal can be used to display the abnormal file information.
[0039] Optionally, the execution entity may encrypt the field types in the query statement to be processed based on preset field mapping information and the determined statement type, thereby obtaining an encrypted statement. This may include the following steps:
[0040] The first step is to treat each field in the query statement above as a field to be matched and perform the following matching steps:
[0041] The first matching step involves determining whether there is replacement information in the aforementioned field mapping information that matches the aforementioned field to be matched. This replacement information in the aforementioned field mapping information that matches the aforementioned field to be matched can include replacement information where the original field is the same as the aforementioned field to be matched.
[0042] The second matching step involves determining the replacement information that matches the field to be matched in the above field mapping information as the target replacement information.
[0043] In the third matching step, in response to determining that there is replacement information in the above field mapping information that matches the above field to be matched, the above field to be matched in the above query statement to be processed is replaced with the replacement field in the above target replacement information.
[0044] The second step is to determine the replacement query statement in response to the fact that each field to be matched in the above query statement has been matched.
[0045] Optionally, the execution entity may further include the following steps: encrypting the field types in the query statement to be processed based on preset field mapping information and the determined statement type of the query statement to be processed, to obtain an encrypted statement.
[0046] The first step is to determine that the above replacement query statement is a query statement, and then determine each query condition field in the above replacement query statement as the query condition field to be mapped, thus obtaining the set of query condition fields to be mapped.
[0047] The second step involves performing the following mapping process on each query condition field in the aforementioned set of query condition fields to be mapped, based on the pre-set encrypted mapping information:
[0048] The first mapping step involves determining whether the encrypted mapping information includes encrypted information that matches the query condition field to be mapped. The encrypted mapping information may include at least one piece of encrypted information. The encrypted information in the encrypted mapping information may include both the original field and the encrypted field. The encrypted information in the encrypted mapping information that matches the query condition field to be mapped may include encrypted information where the original field is the same as the query condition field to be mapped.
[0049] The second mapping step, in response to determining that the encrypted mapping information includes encrypted information that matches the query condition field to be mapped, determines the encrypted information in the encrypted mapping information that matches the query condition field to be mapped as the target encrypted information.
[0050] The third mapping step involves replacing the query condition fields to be mapped in the set of query condition fields to be mapped with the encrypted fields in the target encrypted information.
[0051] The third step is to determine each replaced query condition field to be mapped as a mapping query condition field, thus obtaining a set of mapping query condition fields.
[0052] The fourth step is to replace each query condition field in the above replacement query statement with the corresponding mapping query condition field in the above mapping query condition field set to obtain the initial encrypted query statement.
[0053] The fifth step is to encrypt the initial encrypted query statement to obtain the encrypted statement. This encryption can be achieved using algorithms such as symmetric encryption, asymmetric encryption, and linear hash encryption.
[0054] The steps described above, prior to concatenating the query statement to be processed using a logical processing function to obtain the concatenated query statement, are an inventive point of this disclosure. This addresses the second technical problem mentioned in the background: "When the database stores a large amount of data with a high security level, directly using the original structured query statement for data querying may lead to data leakage." The factors leading to this technical problem are often as follows: when the database stores a large amount of data with a high security level, failure to take confidentiality measures can easily lead to data leakage. Solving these factors can improve the confidentiality of data in the database. To achieve this effect, this disclosure, based on the determined statement type of the query statement to be processed and preset field mapping information and encryption mapping information, replaces the fields included in the query statement to be processed, obtaining an initial encrypted query statement. The initial encrypted query statement is then further encrypted. Therefore, by replacing the fields included in the query statement to be processed using preset field mapping information and encryption mapping information, the possibility of leakage of confidential fields is reduced, and the security of the data stored in the database is improved.
[0055] Step 103: The concatenated query statement is passed as an input parameter to the batch processing function.
[0056] In some embodiments, the execution entity may pass the concatenated query statement as an input parameter to the batch processing function.
[0057] Step 104: Establish a database connection based on the connection status of the target object and the relational database.
[0058] In some embodiments, the execution entity establishes a database connection based on the connection status of the target object-relational database, which may include the following steps:
[0059] The first step is to detect the connection status between the target object and the relational database based on the connection status parameters in the concatenated query statement. These connection status parameters can be used to identify the connection status between the target object and the relational database.
[0060] The second step involves establishing a database connection in response to the determination that the connection status between the target object and the relational database meets a first preset condition. This first preset condition can be that the connection status between the target object and the relational database is in a default state.
[0061] In some alternative implementations of certain embodiments, the execution entity may also close the database connection, commit the transaction, or roll back the transaction in response to determining the connection status of the target object-relational database, and terminate the statement query operation.
[0062] Step 105: After concatenating the query statement, append an empty data operation statement to obtain the dynamic query statement.
[0063] In some embodiments, the execution entity can append an empty data manipulation statement after the concatenated query statement to obtain a dynamic query statement. The empty data manipulation statement can be an empty DML (Data Manipulation Language) statement.
[0064] This can be used to skip the return value check of the dblink_exec function, making function calls compatible during batch processing.
[0065] In some optional implementations of certain embodiments, before the execution entity appends an empty data operation statement to the concatenated query statement to obtain the dynamic query statement, it may also perform the following steps:
[0066] The first step is to determine whether the concatenated query statement is empty.
[0067] The second step is to generate an exception message and terminate the query operation in response to the determination that the above concatenated query statement is empty.
[0068] Step 106: Call the database connection function to perform query processing based on the dynamic query statement.
[0069] In some embodiments, the aforementioned execution entity may call a database connection function to perform query processing based on the aforementioned dynamic query statement.
[0070] As an example, the dblink_exec function can be called to process dynamic query statements.
[0071] In some alternative implementations of certain embodiments, the execution entity may, in response to determining that the database connection function has completed the query processing based on the dynamic query statement, re-acquire the structured query statement for the target object-relational database and continue executing the query operation.
[0072] Therefore, instead of performing an independent transaction termination operation, a new structured query statement is retrieved and processed in a loop.
[0073] The above embodiments of this disclosure have the following beneficial effects: Through the statement query method of some embodiments of this disclosure, for batch query statements, the problem of long-term resource non-release is avoided by processing them one by one. This results in a significant performance improvement in big data processing. While appropriately controlling the batch submission volume, it can support higher concurrency and reduce the resource pressure on the database. Based on this, the statement query method of some embodiments of this disclosure first obtains the structured query statement for the target object-relational database to obtain the query statement to be processed. Thus, the structured query statement for the target object-relational database is obtained one by one. Then, the query statement to be processed is concatenated using a logical processing function to obtain the concatenated query statement. Next, the concatenated query statement is passed as an input parameter to the batch processing function. Then, a database connection is established according to the connection status of the target object-relational database. Next, an empty data operation statement is concatenated after the concatenated query statement to obtain a dynamic query statement. Thus, the judgment of the return value can be skipped, facilitating batch processing. Finally, the database connection function is called to perform query processing based on the dynamic query statement. Therefore, for batch query statements, processing them one by one avoids the problem of resources not being released for a long time. This can significantly improve the performance of big data processing. While appropriately controlling the batch submission volume, it can support higher concurrency and reduce the resource pressure on the database.
[0074] Further reference Figure 2 As an implementation of the methods shown in the above figures, this disclosure provides some embodiments of a statement query device, which are similar to... Figure 1 Corresponding to the method embodiments shown, the device can be specifically applied to various electronic devices.
[0075] like Figure 2As shown, the statement query device 200 in some embodiments includes: an acquisition unit 201, a first concatenation unit 202, a batch processing unit 203, an establishment unit 204, a second concatenation unit 205, and a query unit 206. The acquisition unit 201 is configured to acquire a structured query statement for a target object-relational database to obtain a query statement to be processed; the first concatenation unit 202 is configured to concatenate the query statement to be processed using a logic processing function to obtain a concatenated query statement; the batch processing unit 203 is configured to pass the concatenated query statement as input to a batch processing function; the establishment unit 204 is configured to establish a database connection based on the connection status of the target object-relational database; the second concatenation unit 205 is configured to concatenate an empty data operation statement after the concatenated query statement to obtain a dynamic query statement; and the query unit 206 is configured to call a database connection function to perform query processing based on the dynamic query statement.
[0076] It is understandable that the units recorded in the statement query device 200 and the reference Figure 1 The steps in the described method correspond to each other. Therefore, the operations, features, and beneficial effects described above for the method also apply to the statement query device 200 and the units contained therein, and will not be repeated here.
[0077] The following is for reference. Figure 3 It shows a schematic diagram of the structure of an electronic device 300 suitable for implementing some embodiments of the present disclosure. Figure 3 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of this disclosure.
[0078] like Figure 3 As shown, the electronic device 300 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 302 or a program loaded from a storage device 308 into a random access memory (RAM) 303. The RAM 303 also stores various programs and data required for the operation of the electronic device 300. The processing unit 301, ROM 302, and RAM 303 are interconnected via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0079] Typically, the following devices can be connected to I / O interface 305: input devices 306 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 307 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; and communication devices 309. Communication device 309 allows electronic device 300 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 3 An electronic device 300 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively. Figure 3 Each box shown can represent a device or multiple devices as needed.
[0080] In particular, according to some embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, some embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 309, or installed from storage device 308, or installed from ROM 302. When the computer program is executed by processing device 301, it performs the functions defined in the methods of some embodiments of this disclosure.
[0081] It should be noted that, in some embodiments of this disclosure, the computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In some embodiments of this disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In some embodiments of this disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0082] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0083] The aforementioned computer-readable medium may be included within the aforementioned electronic device; or it may exist independently and not assembled into the electronic device. The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: acquire a structured query statement for a target object-relational database to obtain a query statement to be processed; concatenate the query statement to be processed using a logical processing function to obtain a concatenated query statement; pass the concatenated query statement as input parameters to a batch processing function; establish a database connection based on the connection status of the target object-relational database; append an empty data operation statement to the concatenated query statement to obtain a dynamic query statement; and call a database connection function to perform query processing based on the dynamic query statement.
[0084] Computer program code for performing operations of some embodiments of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0085] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0086] The units described in some embodiments of this disclosure can be implemented in software or hardware. The described units can also be housed in a processor; for example, a processor may be described as including an acquisition unit, a first concatenation unit, a batch processing unit, a creation unit, a second concatenation unit, and a query unit. The names of these units do not necessarily limit the specific unit itself; for example, the acquisition unit may also be described as "acquiring a structured query statement for a target object—a relational database—to obtain a query statement unit to be processed."
[0087] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
Claims
1. A statement query method, comprising: Obtain the structured query statement for the target object—a relational database—to obtain the query statement to be processed; The query statement to be processed is concatenated using a logical processing function to obtain a concatenated query statement, including: Based on the different data types, the data in the query statement to be processed is transformed, resulting in the query statement after data transformation; Replace the null values in the query statement after data conversion with the target string to obtain the query statement to be processed; The concatenated query statement is passed as an input parameter to the batch processing function; Establish a database connection based on the connection status of the target object-relational database; append an empty data operation statement after the concatenated query statement to obtain a dynamic query statement; The database connection function is invoked to perform query processing based on the dynamic query statement.
2. The method according to claim 1, wherein, The step of establishing a database connection based on the connection status of the target object-relational database includes: Based on the connection status input parameters in the concatenated query statement, detect the connection status of the target object-relational database. In response to determining that the connection status of the target object-relational database meets the first preset condition, a database connection is established.
3. The method according to claim 2, wherein, The method further includes: In response to determining the connection status of the target object-relational database, indicating whether to close the database connection, commit the transaction, or roll back the transaction, the statement query operation is terminated.
4. The method according to claim 3, wherein, Before concatenating an empty data operation statement after the concatenated query statement to obtain a dynamic query statement, the method further includes: Determine whether the concatenated query statement is empty; In response to determining that the concatenated query statement is empty, an exception message is generated, and the query operation is terminated.
5. The method according to claim 4, wherein, The method further includes: In response to determining that the database connection function has completed the query processing based on the dynamic query statement, a new structured query statement for the target object-relational database is obtained, and the query operation continues.
6. The method according to claim 5, wherein, Before using a logical processing function to concatenate the query statement to be processed to obtain the concatenated query statement, the method further includes: Determine the statement type of the query statement to be processed; Based on the preset field mapping information and the determined statement type of the query statement to be processed, the field types in the query statement to be processed are encrypted to obtain an encrypted statement. The field mapping information includes at least one replacement information, and the replacement information included in the field mapping information includes the original field and the replacement field. The encrypted statement is stored; In response to the detection of a database anomaly, the encrypted statement is combined with the log file associated with the encrypted statement to obtain anomaly file information; The abnormal file information is sent to the target terminal.
7. A statement query device, comprising: The retrieval unit is configured to retrieve a structured query statement for the target object—a relational database—and obtain the query statement to be processed. The first concatenation unit is configured to use a logic processing function to concatenate the query statement to be processed, resulting in a concatenated query statement, including: Based on the different data types, the data in the query statement to be processed is transformed, resulting in the query statement after data transformation; Replace the null values in the query statement after data conversion with the target string to obtain the query statement to be processed; The batch processing unit is configured to pass the concatenated query statement as an input parameter to the batch processing function. The establishment unit is configured to establish a database connection based on the connection status of the target object-relational database; The second splicing unit is configured to splice an empty data operation statement after the spliced query statement to obtain a dynamic query statement. The query unit is configured to call a database connection function to perform query processing based on the dynamic query statement.
8. An electronic device, comprising: One or more processors; Storage device, on which one or more programs are stored, When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-6.
9. A computer-readable medium having a computer program stored thereon, wherein, When the program is executed by the processor, it implements the method as described in any one of claims 1-6.
Citation Information
Patent Citations
Method and device for updating database
CN103345501A
SQL-based data query method, terminal and server
CN115809259A