A SQL-based data processing method, device, equipment and medium

By parsing and processing functions in SQL commands, and utilizing lazy connection pools and cursor objects, the problem of code complexity and high maintenance costs caused by ORM tools is solved, thereby improving flexibility and efficiency.

CN116126895BActive Publication Date: 2026-03-31DAGUAN TECH (BEIJING) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-13
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

Existing technologies, when faced with complex data processing queries, result in high code complexity, low code readability, and security vulnerabilities when using ORM tools. They also fail to meet flexibility requirements and have high maintenance costs.

Method used

By obtaining the instructions to be executed, parsing out the function and determining the executor, judging the state of the lazy connection pool, connecting to the target registered executor and parsing the cursor object, performing parsing processing to return the results, the complexity of direct hard coding is reduced.

Benefits of technology

It improves the flexibility of SQL data processing, reduces code processing complexity, enhances code readability and data query efficiency, and reduces maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116126895B_ABST
    Figure CN116126895B_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on SQL data processing method, device, equipment and medium. By obtaining the instruction to be executed, function in the instruction to be executed is parsed, and the executor corresponding to function is determined;When the target registered executor in the manager pre-constructed is hit by the executor, it is judged whether the lazy connection pool corresponding to the manager is in the connection state;If not, connect with the target registered executor in the lazy connection pool, and parse the cursor object corresponding to the instruction to be executed;The target analysis result is determined by parsing processing to cursor object, and the target analysis result is fed back to user. The problem that direct hard coding cannot meet the flexibility of different scenes and the high maintenance cost is solved, the flexibility of SQL data processing is improved, the complexity of code processing is reduced, the readability of code is improved, the maintenance cost is reduced, and the efficiency of data query is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a data processing method, apparatus, device, and medium based on SQL. Background Technology

[0002] To cope with increasingly complex business scenarios, the number of business tables in databases is also increasing. To implement a specific data query function, multiple tables often need to be joined for multi-table queries. Furthermore, directly combining SQL (Structured Query Language) with programming languages ​​has the following main drawbacks: hard-coding cannot meet the needs of scenarios requiring flexibility; maintenance costs are high for those unfamiliar with SQL; SQL injection vulnerabilities may exist, posing security risks; the query result structure is complex, requiring many operations before retrieving a specific result; and it cannot be directly mapped to objects in the programming language, making serialization difficult.

[0003] In the process of developing this invention, the inventors discovered the following shortcomings in the existing technology: Currently, the common solution is to use ORM (Object Relational Mapping) tools. First, objects are constructed that correspond one-to-one with tables in the database. Then, based on the query methods provided by the ORM tool, the corresponding SQL query statements are manually and logically converted into query methods in the programming language. The ORM tool then translates these query methods back into SQL statements, which are then passed to the database for querying. After the query is completed, the ORM tool automatically converts the query results with pre-defined query objects for use by programmers. However, for complex data processing queries, the complexity of writing query methods using ORM tools increases exponentially, leading to increased code complexity and low code readability. Summary of the Invention

[0004] This invention provides a SQL-based data processing method, apparatus, device, and medium to improve the flexibility of SQL-based data processing and reduce the complexity of code processing.

[0005] According to one aspect of the present invention, a data processing method based on SQL is provided, comprising:

[0006] Obtain the instruction to be executed, parse out the function in the instruction to be executed, and determine the executor corresponding to the function;

[0007] When the executor hits the target registered executor in the pre-built manager, it is determined whether the lazy connection pool corresponding to the manager is in a connected state;

[0008] If not, then connect with the target registered executor in the lazy connection pool and parse out the cursor object corresponding to the instruction to be executed;

[0009] The cursor object is parsed to determine the target parsing result, and the target parsing result is fed back to the user.

[0010] According to another aspect of the present invention, an SQL-based data processing apparatus is provided, comprising:

[0011] An executor determination module is used to acquire the instruction to be executed, parse out the function in the instruction to be executed, and determine the executor corresponding to the function;

[0012] The connection status determination module is used to determine whether the lazy connection pool corresponding to the manager is in a connected state when the executor hits the target registered executor in the pre-built manager.

[0013] The cursor object parsing module is used to connect with the target registered executor in the lazy connection pool if the lazy connection pool corresponding to the manager is not in a connected state, and parse out the cursor object corresponding to the instruction to be executed.

