CN112632098A - Dynamic generation method of structured query statement and related equipment - Google Patents

Dynamic generation method of structured query statement and related equipment Download PDF

Info

Publication number
CN112632098A
CN112632098A CN202011504603.7A CN202011504603A CN112632098A CN 112632098 A CN112632098 A CN 112632098A CN 202011504603 A CN202011504603 A CN 202011504603A CN 112632098 A CN112632098 A CN 112632098A
Authority
CN
China
Prior art keywords
template
structured query
target
traversal
statement
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011504603.7A
Other languages
Chinese (zh)
Inventor
段金良
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN202011504603.7A priority Critical patent/CN112632098A/en
Publication of CN112632098A publication Critical patent/CN112632098A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/80Information retrieval; Database structures therefor; File system structures therefor of semi-structured data, e.g. markup language structured data such as SGML, XML or HTML
    • G06F16/83Querying
    • G06F16/832Query formulation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/186Templates

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Computing Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to data processing and provides a dynamic generation method of a structured query statement and related equipment. The method can obtain query condition identification, traverse the database server by using the query condition identification to obtain a traversal result, obtain statement template identification when the traversal result meets preset parameters, obtain a target template corresponding to the statement template identification from the database server, write the traversal result into the target template, and generate the target structured query statement. The invention can realize the hot update service of the target structured query statement. In addition, the invention also relates to a block chain technology, and the target structured query statement can be stored in the block chain.

Description

