Data query method and device for target database, equipment and medium

By introducing a regular expression parser into the target database, the problem of existing technologies not supporting regular expression queries is solved, enabling data export under complex conditions and improving the flexibility and accuracy of the database.

CN121117005APending Publication Date: 2025-12-12BEIJING URBAN CONSTR INTELLIGENT CONTROL TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510982320.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-16
Publication Date
2025-12-12

AI Technical Summary

Technical Problem

The existing target database does not support regular expression queries, which limits the flexibility, practicality, and accuracy of data export.

Method used

A regular expression parser is introduced into the target database. The parser processes the regular expressions in the query statement to generate query instructions, and performs data queries based on these instructions, supporting complex regular expression condition filtering.

Benefits of technology

It improves the flexibility and accuracy of the target database, meets diverse data export needs, and enhances the practicality of data querying.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121117005A_ABST
    Figure CN121117005A_ABST
Patent Text Reader

Abstract

The invention provides a data query method and device for a target database, electronic equipment and a storage medium, and relates to the technical field of databases, the method comprises the following steps: obtaining a query statement for the target database; under the condition that the regular expression identifier exists in the query statement, calling a regular expression analyzer in a target database; performing analysis processing on the regular expression in the query statement through a regular expression analyzer to obtain a query instruction; and based on the query instruction, performing data query in a target database to obtain target data corresponding to the query statement in the target database. On the basis of the existing target database, a regular expression query function is added, and the flexibility, practicability and accuracy of the target database are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of database, and particularly relates to a data query method, device and equipment of a target database and a medium. BACKGROUND

[0002] Some databases are widely used in the field of big data storage and processing due to their high scalability and high availability. However, the Copy To command in these databases only supports simple field condition queries when exporting data, and does not support complex regular expression condition filtering, which limits the flexibility, practicality and accuracy of data export. SUMMARY

[0003] The present application provides a data query method, device and equipment of a target database to solve the problem that the target database does not support regular expression queries in the prior art, which limits the flexibility, practicality and accuracy of data export. The present application adds a regular expression query function based on the existing target database, thereby improving the flexibility, practicality and accuracy of the target database.

[0004] The present application provides a data query method of a target database, comprising: obtaining a query statement for the target database; in the case where a regular expression identifier exists in the query statement, calling a regular expression parser in the target database; performing analysis processing on an initial regular expression in the query statement by the regular expression parser to obtain a query instruction; based on the query instruction, performing data query in the target database to obtain target data in the target database corresponding to the query statement.

[0005] According to the data query method of the target database provided by the present application, the analysis processing includes error identification processing, and the analysis processing on the initial regular expression in the query statement by the regular expression parser to obtain a query instruction includes: performing error identification processing on the initial regular expression by the regular expression parser to obtain an identification result; and determining the query instruction based on the identification result by the regular expression parser.

[0006] According to the data query method of the target database provided by the application, the query instruction comprises a first query instruction corresponding to the changed regular expression and a second query instruction corresponding to the initial regular expression, and the query instruction is determined based on the identification result by the regular expression parser, comprising: in the case that there is regular expression error information in the identification result, displaying the regular expression error information on the display interface of the device connected to the target database, the regular expression error information being used to prompt the user to change the regular expression in the query statement; after the user changes the regular expression in the query statement, the changed regular expression is analyzed and processed by the regular expression parser to obtain the first query instruction; in the case that there is no regular expression error information in the identification result, the initial regular expression is analyzed and processed by the regular expression parser to obtain the second query instruction.

[0007] According to the data query method of the target database provided by the application, after the data query in the target database based on the query instruction is performed to obtain the target data corresponding to the query statement in the target database, the method further comprises: receiving a user inputted export command; wherein the export command is a command supported by the target database for regular expression query; determining an export format corresponding to the target data and a target export file based on the export command; exporting the target data to the target export file according to the export format to obtain a target file.