[0014] The target parsing result feedback module is used to parse the cursor object, determine the target parsing result, and feed the target parsing result back to the user.

[0015] According to another aspect of the present invention, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the SQL-based data processing method described in any embodiment of the present invention.

[0016] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the SQL-based data processing method according to any embodiment of the present invention.

[0017] The technical solution of this invention obtains the instruction to be executed, parses the function in the instruction, and determines the executor corresponding to the function. When the executor hits the target registered executor in the pre-built manager, it determines whether the lazy connection pool corresponding to the manager is in a connected state. If not, it connects with the target registered executor in the lazy connection pool and parses the cursor object corresponding to the instruction to be executed. The cursor object is parsed to determine the target parsing result, and the target parsing result is fed back to the user. This solves the problems of direct hard coding failing to meet the flexibility of different scenarios and high maintenance costs, improves the flexibility of SQL-based data processing, reduces code processing complexity, improves code readability, reduces maintenance costs, and improves data query efficiency.

[0018] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a flowchart of a data processing method based on SQL according to Embodiment 1 of the present invention;

[0021] Figure 2 This is a flowchart of another SQL-based data processing method provided according to Embodiment 2 of the present invention;

[0022] Figure 3 This is a schematic diagram of the structure of a SQL-based data processing device according to Embodiment 3 of the present invention;

[0023] Figure 4 This is a schematic diagram of the structure of an electronic device provided according to Embodiment 4 of the present invention. Detailed Implementation

[0024] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0025] It should be noted that the terms "target," "current," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0026] Example 1

[0027] Figure 1 The flowchart of an SQL-based data processing method is provided in Embodiment 1 of the present invention. This embodiment is applicable to the case of data processing and querying based on SQL. The method can be executed by an SQL-based data processing device, which can be implemented in hardware and / or software.

[0028] Correspondingly, such as Figure 1 As shown, the method includes:

[0029] S110. Obtain the instruction to be executed, parse out the function in the instruction to be executed, and determine the executor corresponding to the function.

[0030] The instruction to be executed can be an instruction that requires data processing and querying. One or more functions can be parsed from the instruction to be executed, and the executor can be further determined based on the parsed functions.

[0031] Alternatively, functions can be pre-packaged functions stored in the manager. Each function corresponds to an executor, which needs to be loaded through the functions in the manager.

[0032] Specifically, for different database types, inheritance can be achieved through the pre-defined MySQLExecuter, PostgreExecuter, and SQLiteExecuter functions. After inheritance, query functions can be declared arbitrarily within the scope. No specific operation logic code needs to be written in the function; you only need to add a decorator to the corresponding function, with the decorator parameter being the SQL statement to be executed or the path to the SQL file.

[0033] Optionally, after obtaining the instruction to be executed, parsing out the function in the instruction to be executed, and determining the executor corresponding to the function, the method further includes: if the executor does not match the target registered executor in the pre-built manager, then the instruction to be executed is discarded, and the instruction that failed to match the executor is fed back to the user.

[0034] The target registration executor can be the executor corresponding to each encapsulated function. The manager contains multiple target registration executors, and the target registration executors are loaded and processed through the manager function.

[0035] In this embodiment, if the executor corresponding to the parsed function does not match the target registered executor, it means that the function in the instruction to be executed does not correspond to a pre-encapsulated function in the manager. Therefore, the function in the manager cannot be used directly, and the instruction to be executed needs to be discarded. The instruction that failed to match the executor is then fed back to the user, who then performs manual processing.

[0036] The advantage of this setup is that it allows for more accurate processing of instructions by determining whether the executor matches a pre-built target registered executor in the manager. If no target registered executor is matched, the issue is returned to the user for processing, thus improving the efficiency of data processing and querying and saving labor costs.

[0037] S120. When the executor hits the target registered executor in the pre-built manager, determine whether the lazy connection pool corresponding to the manager is in a connected state.

[0038] The lazy connection pool can be a connection pool in the manager, which stores multiple encapsulated functions and the corresponding target registration executors.