Dynamic generation method of structured query statement and related equipment
Technical Field
The invention relates to the technical field of data processing, in particular to a dynamic generation method of a structured query statement and related equipment.
Background
The existing orm (object Relational mapping) framework mainly includes a MyBatis framework, which is a persistent layer framework supporting dynamic modification of a structured query statement in an XML manner, however, this manner is to modify the structured query statement in the XML, so that after the structured query statement is modified, a service needs to be restarted to execute a program, and hot update cannot be realized.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a method and related apparatus for dynamically generating a structured query statement, which can implement a hot update service for a target structured query statement.
On one hand, the invention provides a dynamic generation method of a structured query statement, which is applied to electronic equipment, wherein the electronic equipment is connected with a database server, and the dynamic generation method of the structured query statement comprises the following steps:
when a dynamic generation request is received, acquiring a query condition identifier from the dynamic generation request;
traversing the database server by using the query condition identifier to obtain a traversal result;
detecting whether the traversal result meets preset parameters or not;
when the traversal result meets the preset parameters, obtaining a statement template identifier from the dynamic generation request;
acquiring a target template corresponding to the sentence template identification from the database server;
and writing the traversal result into the target template to generate a target structured query statement.
According to a preferred embodiment of the present invention, the traversing the database server by using the query condition identifier to obtain a traversal result includes:
determining a data storage area in the database server, and determining a memory occupied by the area;
determining the number of threads according to the memory, and dividing the area into a plurality of partitions according to the number of the threads;
acquiring all threads in a preset thread pool;
acquiring the processing efficiency of each thread and acquiring the thread state of each thread;
generating a thread score of each thread according to the processing efficiency, the thread state and a preset weight;
sequencing all threads according to the sequence of the thread scores from large to small to obtain a thread queue;
screening the first N threads from the thread queue as processing threads;
and traversing the plurality of partitions by utilizing the processing thread based on the query condition identification to obtain the traversal result.
According to a preferred embodiment of the present invention, the detecting whether the traversal result satisfies a preset parameter includes:
when a plurality of preset parameters exist, detecting whether the traversal result meets the preset parameters or not;
when the traversal results all meet a plurality of preset parameters, determining that the traversal results meet the preset parameters; or
And when the traversal results do not all meet the preset parameters, determining that the traversal results do not meet the preset parameters.
According to the preferred embodiment of the present invention, the obtaining of the query condition identifier from the dynamically generated request includes:
analyzing the message of the dynamic generation request to obtain message information carried by the dynamic generation request;
acquiring a first preset label from a configuration label library, wherein the first preset label is used for indicating a condition identifier;
and acquiring information corresponding to the first preset label from the message information as the query condition identifier.
According to the preferred embodiment of the present invention, the obtaining the statement template identifier from the dynamically generated request includes:
eliminating the query condition identification from the message information to obtain data information;
acquiring a second preset label from the configuration label library, wherein the second preset label is used for indicating a template identifier;
and acquiring information corresponding to the template identifier from the data information as the statement template identifier.
According to a preferred embodiment of the present invention, the writing the traversal result into the target template, and the generating the target structured query statement includes:
determining a result label corresponding to the traversal result according to the configuration label library;
determining a location of the result tag in the target template;
and writing the traversal result into the target template according to the position to obtain the target structured query statement.
According to a preferred embodiment of the present invention, the obtaining the target template corresponding to the sentence template identifier from the database server includes:
acquiring a template mapping table in the database server, wherein the template mapping table stores the mapping relation between a plurality of template identifications and storage positions;
acquiring a target position corresponding to the sentence template identification from the template mapping table;
extracting the target template from the target location.
On the other hand, the present invention further provides a dynamic generation apparatus for structured query statements, which runs in an electronic device, wherein the electronic device is connected to a database server, and the dynamic generation apparatus for structured query statements includes:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring query condition identification from a dynamic generation request when the dynamic generation request is received;
the traversal unit is used for traversing the database server by using the query condition identifier to obtain a traversal result;
the detection unit is used for detecting whether the traversal result meets preset parameters or not;
the obtaining unit is further configured to obtain a statement template identifier from the dynamic generation request when the traversal result meets the preset parameter;
the obtaining unit is further configured to obtain a target template corresponding to the sentence template identifier from the database server;
and the generating unit is used for writing the traversal result into the target template to generate a target structured query statement.
In another aspect, the present invention further provides an electronic device, including:
a memory storing computer readable instructions; and
a processor executing computer readable instructions stored in the memory to implement the structured query statement dynamic generation method.
In another aspect, the present invention further provides a computer-readable storage medium, where computer-readable instructions are stored in the computer-readable storage medium, and the computer-readable instructions are executed by a processor in an electronic device to implement the method for dynamically generating the structured query statement.
According to the technical scheme, the query condition identification can be quickly acquired through the dynamic generation request, the result corresponding to the query condition identification can be quickly acquired from the database server by utilizing the query condition identification, the traversal result is detected, the condition in the generated target structured query statement can be ensured to meet the preset parameters, the traversal result is written into the target template, and the target structured query statement can be quickly generated. According to the invention, the target structured query statement is configured and generated in the database server in real time, so that the hot update service of the target structured query statement can be realized without restarting the service.
Drawings
FIG. 1 is a flow chart of the method for dynamically generating a structured query statement according to the preferred embodiment of the present invention.
FIG. 2 is a flow diagram of one embodiment of the present invention for determining traversal results.
FIG. 3 is a flow diagram of an embodiment of the present invention to generate a target structured query statement.
FIG. 4 is a functional block diagram of the dynamic structured query statement generation apparatus according to the present invention.
FIG. 5 is a schematic structural diagram of an electronic device implementing the method for dynamically generating a structured query statement according to the preferred embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
FIG. 1 is a flow chart of a preferred embodiment of the method for dynamically generating a structured query statement according to the present invention. The order of the steps in the flow chart may be changed and some steps may be omitted according to different needs.
The method for dynamically generating the structured query statement is applied to one or more electronic devices, where the electronic devices are devices capable of automatically performing numerical calculation and/or information processing according to computer readable instructions set or stored in advance, and hardware of the electronic devices includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The electronic device may be any electronic product capable of performing human-computer interaction with a user, for example, a Personal computer, a tablet computer, a smart phone, a Personal Digital Assistant (PDA), a game machine, an interactive Internet Protocol Television (IPTV), a smart wearable device, and the like.
The electronic device may include a network device and/or a user device. Wherein the network device includes, but is not limited to, a single network electronic device, an electronic device group consisting of a plurality of network electronic devices, or a Cloud Computing (Cloud Computing) based Cloud consisting of a large number of hosts or network electronic devices.
The network in which the electronic device is located includes, but is not limited to: the internet, a wide area Network, a metropolitan area Network, a local area Network, a Virtual Private Network (VPN), and the like.
The electronic device is connected with the database server.
S10, when receiving the dynamic generation request, obtaining the inquiry condition identification from the dynamic generation request.
In at least one embodiment of the present invention, the dynamic generation request may be triggered by a user, or may be triggered when the database server detects a query requirement, and the generation of the dynamic generation request is not limited by the present invention.
The information carried in the dynamically generated request includes, but is not limited to: the query condition identification, etc.
The query condition identification refers to a label corresponding to the query condition.
In at least one embodiment of the present invention, the electronic device obtaining the query condition identifier from the dynamically generated request includes:
analyzing the message of the dynamic generation request to obtain message information carried by the dynamic generation request;
acquiring a first preset label from a configuration label library, wherein the first preset label is used for indicating a condition identifier;
and acquiring information corresponding to the first preset label from the message information as the query condition identifier.
The configuration tag library stores a plurality of predefined tags, and the configuration tag library is stored in the electronic device.
According to the embodiment, the whole dynamic generation request does not need to be analyzed, so that the analysis efficiency of the dynamic generation request is improved, and meanwhile, the message information only contains the information corresponding to the message, so that the query condition identification can be quickly obtained from the message information, and in addition, the query condition identification can be accurately determined through the mapping relation between the first preset label and the condition identification.
And S11, traversing the database server by using the query condition identification to obtain a traversal result.
In at least one embodiment of the invention, the database server may be a DataHandleServer.
The traversal result refers to a result corresponding to the query condition identifier, and the traversal result is a query parameter in the structured query statement. For example, the traversal result may be param 3.
Referring to FIG. 2, FIG. 2 is a flow chart of an embodiment of the present invention for determining traversal results. In at least one embodiment of the present invention, the traversing, by the electronic device, the database server by using the query condition identifier, and obtaining the traversal result includes:
s110, determining a data storage area in the database server, and determining a memory occupied by the area.
And S111, determining the number of threads according to the memory, and dividing the area into a plurality of partitions according to the number of the threads.
The number of partitions of the plurality of partitions is equal to the number of threads.
Specifically, the electronic device divides the memory by a preset value to obtain the number of threads.
The preset value can be configured according to an application scene.
And S112, acquiring all threads in the preset thread pool.
And a plurality of pre-established threads are stored in the preset thread pool.
S113, acquiring the processing efficiency of each thread and acquiring the thread state of each thread.
The thread states include: idle state, non-idle state. In addition, the value of the idle state may be set to 1, and the value of the non-idle state may be set to 0.
And S114, generating a thread score of each thread according to the processing efficiency, the thread state and a preset weight.
The preset weight may be determined according to an application scenario, and the setting of the preset weight is not limited in the present invention. The preset weight comprises a first weight and a second weight.
Specifically, the electronic device multiplies the processing efficiency by the first weight to obtain an efficiency score, multiplies the thread state by the second weight to obtain a state score, and calculates a sum of the efficiency score and the state score to obtain the thread score.
And S115, sequencing all the threads according to the sequence of the thread scores from large to small to obtain a thread queue.
S116, screening the first N threads from the thread queue as processing threads.
Wherein N is the number of threads.
And S117, traversing the plurality of partitions by using the processing thread based on the query condition identification to obtain the traversal result.
And storing the mapping relation between a plurality of condition identifications and the information corresponding to the condition identifications in the plurality of partitions.
The traversal results are query parameters in the structured query statement.
Specifically, the electronic device traverses the plurality of partitions in parallel by using the processing thread, determines information corresponding to the query condition identifier as the traversal result when any thread traverses the query condition identifier in any partition, and stops traversing the plurality of partitions.
By traversing the plurality of partitions in parallel using the processing thread, traversal efficiency can be improved.
The data storage area in the database server is divided into a plurality of partitions, and then the first N threads with the highest thread scores are used for traversing the plurality of partitions, so that the traversing efficiency of the processing threads can be improved, and the traversing result can be quickly obtained.
S12, detecting whether the traversal result meets preset parameters.
In at least one embodiment of the present invention, the preset parameter may be that the result is not null, or that the result value is smaller than a certain limit value. For example, the preset parameter is test ═ param 3! Null' and a. c3 # { param3 }.
In at least one embodiment of the present invention, the electronic device detecting whether the traversal result satisfies a preset parameter includes:
when a plurality of preset parameters exist, detecting whether the traversal result meets the preset parameters or not;
when the traversal results all meet a plurality of preset parameters, determining that the traversal results meet the preset parameters; or
And when the traversal results do not all meet the preset parameters, determining that the traversal results do not meet the preset parameters.
By the implementation mode, whether the traversal result meets the preset parameters or not can be accurately determined, the generation of the structured query statement is avoided when the traversal result does not meet the preset parameters, and the accuracy of the generation of the structured query statement is improved.
And S13, when the traversal result meets the preset parameters, obtaining a statement template identifier from the dynamic generation request.
In at least one embodiment of the invention, the statement template identification is used to uniquely identify a structured query statement template.
In at least one embodiment of the present invention, when the traversal result satisfies the preset parameter, it indicates that the dynamic generation request satisfies a condition, and then after the dynamic generation request satisfies the preset parameter, the statement template identifier is obtained from the dynamic generation request, so that the statement template identifier is prevented from being obtained when the dynamic generation request does not satisfy the preset parameter, and thus the utilization rate of the thread is improved.
In at least one embodiment of the present invention, the electronic device obtaining the statement template identifier from the dynamically generated request includes:
eliminating the query condition identification from the message information to obtain data information;
acquiring a second preset label from the configuration label library, wherein the second preset label is used for indicating a template identifier;
and acquiring information corresponding to the template identifier from the data information as the statement template identifier.
By the above embodiment, since the data information is obtained by removing the query condition identifier from the message information, the amount of information in the data information and the amount of information in the message information are small, so that the statement template identifier can be quickly obtained from the data information, and in addition, the statement template identifier can be accurately obtained through the mapping relationship between the second preset tag and the template identifier.
And S14, acquiring the target template corresponding to the sentence template identification from the database server.
In at least one embodiment of the invention, the target template refers to a query structured statement template.
In at least one embodiment of the present invention, the obtaining, by the electronic device, the target template corresponding to the sentence template identifier from the database server includes:
acquiring a template mapping table in the database server, wherein the template mapping table stores the mapping relation between a plurality of template identifications and storage positions;
acquiring a target position corresponding to the sentence template identification from the template mapping table;
extracting the target template from the target location.
Wherein the template mapping table is stored in the database server.
And the target template can be accurately acquired from the database server through the template mapping table.
And S15, writing the traversal result into the target template to generate a target structured query statement.
It is emphasized that, to further ensure the privacy and security of the target structured query statement, the target structured query statement may also be stored in a node of a blockchain. For example, the target structured query statement may be a select from table a where c1 # { param1} and a c2 # { param2} < if test ═ param 3! Null' and a. c3 # { param3} </if >.
In at least one embodiment of the invention, the target structured query statement is generated in real-time.
Referring to FIG. 3, FIG. 3 is a flow diagram of one embodiment of the present invention for generating a target structured query statement. In at least one embodiment of the present invention, the electronic device writes the traversal result into the target template, and generating the target structured query statement includes:
s150, determining a result label corresponding to the traversal result according to the configuration label library.
S151, determining the position of the result label in the target template.
S152, writing the traversal result into the target template according to the position to obtain the target structured query statement.
The result tag can be accurately determined through the configuration tag library, and then the position of the traversal result, which needs to be written in the target template, can be determined through the result tag, so that the target structured query statement can be accurately generated.
In at least one embodiment of the invention, after generating the target structured query statement, the method further comprises:
acquiring a request number of the dynamic generation request;
generating prompt information according to the request number and the target structured query statement;
determining the request grade of the dynamic generation request, and determining a sending mode according to the request grade;
and sending the prompt information in the sending mode.
By the implementation mode, the triggering user of the dynamic generation request can be reminded to receive the dynamic generation request in time after the target structured query statement is generated, and timeliness is improved.
According to the technical scheme, the query condition identification can be quickly acquired through the dynamic generation request, the result corresponding to the query condition identification can be quickly acquired from the database server by utilizing the query condition identification, the traversal result is detected, the condition in the generated target structured query statement can be ensured to meet the preset parameters, the traversal result is written into the target template, and the target structured query statement can be quickly generated. According to the invention, the target structured query statement is configured and generated in the database server in real time, so that the hot update service of the target structured query statement can be realized without restarting the service.
FIG. 4 is a functional block diagram of the apparatus for dynamically generating structured query statements according to the preferred embodiment of the present invention. The dynamic structured query statement generating device 11 includes an acquiring unit 110, a traversing unit 111, a detecting unit 112, a generating unit 113, a determining unit 114, and a sending unit 115. The module/unit referred to herein is a series of computer readable instruction segments that can be accessed by the processor 13 and perform a fixed function and that are stored in the memory 12. In the present embodiment, the functions of the modules/units will be described in detail in the following embodiments.
When receiving a dynamic generation request, the obtaining unit 110 obtains the query condition identifier from the dynamic generation request.
In at least one embodiment of the present invention, the dynamic generation request may be triggered by a user, or may be triggered when the database server detects a query requirement, and the generation of the dynamic generation request is not limited by the present invention.
The information carried in the dynamically generated request includes, but is not limited to: the query condition identification, etc.
The query condition identification refers to a label corresponding to the query condition.
In at least one embodiment of the present invention, the obtaining unit 110 obtains the query condition identifier from the dynamically generated request, including:
analyzing the message of the dynamic generation request to obtain message information carried by the dynamic generation request;
acquiring a first preset label from a configuration label library, wherein the first preset label is used for indicating a condition identifier;
and acquiring information corresponding to the first preset label from the message information as the query condition identifier.
The configuration tag library stores a plurality of predefined tags, and is stored in the electronic device.
According to the embodiment, the whole dynamic generation request does not need to be analyzed, so that the analysis efficiency of the dynamic generation request is improved, and meanwhile, the message information only contains the information corresponding to the message, so that the query condition identification can be quickly obtained from the message information, and in addition, the query condition identification can be accurately determined through the mapping relation between the first preset label and the condition identification.
The traversal unit 111 traverses the database server by using the query condition identifier to obtain a traversal result.
In at least one embodiment of the invention, the database server may be a DataHandleServer.
The traversal result refers to a result corresponding to the query condition identification, and the traversal result may be param 3.
In at least one embodiment of the present invention, the traversing unit 111 traverses the database server by using the query condition identifier, and obtaining a traversal result includes:
and determining the data storage area in the database server and determining the memory occupied by the area.
And determining the number of threads according to the memory, and dividing the area into a plurality of partitions according to the number of the threads.
The number of partitions of the plurality of partitions is equal to the number of threads.
And acquiring all threads in the preset thread pool.
And a plurality of pre-established threads are stored in the preset thread pool.
And acquiring the processing efficiency of each thread and acquiring the thread state of each thread.
The thread states include: idle state, non-idle state. In addition, the value of the idle state may be set to 1, and the value of the non-idle state may be set to 0.
And generating a thread score of each thread according to the processing efficiency, the thread state and a preset weight.
The preset weight may be determined according to an application scenario, and the setting of the preset weight is not limited in the present invention.
And sequencing all the threads according to the sequence of the thread scores from large to small to obtain a thread queue.
And screening the first N threads from the thread queue as processing threads.
And N is the number of the threads.
And traversing the plurality of partitions by utilizing the processing thread based on the query condition identification to obtain the traversal result.
The data storage area in the database server is divided into a plurality of partitions, and then the first N threads with the highest thread scores are used for traversing the plurality of partitions, so that the traversing efficiency of the processing threads can be improved, and the traversing result can be quickly obtained.
The detection unit 112 detects whether the traversal result satisfies a preset parameter.
In at least one embodiment of the present invention, the preset parameter may be that the result is not null, or that the result value is smaller than a certain limit value. For example, the preset parameter is test ═ param 3! Null' and a. c3 # { param3 }.
In at least one embodiment of the present invention, the detecting unit 112 detects whether the traversal result satisfies a preset parameter includes:
when a plurality of preset parameters exist, detecting whether the traversal result meets the preset parameters or not;
when the traversal results all meet a plurality of preset parameters, determining that the traversal results meet the preset parameters; or
And when the traversal results do not all meet the preset parameters, determining that the traversal results do not meet the preset parameters.
By the implementation mode, whether the traversal result meets the preset parameters or not can be accurately determined, the generation of the structured query statement is avoided when the traversal result does not meet the preset parameters, and the accuracy of the generation of the structured query statement is improved.
When the traversal result satisfies the preset parameter, the obtaining unit 110 obtains a statement template identifier from the dynamic generation request.
In at least one embodiment of the invention, the statement template identification is used to uniquely identify a structured query statement template.
In at least one embodiment of the present invention, when the traversal result satisfies the preset parameter, it indicates that the dynamic generation request satisfies a condition, and then after the dynamic generation request satisfies the preset parameter, the statement template identifier is obtained from the dynamic generation request, so that the statement template identifier is prevented from being obtained when the dynamic generation request does not satisfy the preset parameter, and thus the utilization rate of the thread is improved.
In at least one embodiment of the present invention, the obtaining unit 110 obtains the statement template identifier from the dynamically generated request, including:
eliminating the query condition identification from the message information to obtain data information;
acquiring a second preset label from the configuration label library, wherein the second preset label is used for indicating a template identifier;
and acquiring information corresponding to the template identifier from the data information as the statement template identifier.
By the above embodiment, since the data information is obtained by removing the query condition identifier from the message information, the amount of information in the data information and the amount of information in the message information are small, so that the statement template identifier can be quickly obtained from the data information, and in addition, the statement template identifier can be accurately obtained through the mapping relationship between the second preset tag and the template identifier.
The obtaining unit 110 obtains a target template corresponding to the sentence template identifier from the database server.
In at least one embodiment of the invention, the target template refers to a query structured statement template.
In at least one embodiment of the present invention, the obtaining unit 110 obtains the target template corresponding to the sentence template identifier from the database server includes:
acquiring a template mapping table in the database server, wherein the template mapping table stores the mapping relation between a plurality of template identifications and storage positions;
acquiring a target position corresponding to the sentence template identification from the template mapping table;
extracting the target template from the target location.
Wherein the template mapping table is stored in the database server.
And the target template can be accurately acquired from the database server through the template mapping table.
The generating unit 113 writes the traversal result into the target template, and generates a target structured query statement.
It is emphasized that, to further ensure the privacy and security of the target structured query statement, the target structured query statement may also be stored in a node of a blockchain.
In at least one embodiment of the invention, the target structured query statement is generated in real-time.
In at least one embodiment of the present invention, the generating unit 113 writes the traversal result into the target template, and generating the target structured query statement includes:
and determining a result label corresponding to the traversal result according to the configuration label library.
Determining a location of the result tag in the target template.
And writing the traversal result into the target template according to the position to obtain the target structured query statement.
The result tag can be accurately determined through the configuration tag library, and then the position of the traversal result, which needs to be written in the target template, can be determined through the result tag, so that the target structured query statement can be accurately generated.
In at least one embodiment of the present invention, after generating the target structured query statement, the method obtaining unit 110 obtains the request number of the dynamic generation request;
the generating unit 113 generates prompt information according to the request number and the target structured query statement;
the determining unit 114 determines the request level of the dynamic generation request and determines the sending mode according to the request level;
the transmitting unit 115 transmits the prompt information in the transmission manner.
By the implementation mode, the triggering user of the dynamic generation request can be reminded to receive the dynamic generation request in time after the target structured query statement is generated, and timeliness is improved.
According to the technical scheme, the query condition identification can be quickly acquired through the dynamic generation request, the result corresponding to the query condition identification can be quickly acquired from the database server by utilizing the query condition identification, the traversal result is detected, the condition in the generated target structured query statement can be ensured to meet the preset parameters, the traversal result is written into the target template, and the target structured query statement can be quickly generated. According to the invention, the target structured query statement is configured and generated in the database server in real time, so that the hot update service of the target structured query statement can be realized without restarting the service.
Fig. 5 is a schematic structural diagram of an electronic device implementing the method for dynamically generating a structured query statement according to a preferred embodiment of the present invention.
In one embodiment of the present invention, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and computer readable instructions, such as a structured query statement dynamic generation program, stored in the memory 12 and executable on the processor 13.
It will be appreciated by a person skilled in the art that the schematic diagram is only an example of the electronic device 1 and does not constitute a limitation of the electronic device 1, and that it may comprise more or less components than shown, or some components may be combined, or different components, e.g. the electronic device 1 may further comprise an input output device, a network access device, a bus, etc.
The Processor 13 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. The processor 13 is an operation core and a control center of the electronic device 1, and is connected to each part of the whole electronic device 1 by various interfaces and lines, and executes an operating system of the electronic device 1 and various installed application programs, program codes, and the like.
Illustratively, the computer readable instructions may be partitioned into one or more modules/units that are stored in the memory 12 and executed by the processor 13 to implement the present invention. The one or more modules/units may be a series of computer readable instruction segments capable of performing specific functions, which are used for describing the execution process of the computer readable instructions in the electronic device 1. For example, the computer readable instructions may be partitioned into an acquisition unit 110, a traversal unit 111, a detection unit 112, a generation unit 113, a determination unit 114, and a transmission unit 115.
The memory 12 may be used for storing the computer readable instructions and/or modules, and the processor 13 implements various functions of the electronic device 1 by executing or executing the computer readable instructions and/or modules stored in the memory 12 and invoking data stored in the memory 12. The memory 12 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data created according to use of the electronic device, and the like. The memory 12 may include non-volatile and volatile memories, such as: a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other storage device.
The memory 12 may be an external memory and/or an internal memory of the electronic device 1. Further, the memory 12 may be a memory having a physical form, such as a memory stick, a TF Card (Trans-flash Card), or the like.
The integrated modules/units of the electronic device 1 may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, all or part of the flow of the method according to the above embodiments may be implemented by hardware that is configured to be instructed by computer readable instructions, which may be stored in a computer readable storage medium, and when the computer readable instructions are executed by a processor, the steps of the method embodiments may be implemented.
Wherein the computer readable instructions comprise computer readable instruction code which may be in source code form, object code form, an executable file or some intermediate form, and the like. The computer-readable medium may include: any entity or device capable of carrying said computer readable instruction code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM).
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
In conjunction with fig. 1, the memory 12 in the electronic device 1 stores computer readable instructions to implement a method for dynamically generating a structured query statement, and the processor 13 can execute the computer readable instructions to implement:
when a dynamic generation request is received, acquiring a query condition identifier from the dynamic generation request;
traversing the database server by using the query condition identifier to obtain a traversal result;
detecting whether the traversal result meets preset parameters or not;
when the traversal result meets the preset parameters, obtaining a statement template identifier from the dynamic generation request;
acquiring a target template corresponding to the sentence template identification from the database server;
and writing the traversal result into the target template to generate a target structured query statement.
Specifically, the processor 13 may refer to the description of the relevant steps in the embodiment corresponding to fig. 1 for a specific implementation method of the computer readable instructions, which is not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The computer readable storage medium has computer readable instructions stored thereon, wherein the computer readable instructions when executed by the processor 13 are configured to implement the steps of:
when a dynamic generation request is received, acquiring a query condition identifier from the dynamic generation request;
traversing the database server by using the query condition identifier to obtain a traversal result;
detecting whether the traversal result meets preset parameters or not;
when the traversal result meets the preset parameters, obtaining a statement template identifier from the dynamic generation request;
acquiring a target template corresponding to the sentence template identification from the database server;
and writing the traversal result into the target template to generate a target structured query statement.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. The plurality of units or devices may also be implemented by one unit or device through software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. A dynamic generation method of a structured query statement is applied to electronic equipment, and the electronic equipment is connected with a database server, and is characterized in that the dynamic generation method of the structured query statement comprises the following steps:
when a dynamic generation request is received, acquiring a query condition identifier from the dynamic generation request;
traversing the database server by using the query condition identifier to obtain a traversal result;
detecting whether the traversal result meets preset parameters or not;
when the traversal result meets the preset parameters, obtaining a statement template identifier from the dynamic generation request;
acquiring a target template corresponding to the sentence template identification from the database server;
and writing the traversal result into the target template to generate a target structured query statement.
2. The method for dynamically generating structured query statements according to claim 1, wherein said traversing the database server using the query condition identifier to obtain a traversal result comprises:
determining a data storage area in the database server, and determining a memory occupied by the area;
determining the number of threads according to the memory, and dividing the area into a plurality of partitions according to the number of the threads;
acquiring all threads in a preset thread pool;
acquiring the processing efficiency of each thread and acquiring the thread state of each thread;
generating a thread score of each thread according to the processing efficiency, the thread state and a preset weight;
sequencing all threads according to the sequence of the thread scores from large to small to obtain a thread queue;
screening the first N threads from the thread queue as processing threads;
and traversing the plurality of partitions by utilizing the processing thread based on the query condition identification to obtain the traversal result.
3. The method for dynamically generating structured query statements according to claim 1, wherein said detecting whether the traversal result satisfies a preset parameter comprises:
when a plurality of preset parameters exist, detecting whether the traversal result meets the preset parameters or not;
when the traversal results all meet a plurality of preset parameters, determining that the traversal results meet the preset parameters; or
And when the traversal results do not all meet the preset parameters, determining that the traversal results do not meet the preset parameters.
4. The method for dynamically generating structured query statements according to claim 1, wherein said obtaining query condition identifications from said dynamically generated request comprises:
analyzing the message of the dynamic generation request to obtain message information carried by the dynamic generation request;
acquiring a first preset label from a configuration label library, wherein the first preset label is used for indicating a condition identifier;
and acquiring information corresponding to the first preset label from the message information as the query condition identifier.
5. The method of claim 4, wherein the obtaining a statement template token from the dynamically generated request comprises:
eliminating the query condition identification from the message information to obtain data information;
acquiring a second preset label from the configuration label library, wherein the second preset label is used for indicating a template identifier;
and acquiring information corresponding to the template identifier from the data information as the statement template identifier.
6. The method for dynamically generating structured query statements according to claim 4, wherein said writing said traversal results into said target template, generating a target structured query statement comprises:
determining a result label corresponding to the traversal result according to the configuration label library;
determining a location of the result tag in the target template;
and writing the traversal result into the target template according to the position to obtain the target structured query statement.
7. The method for dynamically generating structured query statements according to claim 1, wherein said obtaining a target template corresponding to said statement template identity from said database server comprises:
acquiring a template mapping table in the database server, wherein the template mapping table stores the mapping relation between a plurality of template identifications and storage positions;
acquiring a target position corresponding to the sentence template identification from the template mapping table;
extracting the target template from the target location.
8. A dynamic generation device of a structured query statement, which runs in an electronic device connected to a database server, is characterized in that the dynamic generation device of a structured query statement comprises:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring query condition identification from a dynamic generation request when the dynamic generation request is received;
the traversal unit is used for traversing the database server by using the query condition identifier to obtain a traversal result;
the detection unit is used for detecting whether the traversal result meets preset parameters or not;
the obtaining unit is further configured to obtain a statement template identifier from the dynamic generation request when the traversal result meets the preset parameter;
the obtaining unit is further configured to obtain a target template corresponding to the sentence template identifier from the database server;
and the generating unit is used for writing the traversal result into the target template to generate a target structured query statement.
9. An electronic device, characterized in that the electronic device comprises:
a memory storing computer readable instructions; and
a processor executing computer readable instructions stored in the memory to implement the method of dynamically generating structured query statements as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium characterized by: the computer-readable storage medium stores therein computer-readable instructions which are executed by a processor in an electronic device to implement the method for dynamically generating the structured query statement according to any one of claims 1 to 7.
CN202011504603.7A 2020-12-18 2020-12-18 Dynamic generation method of structured query statement and related equipment Pending CN112632098A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011504603.7A CN112632098A (en) 2020-12-18 2020-12-18 Dynamic generation method of structured query statement and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011504603.7A CN112632098A (en) 2020-12-18 2020-12-18 Dynamic generation method of structured query statement and related equipment