[0008] According to the data query method of the target database provided by the application, the target data is exported to the target export file according to the export format to obtain a target file, comprising: in the case that an export error occurs in the process of exporting the target data to the target export file, displaying export error information on the display interface of the device connected to the target database, the export error information being used to prompt the user to solve the export error; after the user solves the export error, continuing to export the target data to the target export file according to the export format to obtain the target file.

[0009] According to the data query method of the target database provided by the application, after the target data is exported to the target export file in the export format, the method further comprises: verifying the original export function corresponding to the target database to obtain a first verification result; in the case that the first verification result shows that the original export function of the target database is incorrect, determining the target file as an incorrect file; in the case that the first verification result shows that the original export function of the target database is correct, verifying the target data in the target file to obtain a second verification result; and determining the type of the target file based on the second verification result.

[0010] According to the data query method of the target database provided by the application, the determination of the type of the target file based on the second verification result comprises: in the case that the second verification result shows that the target data is correct, determining the type of the target file as a correct file; and in the case that the second verification result shows that the target data is incorrect, determining the type of the target file as an incorrect file.

[0011] The application further provides a data query device of a target database, comprising: an acquisition module, configured to acquire a query statement for a target database; a calling module, configured to call a regular expression parser in the target database in the case that there is a regular expression identifier in the query statement; a parsing module, configured to perform parsing processing on an initial regular expression in the query statement by using the regular expression parser to obtain a query instruction; a query module, configured to perform data query in the target database based on the query instruction to obtain target data corresponding to the query statement in the target database.

[0012] The application further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the data query method of the target database according to any one of the above-mentioned methods when executing the computer program.

[0013] The application further provides a non-transitory computer readable storage medium, which stores a computer program, and the computer program is executable on a processor to implement the data query method of the target database according to any one of the above-mentioned methods.

[0014] The application further provides a computer program product, comprising a computer program, and the computer program is executable on a processor to implement the data query method of the target database according to any one of the above-mentioned methods.

[0015] The application provides a data query method, device, equipment and medium of a target database, wherein the method comprises the following steps: acquiring a query statement for the target database; calling a regular expression parser in the target database to parse a regular expression in the query statement and obtaining a query instruction when the regular expression exists in the query statement; and performing data query in the target database based on the query instruction to obtain target data corresponding to the query statement in the target database. Thus, the target database can understand and execute the query containing the regular expression by calling the regular expression parser in the target database, thereby improving the flexibility, practicability and accuracy of the database, expanding the query function of the target database and meeting diversified data export requirements. BRIEF DESCRIPTION OF DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the application or prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative effort.

[0017] Figure 1 FIG. 1 is a flowchart of a data query method of a target database provided by the application.

[0018] Figure 2 FIG. 2 is a structural diagram of a data query device of a target database provided by the application.

[0019] Figure 3 FIG. 3 is a structural diagram of an electronic device provided by the application. DETAILED DESCRIPTION

[0020] In order to make the objects, technical solutions and advantages of the application clearer, the technical solutions in the application will be described clearly and completely in combination with the drawings in the application. Obviously, the described embodiments are some embodiments of the application, rather than all the embodiments. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative effort belong to the protection scope of the application.

[0021] Firstly, the following professional terms are explained: Cassandra: Cassandra is a highly scalable non-relational database (Not Only Structured Query Language, NoSQL) designed for distributed storage of large amounts of data across multiple data centers.

[0022] Copy To: Command for data export in Cassandra database.

[0023] Regular Expression: A regular expression is a text pattern that includes ordinary characters (e.g., letters a to z) and special characters (called "metacharacters") used for string searching and manipulation.

[0024] NoSQL: A database category that provides a way to store and retrieve data without relying on traditional Relational Database Management Systems (RDBMS).

[0025] Cassandra Query Language (CQL): A declarative query language specifically designed for Cassandra databases. CQL is similar to Structured Query Language (SQL) and provides a syntax for data definition, data manipulation, and querying.