[0039] In this embodiment, after determining that the executor hits the target registered executor in the pre-built manager, it is necessary to further determine whether the lazy connection pool corresponding to the manager is in a connected state. If it is in a connected state, it means that the relevant target registered executor can be called directly; if it is not in a connected state, it means that there is no connection with the target registered executor in the current manager, so the target registered executor cannot be called directly and needs to be connected before it can be called.

[0040] S130. If not, connect to the target registered executor in the lazy connection pool and parse out the cursor object corresponding to the instruction to be executed.

[0041] The cursor object can be an iterator to the query result set. Specifically, Connection() is a network connection to the database, and its real purpose is to return a cursor.

[0042] In this embodiment, if the lazy connection pool corresponding to the manager is not in a connected state, it is necessary to connect with the target registered executor in the lazy connection pool and manage the connection object. After the connection is established, the cursor object corresponding to the instruction to be executed can be parsed out.

[0043] S140. The cursor object is parsed to determine the target parsing result, and the target parsing result is fed back to the user.

[0044] The target parsing result can be the parsing result obtained by parsing the cursor object.

[0045] In this embodiment, when parsing the cursor object, a transaction needs to be actively created, and the transaction is committed or rolled back depending on the SQL execution result. Furthermore, the execution result is obtained through the chained method calls (e.g., the fetch method) built into the cursor object. After obtaining the result, different operations are performed depending on the model mapping object in the executor.

[0046] Optionally, the step of parsing the cursor object to determine the target parsing result includes: obtaining the chained call method corresponding to the cursor object, and determining the initial parsing result based on the chained call method; determining whether the model mapping object corresponding to the initial parsing result is a custom object in the pre-built manager; if yes, processing the initial parsing result according to the pre-set field type conversion verification method corresponding to the custom object to determine the target parsing result; if no, determining that the model mapping object corresponding to the initial parsing result is an Object object, obtaining the field name by parsing the cursor object, and assigning a value to the Object object based on the field name to determine the target parsing result.

[0047] Method chaining, or method call chaining, literally means a coding method that links a series of operations or function methods together like a chain. For example, in Python, a simple method chain is implemented by constructing class methods that return the object itself or its class.

[0048] The initial parsing result can be obtained through chained method calls, such as the `fetch` method. The model mapping object can be determined for each initial parsing result based on the target registered executor. Custom objects can be multiple objects from encapsulated functions, stored in the manager's lazy connection pool.

[0049] Additionally, field type conversion verification methods can perform field type conversion and verification. Specifically, based on the field type conversion verification method, the corresponding field values ​​can be parsed and placed into the corresponding fields, further determining the target parsing result. The Object can be an object that does not exist in the manager's lazy connection pool; it is the default target object.

[0050] Specifically, if the model mapping object corresponding to the initial parsing result matches a custom object in the pre-built manager, the field type will be converted and validated according to the field type conversion and validation method set during the customization process, and the corresponding value will be put into the corresponding field to further determine the target parsing result.

[0051] Furthermore, if the model mapping object is the default Object object, the properties of the Object object will be added and assigned values ​​by the field names parsed from the cursor object, thereby determining the target parsing result.

[0052] The advantage of this setting is that by determining whether the model mapping object corresponding to the initial parsing result is a custom object in the pre-built manager or an Object object, different parsing methods can be adopted to obtain the corresponding target parsing result. This allows for more comprehensive result parsing and processing, improving the flexibility of SQL-based data processing.

[0053] The technical solution of this invention obtains the instruction to be executed, parses the function in the instruction, and determines the executor corresponding to the function. When the executor hits the target registered executor in the pre-built manager, it determines whether the lazy connection pool corresponding to the manager is in a connected state. If not, it connects with the target registered executor in the lazy connection pool and parses the cursor object corresponding to the instruction to be executed. The cursor object is parsed to determine the target parsing result, and the target parsing result is fed back to the user. This solves the problems of direct hard coding failing to meet the flexibility of different scenarios and high maintenance costs, improves the flexibility of SQL-based data processing, reduces code processing complexity, improves code readability, reduces maintenance costs, and improves data query efficiency.

[0054] Example 2

[0055] Figure 2 This is a flowchart of another SQL-based data processing method provided in Embodiment 2 of the present invention. This embodiment is based on the above embodiments and optimized. In this embodiment, before obtaining the instruction to be executed, parsing out the function in the instruction to be executed, and determining the executor corresponding to the function, it also includes a specific operation process for constructing the manager.