Publications (1)

Publication Number Publication Date
CN112632098A true CN112632098A (en) 2021-04-09

Family

ID=75317019

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011504603.7A Pending CN112632098A (en) 2020-12-18 2020-12-18 Dynamic generation method of structured query statement and related equipment

Country Status (1)

Country Link
CN (1) CN112632098A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113448980A (en) * 2021-06-18 2021-09-28 青岛海尔科技有限公司 Method and device for generating SQL (structured query language) statement and electronic equipment
CN114281841A (en) * 2021-12-07 2022-04-05 四川新网银行股份有限公司 Method for generating configuration SQL statement based on business requirement
CN114490723A (en) * 2022-02-23 2022-05-13 阿波罗智联(北京)科技有限公司 Unified retrieval method, device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040177093A1 (en) * 2003-03-06 2004-09-09 Ward Mullins Displayable presentation page and SQL searchable relational data source implementation of a system, method and software for creating or maintaining distributed transparent persistence of complex data objects and their data relationships
CN104317926A (en) * 2014-10-31 2015-01-28 北京思特奇信息技术股份有限公司 Persistent data storage method, persistent data query method, persistent data storage device and persistent data query system
CN108921712A (en) * 2018-06-13 2018-11-30 泰康保险集团股份有限公司 Data processing method, device, medium and electronic equipment
CN109947788A (en) * 2017-10-30 2019-06-28 北京京东尚科信息技术有限公司 Data query method and apparatus

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040177093A1 (en) * 2003-03-06 2004-09-09 Ward Mullins Displayable presentation page and SQL searchable relational data source implementation of a system, method and software for creating or maintaining distributed transparent persistence of complex data objects and their data relationships
CN104317926A (en) * 2014-10-31 2015-01-28 北京思特奇信息技术股份有限公司 Persistent data storage method, persistent data query method, persistent data storage device and persistent data query system
CN109947788A (en) * 2017-10-30 2019-06-28 北京京东尚科信息技术有限公司 Data query method and apparatus
CN108921712A (en) * 2018-06-13 2018-11-30 泰康保险集团股份有限公司 Data processing method, device, medium and electronic equipment

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113448980A (en) * 2021-06-18 2021-09-28 青岛海尔科技有限公司 Method and device for generating SQL (structured query language) statement and electronic equipment
CN114281841A (en) * 2021-12-07 2022-04-05 四川新网银行股份有限公司 Method for generating configuration SQL statement based on business requirement
CN114490723A (en) * 2022-02-23 2022-05-13 阿波罗智联(北京)科技有限公司 Unified retrieval method, device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN112632098A (en) Dynamic generation method of structured query statement and related equipment
CN112632163B (en) Big data report export method and related equipment
CN112948418A (en) Dynamic query method, device, equipment and storage medium
CN112199494A (en) Medical information searching method and device, electronic equipment and storage medium
CN112711398A (en) Method, device and equipment for generating buried point file and storage medium
CN114372060A (en) Data storage method, device, equipment and storage medium
CN114510487A (en) Data table merging method, device, equipment and storage medium
CN114116108A (en) Dynamic rendering method, device, equipment and storage medium
CN114418398A (en) Scene task development method, device, equipment and storage medium
CN112819305A (en) Service index analysis method, device, equipment and storage medium
CN112181485A (en) Script execution method and device, electronic equipment and storage medium
CN112199364A (en) Data cleaning method and device, electronic equipment and storage medium
CN112434062A (en) Quasi-real-time data processing method, device, server and storage medium
CN111933241A (en) Medical data analysis method, medical data analysis device, electronic device, and storage medium
CN113282218A (en) Multi-dimensional report generation method, device, equipment and storage medium
CN115794621A (en) Code coverage test method, device, equipment and storage medium
CN115205032A (en) Credit investigation query method, apparatus, device and storage medium
CN114692204A (en) Data query method, device, equipment and storage medium
CN114741259A (en) Motion trajectory generation method, device, equipment and storage medium
CN114490262A (en) Database monitoring method, device, equipment and storage medium
CN114003784A (en) Request recording method, device, equipment and storage medium
CN112434237A (en) Page loading method and device, electronic equipment and storage medium
CN114187050A (en) Card and ticket issuing monitoring method, device, equipment and storage medium
CN113886263A (en) System testing method, device, equipment and storage medium
CN112527830A (en) Data query method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
AD01 Patent right deemed abandoned

Effective date of abandoning: 20240628

AD01 Patent right deemed abandoned