[0026] Regular Expression: A regular expression is a text pattern that includes ordinary characters (e.g., letters a to z) and special characters (called "metacharacters") used for string searching and manipulation. The introduction of regular expressions in CQL can enhance the flexibility of queries, allowing for complex pattern matching.

[0027] Parser: A parser is a part of a computer program that analyzes the structure of text data, such as programming languages or query languages. In the context of CQL, the parser is responsible for understanding and converting user-input query statements into a form that the database can execute.

[0028] It should be noted that the target database can be any suitable database, such as a Cassandra database, a Hbase database, a ScyllaDB database, etc. The following describes the data query method of the target database using the Cassandra database as an example.

[0029] The following describes the data query method of the target database according to the present application. Figure 1 The execution subject of the data query method of the target database can be an electronic device, or a data query method of a target database provided in the electronic device. The data query method of the target database can be implemented by software, hardware, or a combination of both.

[0030] Figure 1 The flowchart of the data query method of the target database provided by the present application is shown in FIG. 1. Figure 1 The method includes the following steps: Step 101, obtaining a query statement for a target database.

[0031] Here, the query statement can be input by a user in a command interface.

[0032] It should be noted that the system needs to connect to the Cassandra database to query data, for example, Linux system, after the user enters the Linux system, the command line input call command, call Cassandra database.

[0033] Here, the Cassandra database can be a Cassandra database after extending the query language of Cassandra, wherein the extended Cassandra database specifically includes the following processes: 1. Syntax definition: design new CQL syntax rules, including the use of regular expressions, operators and functions. Here, the syntax definition includes: 1) requirement analysis, analyzing the user's demand for regular expressions in data query, and determining the regular expression functions that need to be supported; 2) Syntax design: design CQL syntax rules, including the use of regular expressions, operators and functions. For example, introduce new keywords and functions, such as REGEXP_MATCH, which allows users to use regular expressions in the WHERE clause, SELECT * FROM users WHERE name REGEXP_MATCH '^[A-Za-z]+'; 3) Document writing: update the official document of Cassandra, and describe the new regular expression syntax and use examples in detail.

[0034] 2. Parser modification: adjust the CQL parser according to the new CQL syntax rules, so that it can recognize and process regular expressions.

[0035] Step 102, in the case that there is a regular expression identifier in the query statement, calling the regular expression parser in the target database.

[0036] For example, the target database is a Cassandra database, and the regular expression parser in the Cassandra database is independently developed and integrated into the Cassandra database, wherein the regular expression parser includes a lexical analyzer: used to identify symbols and patterns in regular expressions; Syntax analyzer: used to build a parse tree of regular expressions; Interpreter: used to perform matching operations of regular expressions.

[0037] For example, developing a regular expression parser and integrating it into Cassandra specifically includes the following processes: 1. Design a regular expression parser. This includes: 1) requirement analysis: determine the functions and syntax of regular expressions that the parser needs to support; 2) algorithm selection: choose appropriate algorithms to implement the parser, such as Thompson's construction algorithm or other efficient regular expression processing algorithms; 3) module design: design the software architecture of the parser; 4) coding implementation: write code to implement the parser, including the lexical analyzer, syntax analyzer, and interpreter.

[0038] 2. Integration testing: integrate the regular expression parser into Cassandra and conduct comprehensive testing to ensure its correctness and efficiency. This includes: 1) integrated development environment: integrate the regular expression parser into the development environment of Cassandra; 2) unit testing: write unit tests to verify the components of the parser, ensuring that they can correctly handle various regular expression patterns; 3) integration testing: conduct integration testing to ensure that the parser can seamlessly cooperate with other parts of Cassandra, such as the query parser and execution engine; 4) performance testing: evaluate the impact of the parser on the performance of Cassandra, ensuring that it does not introduce significant performance bottlenecks.