[0056] Correspondingly, such as Figure 2 As shown, the method includes:

[0057] S210. Obtain the standard function, encapsulate the standard function, and determine the target executor corresponding to the standard function.

[0058] Standard functions can be functions that can process instructions or encapsulate predefined functions. Specifically, standard functions can include MySQLExecuter, PostgreExecuter, or SQLiteExecuter functions.

[0059] In this embodiment, the executor needs to be declared first. For different database types, it can be inherited through the preset MySQLExecuter function, PostgreExecuter function, or SQLiteExecuter function. After inheritance, any query function can be declared within the scope. No specific operation logic code needs to be written in the function. You only need to add a decorator to the corresponding function. The decorator parameter is the SQL statement to be executed or the path of the SQL file.

[0060] S220. Obtain at least one standard object corresponding to the standard function, and match the fields corresponding to the standard object with the properties of the mapping object model class to determine the custom object.

[0061] The standard object can be multiple standard objects included in the standard function. Each standard object can be matched with the properties of the mapping object model class to determine the corresponding custom object.

[0062] Additionally, the mapping object model class attributes can specify model class attributes for different standard objects. Based on these attributes, the standard objects are processed to obtain the corresponding custom objects. In this embodiment, it is necessary to declare a mapping object model class, map the fields to be mapped in the database to the attributes of the model class one by one, and specify the data type of the mapping object model class attributes to facilitate subsequent validation and type conversion, thereby obtaining the corresponding custom objects.

[0063] S230. Instantiate the target registration executor and the custom object, and complete the construction of the manager.

[0064] The manager can include a lazy connection pool, which contains multiple functions and multiple custom objects. Specifically, the target executor needs to be instantiated, and the custom objects also need to be instantiated to obtain the corresponding instantiated results and build the manager.

[0065] In this embodiment, it is necessary to instantiate the target registration executor and also to instantiate the custom object. After instantiation, the result is more accurate and standardized, thus enabling the construction of a more efficient manager.

[0066] Optionally, the instantiation of the target executor and the custom object to complete the manager construction includes: instantiating the target executor to determine a manager function dictionary; instantiating the custom object to determine a manager object; and storing the manager function dictionary and the manager object in a lazy connection pool to complete the manager construction.

[0067] The manager function dictionary can be a dictionary that stores the names of mapped object model classes and functions. The manager object can be an object obtained by instantiating a custom object. The lazy connection pool can be a connection pool that exists within the manager, and the lazy connection pool includes the manager function dictionary and the manager object.

[0068] In this embodiment, the target registration executor needs to be instantiated. Specifically, a target registration executor object needs to be created. During instantiation, the mapping object model of the life can be optionally passed as a parameter. If not passed, an Object object without attributes is used as the default model mapping.

[0069] Additionally, the management class needs to be instantiated and management objects created. During this process, database connection information needs to be provided. Once provided, the management object will test the connection and create a lazy connection pool. After the manager object is instantiated, the executor needs to be loaded via the manager function.

[0070] Optionally, the instantiation process of the target executor and the determination of the manager function dictionary includes: creating a target executor object based on the target executor and determining the initial custom object parameters corresponding to the target executor object; determining whether the initial custom object parameters are SQL file paths; if so, reading the SQL statement corresponding to the parsed target SQL file path and determining the manager function dictionary; if not, reading the SQL statement based on the initial custom object parameters and determining the manager function dictionary.

[0071] The target executor object can be the object corresponding to the target executor. Specifically, the target executor object can correspond to the initial custom object parameters. The initial custom object parameters can include the SQL file path or the SQL statement.

[0072] Additionally, the SQL file path can be the path where the file is stored. The SQL statement can be determined based on the file storage path. The SQL statement is a language used to manipulate the database. By parsing the SQL statement, the SQL statement and the mapped object model class can be stored as values ​​along with the function name in the manager's function dictionary.

[0073] In this embodiment, it is necessary to determine whether the initial custom object parameter is an SQL file path to read the SQL statement, or to read the SQL statement through the file path. This allows for more accurate and flexible data processing of the SQL, improves code readability, and reduces maintenance costs.

[0074] Optionally, reading the SQL statement and determining the manager function dictionary includes: determining the mapping object model class attributes based on the initial custom object parameters; and storing the SQL statement and the mapping object model class attributes as dictionary values ​​in the manager function dictionary.

[0075] In this embodiment, it is necessary to further parse the initial custom object parameters to determine the mapping object model class attributes. This allows the mapping object model class attributes and SQL statements to be stored together in the manager function dictionary, which enables more accurate SQL data processing and improves the accuracy and flexibility of data processing.

[0076] S240. Obtain the instruction to be executed, parse out the function in the instruction to be executed, and determine the executor corresponding to the function.

[0077] S250. When the executor hits the target registered executor in the pre-built manager, determine whether the lazy connection pool corresponding to the manager is in a connected state.

[0078] S260. If not, then connect with the target registered executor in the lazy connection pool and parse out the cursor object corresponding to the instruction to be executed.

[0079] S270. The cursor object is parsed to determine the target parsing result, and the target parsing result is fed back to the user.

[0080] The technical solution of this invention involves: acquiring a standard function, encapsulating the standard function, and determining the target executor corresponding to the standard function; acquiring at least one standard object corresponding to the standard function, and matching the fields corresponding to the standard object with the mapping object model class attributes to determine a custom object; instantiating the target executor and the custom object to construct a manager; acquiring the instruction to be executed, parsing the function in the instruction to be executed, and determining the executor corresponding to the function; when the executor hits the target executor in the pre-built manager, determining whether the lazy connection pool corresponding to the manager is in a connected state; if not, connecting with the target executor in the lazy connection pool and parsing the cursor object corresponding to the instruction to be executed; parsing the cursor object, determining the target parsing result, and feeding the target parsing result back to the user. This improves the flexibility of SQL-based data processing, reduces the complexity of code processing, improves code readability, reduces maintenance costs, improves the efficiency of data querying, and improves the accuracy of data processing.

[0081] Example 3

[0082] Figure 3 This is a schematic diagram of a data processing device based on SQL provided in Embodiment 3 of the present invention. The SQL-based data processing device provided in this embodiment can be implemented by software and / or hardware, and can be configured in a terminal device or server to implement a SQL-based data processing method according to the embodiments of the present invention. Figure 3 As shown, the device includes: an actuator determination module 310, a connection status judgment module 320, a cursor object parsing module 330, and a target parsing result feedback module 340.

[0083] The executor determination module 310 is used to obtain the instruction to be executed, parse out the function in the instruction to be executed, and determine the executor corresponding to the function.

[0084] The connection status determination module 320 is used to determine whether the lazy connection pool corresponding to the manager is in a connected state when the executor hits the target registered executor in the pre-built manager.

[0085] The cursor object parsing module 330 is used to connect with the target registered executor in the lazy connection pool if the lazy connection pool corresponding to the manager is not in a connected state, and parse out the cursor object corresponding to the instruction to be executed.

[0086] The target parsing result feedback module 340 is used to parse the cursor object, determine the target parsing result, and feed the target parsing result back to the user.

[0087] The technical solution of this invention obtains the instruction to be executed, parses the function in the instruction, and determines the executor corresponding to the function. When the executor hits the target registered executor in the pre-built manager, it determines whether the lazy connection pool corresponding to the manager is in a connected state. If not, it connects with the target registered executor in the lazy connection pool and parses the cursor object corresponding to the instruction to be executed. The cursor object is parsed to determine the target parsing result, and the target parsing result is fed back to the user. This solves the problems of direct hard coding failing to meet the flexibility of different scenarios and high maintenance costs, improves the flexibility of SQL-based data processing, reduces code processing complexity, improves code readability, reduces maintenance costs, and improves data query efficiency.

[0088] Optionally, the target parsing result feedback module 340 can be specifically used to: obtain the chained call method corresponding to the cursor object, and determine the initial parsing result based on the chained call method; determine whether the model mapping object corresponding to the initial parsing result is a custom object in the pre-built manager; if so, process the initial parsing result according to the pre-set field type conversion verification method corresponding to the custom object to determine the target parsing result; if not, determine that the model mapping object corresponding to the initial parsing result is an Object object, and obtain the field name by parsing the cursor object, and assign a value to the Object object based on the field name to determine the target parsing result.