[0039] 3. Exception handling: implement an exception handling mechanism to handle invalid regular expression inputs and improve the robustness of the system. This includes: 1) error identification: define possible regular expression error types, such as syntax errors, infinite backtracking, etc.; 2) exception capture: implement an exception capture mechanism in the parser to capture and handle exceptions when encountering invalid inputs; 3) error reporting: design an error reporting mechanism to provide clear error information to users, helping them diagnose and fix problems; 4) security protection: ensure that the exception handling mechanism does not expose internal system information, preventing potential security risks.

[0040] Step 103: Analyze the initial regular expression in the query statement using the regular expression parser to obtain a query instruction.

[0041] Here, the initial regular expression refers to the unmodified regular expression in the query statement. The query instruction can be the query instruction corresponding to the initial regular expression, or the query instruction corresponding to the modified initial regular expression when the initial regular expression has an error syntax.

[0042] Step 104: Based on the query instruction, perform data query in the target database to obtain the target data corresponding to the query statement in the target database.

[0043] Here, the target data refers to data satisfying the query statement, and the target data is found in the Cassandra database according to the matching result.

[0044] In the embodiment of the present application, the query statement is obtained for the target database, and the regular expression in the query statement is parsed by calling the regular expression parser in the target database to obtain a query instruction. The target data corresponding to the query statement in the target database is obtained by querying the target database based on the query instruction. In this way, the target database can understand and execute the query containing the regular expression by calling the regular expression parser in the target database, thereby improving the flexibility, practicability and accuracy of the database, expanding the query function of the target database, and meeting the diversified data export requirements.

[0045] Further, the parsing process includes error identification processing, and the parsing process of the initial regular expression in the query statement by the regular expression parser to obtain a query instruction includes: error identification processing of the initial regular expression by the regular expression parser to obtain an identification result; and determination of the query instruction by the regular expression parser based on the identification result.

[0046] Here, the error identification can be identification of error syntax, infinite backtracking, etc. of the regular expression. The identification result is used to represent whether the regular expression has an error.

[0047] It should be noted that the possible regular expression error types, such as syntax error, infinite backtracking, etc. can be defined in the regular expression parser in advance. When the regular expression parser identifies an error regular expression, it is determined as invalid input.

[0048] It should be noted that the regular expression parser converts the regular expression into an internal data structure after error identification processing of the regular expression, and matches the internal data structure with the field in the Cassandra database to obtain a matching result.

[0049] For example, SELECT * FROM users WHERE name REGEXP_MATCH '^[A-Za-z]+', wherein name represents an identification field, REGEXP_MATCH represents a regular expression keyword, and ^[A-Za-z]+ represents a regular expression. According to ^[A-Za-z]+, a text segment or a text position satisfying the regular expression is searched in the database.

[0050] In the embodiment of the present application, the regular expression is subjected to error identification processing and matching processing by the added regular expression parser, allowing the Cassandra database to perform complex pattern matching queries and meet diversified data export requirements.

[0051] Further, the query instruction includes a first query instruction corresponding to the changed regular expression and a second query instruction corresponding to the initial regular expression, and the determination of the query instruction based on the identification result by the regular expression parser includes: in the case where the regular expression error information exists in the identification result, displaying the regular expression error information on a device display interface connected to the target database, the regular expression error information being used to prompt a user to change the regular expression in the query statement; after the user changes the regular expression in the query statement, analyzing the changed regular expression by the regular expression parser to obtain the first query instruction; in the case where the regular expression error information does not exist in the identification result, analyzing the initial regular expression by the regular expression parser to obtain the second query instruction.

[0052] It should be noted that the regular expression error information can include syntax errors, infinite backtracking, etc., and when the regular expression error information exists in the identification result, the device display interface displays the regular expression error information, so that the user modifies the regular expression according to the regular expression error information, and then performs matching processing on the modified regular expression and the field in the target database, such as the Cassandra database, to obtain a matching result; when the regular expression error information does not exist in the identification result, it indicates that the regular expression is correct, and after parsing, the regular expression can be directly matched with the field in the Cassandra database to obtain a matching result.