[0089] Optionally, it also includes a manager construction module, which may specifically include: a target registration executor determination unit, used to obtain a standard function, encapsulate the standard function, and determine the target registration executor corresponding to the standard function before obtaining the instruction to be executed, parsing the function in the instruction to be executed, and determining the executor corresponding to the function; a custom object determination unit, used to obtain at least one standard object corresponding to the standard function, and match the fields corresponding to the standard object with the mapping object model class attributes to determine the custom object; and a manager construction unit, used to instantiate the target registration executor and the custom object to complete the manager construction.

[0090] Optionally, the manager construction unit may specifically include: a manager function dictionary determination subunit, used to instantiate the target registration executor and determine the manager function dictionary; a manager object determination subunit, used to instantiate the custom object and determine the manager object; and a manager construction subunit, used to store the manager function dictionary and the manager object in a lazy connection pool to complete the manager construction.

[0091] Optionally, the manager function dictionary determination subunit can be specifically used for: creating a target registration executor object based on the target registration executor, and determining the initial custom object parameters corresponding to the target registration executor object; determining whether the initial custom object parameters are SQL file paths; if so, reading the SQL statement corresponding to the target SQL file path based on the parsed target SQL file path, and determining the manager function dictionary; if not, reading the SQL statement based on the initial custom object parameters, and determining the manager function dictionary.

[0092] Optionally, it can be specifically used to: determine the mapping object model class attributes based on the initial custom object parameters; and store the SQL statement and the mapping object model class attributes as dictionary values ​​in the manager function dictionary.

[0093] Optionally, it also includes an instruction feedback module, which can be specifically used to: after obtaining the instruction to be executed, parsing out the function in the instruction to be executed, and determining the executor corresponding to the function, if the executor does not match the target registered executor in the pre-built manager, then the instruction to be executed is discarded, and the instruction that failed to match the executor is fed back to the user.

[0094] The SQL-based data processing device provided in the embodiments of the present invention can execute the SQL-based data processing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the method execution.

[0095] Example 4

[0096] Figure 4 A schematic diagram of an electronic device 10, which can be used to implement Embodiment 4 of the present invention, is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0097] like Figure 4 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0098] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0099] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as SQL-based data processing methods.

[0100] In some embodiments, the SQL-based data processing method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the SQL-based data processing method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to execute the SQL-based data processing method by any other suitable means (e.g., by means of firmware).

[0101] The method includes: acquiring an instruction to be executed, parsing out the function in the instruction to be executed, and determining the executor corresponding to the function; when the executor hits a target registered executor in a pre-built manager, determining whether the lazy connection pool corresponding to the manager is in a connected state; if not, connecting with the target registered executor in the lazy connection pool and parsing out the cursor object corresponding to the instruction to be executed; parsing the cursor object, determining the target parsing result, and feeding back the target parsing result to the user.

[0102] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0103] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0104] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0105] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0106] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0107] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0108] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0109] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

[0110] Example 5

[0111] Embodiment 5 of the present invention also provides a computer-readable storage medium, wherein the computer-readable instructions, when executed by a computer processor, are used to execute an SQL-based data processing method. The method includes: obtaining an instruction to be executed, parsing out the function in the instruction to be executed, and determining the executor corresponding to the function; when the executor hits a target registered executor in a pre-built manager, determining whether the lazy connection pool corresponding to the manager is in a connected state; if not, connecting with the target registered executor in the lazy connection pool and parsing out the cursor object corresponding to the instruction to be executed; parsing the cursor object, determining the target parsing result, and feeding back the target parsing result to the user.

[0112] Of course, the computer-executable instructions provided in the embodiments of the present invention, which include a computer-readable storage medium, are not limited to the method operations described above, but can also perform related operations in the SQL-based data processing method provided in any embodiment of the present invention.

[0113] Based on the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented using software and necessary general-purpose hardware, and of course, it can also be implemented using hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk, or optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0114] It is worth noting that in the above embodiments of the SQL-based data processing device, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the scope of protection of the present invention.

[0115] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method for processing data based on structured query language (SQL), characterized in that, The method comprises the following steps: acquiring an instruction to be executed, parsing a function in the instruction to be executed, and determining an executor corresponding to the function; when the executor hits a target registered executor in a pre-constructed manager, judging whether an inert connection pool corresponding to the manager is in a connection state; if not, connecting with the target registered executor in the inert connection pool, and parsing a cursor object corresponding to the instruction to be executed; performing parsing processing on the cursor object, determining a target parsing result, and feeding back the target parsing result to a user; wherein the parsing processing on the cursor object and the determination of the target parsing result comprise: acquiring a chain call method corresponding to the cursor object, and determining an initial parsing result according to the chain call method; judging whether a model mapping object corresponding to the initial parsing result is a custom object hitting the pre-constructed manager; if yes, processing the initial parsing result according to a pre-set field type conversion checking method corresponding to the custom object, and determining the target parsing result; if not, determining that the model mapping object corresponding to the initial parsing result is an Object object, obtaining a field name by parsing the cursor object, and assigning the Object object according to the field name to determine the target parsing result.

2. The method of claim 1, wherein, Before the acquiring of the instruction to be executed, the parsing of the function in the instruction to be executed, and the determination of the executor corresponding to the function, the method further comprises the following steps: acquiring a standard function, encapsulating the standard function, and determining a target registered executor corresponding to the standard function; acquiring at least one standard object corresponding to the standard function, and matching a field and a mapping object model class attribute corresponding to the standard object to determine a custom object; performing instantiation processing on the target registered executor and the custom object to construct a manager.

3. The method of claim 2, wherein, The instantiation processing on the target registered executor and the custom object to construct the manager comprises: performing instantiation processing on the target registered executor to determine a manager function dictionary; performing instantiation processing on the custom object to determine a manager object; storing the manager function dictionary and the manager object in an inert connection pool to construct the manager.

4. The method of claim 3, wherein, The instantiation processing on the target registered executor to determine the manager function dictionary comprises: creating a target registered executor object according to the target registered executor, and determining an initial custom object parameter corresponding to the target registered executor object; judging whether the initial custom object parameter is a SQL file path, if yes, reading a SQL statement corresponding to the target SQL file path according to the parsed target SQL file path, and determining the manager function dictionary; if not, reading a SQL statement according to the initial custom object parameter, and determining the manager function dictionary.

5. The method of claim 4, wherein, The reading of the SQL statement and the determination of the manager function dictionary comprise: determining a mapping object model class attribute according to the initial custom object parameter; The SQL statement and the mapping object model class attribute are stored in the manager function dictionary as dictionary values.

6. The method of claim 1, wherein, After the instruction to be executed is obtained, the function in the instruction to be executed is parsed, and the executor corresponding to the function is determined. If the target registered executor in the pre-constructed manager is not hit by the executor, the instruction to be executed is discarded, and the instruction for which the executor is not matched is fed back to the user.

7. A structured query language (SQL) based data processing apparatus, characterized by comprising: The executor determination module is configured to obtain an instruction to be executed, parse a function in the instruction to be executed, and determine an executor corresponding to the function. The connection state determination module is configured to determine whether a lazy connection pool corresponding to the manager is in a connection state when the target registered executor in the pre-constructed manager is hit by the executor. The cursor object parsing module is configured to connect with the target registered executor in the lazy connection pool and parse a cursor object corresponding to the instruction to be executed if the lazy connection pool corresponding to the manager is not in the connection state. The target parsing result feedback module is configured to parse the cursor object, determine a target parsing result, and feed back the target parsing result to the user. The target parsing result feedback module is further configured to obtain a chain call method corresponding to the cursor object, determine an initial parsing result according to the chain call method, determine whether a model mapping object corresponding to the initial parsing result is a custom object in the pre-constructed manager, process the initial parsing result according to a field type conversion inspection method corresponding to the custom object if the model mapping object is the custom object, determine a target parsing result, determine that the model mapping object corresponding to the initial parsing result is an Object object if the model mapping object is not the custom object, obtain a field name by parsing the cursor object, assign the Object object according to the field name, and determine a target parsing result. The processor executes the computer program to implement the SQL-based data processing method in any one of claims 1-6.

8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The computer readable storage medium stores computer instructions for causing the processor to implement the SQL-based data processing method in any one of claims 1-6 when executed.

9. A computer-readable storage medium, characterized in that, ​

Citation Information

Patent Citations

  • Cross-platform multi-data source access method and device, electronic equipment and storage medium

    CN114416774A

  • Data processing method, device and system and storage medium

    CN115145689A