[0053] It should be noted that the error identification processing and error information display of the regular expression parser can be implemented by prewriting corresponding codes in the system, such as prewriting possible regular expression error types, preadding an exception capturing mechanism, an error reporting mechanism and a security protection mechanism in the regular expression parser. The exception capturing mechanism can capture and process exceptions when encountering invalid inputs (i.e., regular expression errors), the error reporting mechanism can provide clear error information to the user to help the user diagnose and repair problems, and the security protection mechanism can protect internal system information to prevent potential security risks.

[0054] In the embodiment of the present application, by adding the error identification mechanism and the error reporting mechanism in the regular expression parser, the Cassandra database can process invalid regular expression inputs, improve the robustness of the system, and provide clear error information to the user to help diagnose and repair problems.

[0055] Further, after the data query in the target database based on the query instruction to obtain the target data corresponding to the query statement in the target database, the method further comprises: receiving a user input export command; wherein the export command is a command supported by the target database for regular expression query; determining an export format corresponding to the target data and a target export file based on the export command; exporting the target data to the target export file according to the export format to obtain a target file.

[0056] Here, the export command is essentially a command obtained by pre-expanding the Copy To command of the target database, for example, a Cassandra database.

[0057] For example, the target database is a Cassandra database, and the original Copy To command in the Cassandra database is COPY platform_point.pointvalue01 to ' / home / pv1.csv' with header = true; and the expanded Cassandra database Copy To command is COPY platform_point.pointvalue01 to ' / home / pv1.csv' with header = true name REGEXP_MATCH '^[A-Za-z]+'.

[0058] It should be noted that expanding the Copy To command of the Cassandra database specifically includes the following process: 1. Command analysis: modify the analysis logic of the Copy To command to enable it to accept regular expressions as query conditions. Specifically, it includes: 1) requirement analysis: analyze the user's demand for regular expressions when using the Copy To command, and determine the regular expression functions that need to be supported; 2) syntax modification: expand the syntax of the Copy To command to allow embedding regular expressions in the command. For example, the user can be allowed to use the condition (WHERE) clause to specify regular expression conditions; 3) parser integration: integrate the regular expression parser into the analysis logic of the Copy To command to ensure that the command can correctly parse queries containing regular expressions. 4) Test verification: develop test cases to verify the modified command analysis logic to ensure that it can correctly handle queries containing regular expressions.

[0059] 2. User interface and documentation: Update the user interface and documentation to support the new Copy To command functionality. This includes: 1) User interface update: If the Copy To command is provided through a graphical user interface (GUI), update the GUI to support regular expression input and application; 2) Documentation writing: Update the official documentation to detail the usage of the new Copy To command, including how to use regular expressions for data filtering; 3) Example provision: Provide examples of data export using regular expressions to help users understand the usage of the new functionality.

[0060] 3. Testing and deployment: Conduct comprehensive testing and deploy the new Copy To command. This includes: 1) Functional testing: Conduct functional testing to ensure that the new Copy To command correctly handles queries containing regular expressions; 2) Performance testing: Conduct performance testing to evaluate the impact of the new functionality on data export performance; 3) User acceptance testing: Invite users to participate in testing, collect feedback, and make adjustments based on feedback; 4) Deployment online: After ensuring the stability and reliability of the new functionality, deploy it to the production environment.

[0061] Here, the export format can be user-defined, including but not limited to CSV, JSON, XML format, etc.

[0062] Specifically, the user inputs the specified export format and target export file through the command line, the system determines the export format and target export file from the export command, exports the target data according to the export format to the target export file, and obtains the target file.

[0063] For example, the export command can be COPY platform_point.pointvalue01 to ' / home / pv1.csv' with header = true name REGEXP_MATCH '^[A-Za-z]+', where the export format is csv format, and the target export file is pv1.csv, that is, the data that meets the ^ [A-Za-z]+ regular expression is exported to the pv1.csv file in csv format.

[0064] In the embodiments of the present application, the command for regular expression export supported by the Cassandra database can accept and process queries and exports containing regular expressions, and users can independently select the export format and target export file, thereby improving the flexibility, practicality and accuracy of the Cassandra database.

[0065] Further, the exporting the target data into the target export file in the export format to obtain a target file comprises: in a case that an export error occurs in the process of exporting the target data into the target export file, displaying export error information on a device interface connected to the target database, the export error information being used to prompt a user to solve the export error; after the user solves the export error, continuing to export the target data into the target export file in the export format to obtain the target file.

[0066] Here, the export error includes but is not limited to a write permission problem, insufficient disk space, etc.

[0067] In the embodiment of the application, the error processing mechanism is implemented in the process of exporting the target data, so as to process possible problems in the exporting process, and improve the accuracy and security of the target data exporting.

[0068] Further, after the target data is exported into the target export file in the export format to obtain a target file, the method further comprises: verifying an original export function corresponding to the target database to obtain a first verification result; in a case that the first verification result shows that the original export function of the target database is incorrect, determining the target file as an error file; in a case that the first verification result shows that the original export function of the target database is correct, verifying the target data in the target file to obtain a second verification result; and determining the type of the target file based on the second verification result.

[0069] Taking the Cassandra database as an example, when the existing Cassandra database is expanded, it is necessary to ensure that the original function of the Cassandra database is normal, and therefore, it is necessary to verify the original export function of the Cassandra database, and in a case that the original function of the Cassandra database is verified to be normal, the target data in the target file is continuously verified to ensure that the Cassandra database operates normally; and in a case that the original function of the Cassandra database is verified to be incorrect, the target file is determined as an error file.

[0070] In the embodiment of the application, after the target data is exported, the original export function of the Cassandra database and the exported target data are verified to ensure that the exported data is accurate and meets the format specified by the user.

[0071] Further, the type of the target file is determined based on the second verification result, including: in the case that the second verification result shows that the target data is correct, the type of the target file is a correct file; in the case that the second verification result shows that the target data is incorrect, the type of the target file is an incorrect file.

[0072] It should be noted that when the target file is an incorrect file, the extended Cassandra database needs to be adjusted or re-matched and queried.

[0073] In the embodiment of the present application, after the target data is exported, the original export function of the Cassandra database and the exported target data are double-verified to ensure that the exported data is accurate and meets the format specified by the user, thereby improving the accuracy of data export.

[0074] The data query device of the target database provided by the present application is described below, and the data query device of the target database described below can be correspondingly referred to the data query method of the target database described above.

[0075] Figure 2 is a structural schematic diagram of the data query device of the target database provided by the present application, as Figure 2 shown, the data query device of the target database 200 includes: The acquisition module 201 is configured to acquire a query statement for the target database. The calling module 202 is configured to call a regular expression parser in the target database in the case that there is a regular expression identifier in the query statement. The parsing module 203 is configured to perform parsing processing on an initial regular expression in the query statement by the regular expression parser to obtain a query instruction. The query module 204 is configured to perform data query in the target database based on the query instruction to obtain target data corresponding to the query statement in the target database.

[0076] In the embodiment of the present application, the parsing processing includes error identification processing, and the parsing module 203 is specifically configured to: perform error identification processing on the initial regular expression by the regular expression parser to obtain an identification result; and determine the query instruction based on the identification result by the regular expression parser.

[0077] In the embodiment of the present application, the query instruction includes a first query instruction corresponding to the changed regular expression and a second query instruction corresponding to the initial regular expression, and the parsing module 203 is further configured to: in the case where the regular expression error information exists in the identification result, display the regular expression error information on a display interface of a device connected to the target database, the regular expression error information being used to prompt a user to change the regular expression in the query statement; after the user changes the regular expression in the query statement, analyze and process the changed regular expression by using the regular expression parser to obtain the first query instruction; in the case where the regular expression error information does not exist in the identification result, analyze and process the initial regular expression by using the regular expression parser to obtain the second query instruction.

[0078] In the embodiment of the present application, the data query apparatus 200 of the target database further includes an exporting module, which is configured to: after the data query in the target database based on the query instruction is performed to obtain the target data corresponding to the query statement in the target database, receive a user inputted exporting command, wherein the exporting command is a command supported by the target database for regular expression query; determine an exporting format corresponding to the target data and a target exporting file based on the exporting command; and export the target data to the target exporting file according to the exporting format to obtain a target file.

[0079] In the embodiment of the present application, the exporting module is further configured to: in the case where an exporting error occurs in the process of exporting the target data to the target exporting file, display exporting error information on a display interface of a device connected to the target database, the exporting error information being used to prompt a user to solve the exporting error; after the user solves the exporting error, continue to export the target data to the target exporting file according to the exporting format to obtain the target file.

[0080] In the embodiment of the present application, the data query apparatus 200 of the target database further includes a verifying module, which is configured to: after the target data is exported to the target exporting file according to the exporting format to obtain a target file, verify an original exporting function corresponding to the target database to obtain a first verification result; in the case where the first verification result shows that the original exporting function of the target database is incorrect, determine the target file as an error file; in the case where the first verification result shows that the original exporting function of the target database is correct, obtain a second verification result; and determine the type of the target file based on the second verification result.

[0081] In this embodiment of the invention, the verification module is further specifically configured to: when the second verification result shows that the target data is correct, set the type of the target file to a correct file; and when the second verification result shows that the target data is incorrect, set the type of the target file to an incorrect file.

[0082] Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention, such as... Figure 3 As shown, the electronic device may include a processor 310, a communications interface 320, a memory 330, and a communication bus 340, wherein the processor 310, communications interface 320, and memory 330 communicate with each other via the communication bus 340. The processor 310 can call logical instructions in the memory 330 to execute a data query method for a target database. This method includes: obtaining a query statement for the target database; if a regular expression identifier exists in the query statement, calling a regular expression parser in the target database; parsing the initial regular expression in the query statement using the regular expression parser to obtain a query instruction; and performing a data query in the target database based on the query instruction to obtain the target data in the target database corresponding to the query statement.

[0083] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0084] In another aspect, the present application also provides a computer program product comprising a computer program, which can be stored on a non-transitory computer readable storage medium, and the computer program, when executed by a processor, enables a computer to perform the data query method of a target database provided by the above method, and the method comprises: obtaining a query statement for a target database; in the case that a regular expression identifier exists in the query statement, calling a regular expression parser in the target database; performing parsing processing on an initial regular expression in the query statement by the regular expression parser to obtain a query instruction; and performing data query in the target database based on the query instruction to obtain target data corresponding to the query statement in the target database.

[0085] In another aspect, the present application also provides a non-transitory computer readable storage medium having a computer program stored thereon, and the computer program, when executed by a processor, enables a computer to perform the data query method of a target database provided by the above method, and the method comprises: obtaining a query statement for a target database; in the case that a regular expression identifier exists in the query statement, calling a regular expression parser in the target database; performing parsing processing on an initial regular expression in the query statement by the regular expression parser to obtain a query instruction; and performing data query in the target database based on the query instruction to obtain target data corresponding to the query statement in the target database.

[0086] The device embodiments described above are merely illustrative, wherein the units illustrated as separate components can or can not be physically separated, and the components illustrated as units can or can not be physical units, i.e., can be located in one place or distributed on multiple network units. Part or all of the modules can be selected to achieve the purpose of the embodiment according to actual needs. Those skilled in the art can understand and implement without creative labor.

[0087] From the above description of the embodiments, those skilled in the art can clearly understand that the embodiments can be realized by means of software plus necessary universal hardware platforms, and of course can also be realized by hardware. Based on such understanding, the above technical solutions, essentially or in other words, the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments.

[0088] It should be pointed out finally that the above embodiments are only used to illustrate the technical solutions of the present application, but not to limit the same; and although the present application has been described in detail with reference to the foregoing embodiments, it should be appreciated by those skilled in the art that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features thereof can be replaced equivalently; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A data query method of a target database, characterized by, The method comprises the following steps: acquiring a query statement for a target database; in the case that there is a regular expression identifier in the query statement, calling a regular expression parser in the target database; parsing an initial regular expression in the query statement by the regular expression parser to obtain a query instruction; based on the query instruction, performing data query in the target database to obtain target data corresponding to the query statement in the target database.

2. The data query method of a target database according to claim 1, wherein, The parsing process includes error identification processing. The parsing process of the initial regular expression in the query statement by the regular expression parser to obtain a query instruction includes: error identification processing of the initial regular expression by the regular expression parser to obtain an identification result; determination of the query instruction by the regular expression parser based on the identification result.

3. The data query method of a target database according to claim 2, wherein, The query instruction includes a first query instruction corresponding to a changed regular expression and a second query instruction corresponding to the initial regular expression. The determination of the query instruction by the regular expression parser based on the identification result includes: in the case that there is regular expression error information in the identification result, displaying the regular expression error information on the device display interface connected to the target database, the regular expression error information being used to prompt the user to change the regular expression in the query statement; analysis processing of the changed regular expression by the regular expression parser after the user changes the regular expression in the query statement to obtain the first query instruction; analysis processing of the initial regular expression by the regular expression parser in the case that there is no regular expression error information in the identification result to obtain the second query instruction.

4. The method of claim 1 to 3, wherein, After the data query in the target database based on the query instruction to obtain the target data corresponding to the query statement in the target database, the method further comprises: receiving a user inputted export command; wherein the export command is a command supported by the target database for regular expression query; based on the export command, determining an export format corresponding to the target data and a target export file; exporting the target data to the target export file according to the export format to obtain a target file.

5. The data query method of a target database according to claim 4, wherein, The exporting of the target data to the target export file according to the export format to obtain a target file includes: in the case that an export error occurs in the process of exporting the target data to the target export file, displaying export error information on the device display interface connected to the target database, the export error information being used to prompt the user to solve the export error; after the user solves the export error, continuing to export the target data to the target export file according to the export format to obtain the target file.

6. The data query method of a target database according to claim 4, wherein, After the exporting of the target data to the target export file according to the export format to obtain a target file, the method further comprises: verifying an original export function corresponding to the target database to obtain a first verification result; In a case where the first verification result shows that the original export function of the target database is incorrect, the target file is determined as an incorrect file; In a case where the first verification result shows that the original export function of the target database is correct, target data in the target file is verified to obtain a second verification result; Based on the second verification result, the type of the target file is determined.

7. The data query method of a target database according to claim 6, wherein, The determination of the type of the target file based on the second verification result comprises: In a case where the second verification result shows that the target data is correct, the type of the target file is a correct file; In a case where the second verification result shows that the target data is incorrect, the type of the target file is an incorrect file.

8. A data query apparatus for a target database, characterized by comprising: The method comprises the following steps: an acquisition module configured to acquire a query statement for a target database; a calling module configured to call a regular expression parser in the target database in a case where the query statement contains a regular expression identifier; a parsing module configured to perform parsing processing on an initial regular expression in the query statement by using the regular expression parser to obtain a query instruction; a query module configured to perform data query in the target database based on the query instruction to obtain target data in the target database corresponding to the query statement.

9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and running on the processor, characterized in that, The computer program is executed by the processor to implement the data query method of the target database according to any one of claims 1 to 7. 10.A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the data query method of the target database according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method for solving problem of ApacheSolr phrase search inaccuracy

    CN106933998A

  • Data query method, device and equipment and storage medium

    CN110737687A

  • Database query method and device, equipment and storage medium

    CN112182014A

  • Database query system

    US20160063063A1

  • Regular expression searching

    US20180121410A1