CN115981791A - System interaction method, device, equipment and storage medium - Google Patents

System interaction method, device, equipment and storage medium Download PDF

Info

Publication number
CN115981791A
CN115981791A CN202310042058.1A CN202310042058A CN115981791A CN 115981791 A CN115981791 A CN 115981791A CN 202310042058 A CN202310042058 A CN 202310042058A CN 115981791 A CN115981791 A CN 115981791A
Authority
CN
China
Prior art keywords
target
language
sql statement
converted
command
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
CN202310042058.1A
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.)
Advanced New Technologies Co Ltd
Original Assignee
Advanced New Technologies 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 Advanced New Technologies Co Ltd filed Critical Advanced New Technologies Co Ltd
Priority to CN202310042058.1A priority Critical patent/CN115981791A/en
Publication of CN115981791A publication Critical patent/CN115981791A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • G06F9/45516Runtime code conversion or optimisation
    • 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
    • G06F16/2448Query languages for particular applications; for extensibility, e.g. user defined types
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Devices For Executing Special Programs (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application provides a system interaction method, a device, equipment and a storage medium, and relates to the technical field of computers. The method comprises the following steps: analyzing the target SQL statement and determining an element to be converted in the target SQL statement; converting the element to be converted into an operation command corresponding to a target command language of a target operation system based on a preset mapping relation, wherein the preset mapping relation comprises a mapping relation between a language element in a target SQL statement and the operation command of the target command language; and generating a command statement corresponding to the target command language based on the converted target SQL statement so as to interact with the target operating system based on the command statement. According to the technical scheme, the SQL language can be interacted with the operating system, a large amount of time and energy are not needed to be spent on learning the command language, and the use threshold of interaction between the command language and the operating system is lowered.

Description

System interaction method, device, equipment and storage medium
The patent application of the invention is a divisional application of Chinese invention patent applications with the application date of 2019, 5 and 23 months, and the application number of 201910435910.5, and the name of system interaction method, device, equipment and storage medium.
Technical Field
The present application relates to the field of computer technologies, and in particular, to a system interaction method, a system interaction apparatus, a system interaction device, and a computer-readable storage medium.
Background
With the rapid development of computer technology, users interact with operating systems more and more, and how to interact with operating systems better becomes a focus of attention.
Currently, users interact with operating systems primarily through command languages. The command language is a language used by an operating system, and is capable of parsing and executing an operation command input by a user. However, since command languages such as powershell language are not commonly used program languages, the operation commands of the command language are unfamiliar to many users, and it takes much time and effort to learn the command language by directly interacting with the operating system through the command language, and the work efficiency of interacting with the operating system through the command language is low for such users.
Disclosure of Invention
The embodiment of the application aims to provide a system interaction method, a system interaction device, system interaction equipment and a computer readable storage medium, so as to improve the working efficiency of interaction between a user and an operating system through a command language.
In order to solve the above technical problem, the embodiment of the present application is implemented as follows:
according to a first aspect of embodiments of the present application, a system interaction method is provided, including:
analyzing a target Structured Query Language (SQL) statement, and generating an abstract syntax tree corresponding to the target SQL statement based on an analysis result; traversing the abstract syntax tree, and determining nodes to be converted of the abstract syntax tree based on the types of language elements corresponding to the traversed nodes; taking the language elements corresponding to the nodes to be converted as the elements to be converted in the target SQL sentences;
converting the element to be converted in the target SQL statement into an operation command corresponding to a target command language of a target operating system based on a preset mapping relation so as to obtain a converted target SQL statement; the preset mapping relation comprises a mapping relation between a language element in the target SQL statement and an operation command of the target command language;
and generating a command statement corresponding to the target command language based on the converted target SQL statement.
In an exemplary embodiment of the present application, parsing a target SQL statement based on the above scheme, and generating an abstract syntax tree corresponding to the target SQL statement based on a parsing result includes: performing lexical analysis on the target SQL statement to generate a plurality of language elements corresponding to the target SQL statement; parsing the target SQL statement to generate the abstract syntax tree corresponding to the target SQL statement based on the plurality of language elements.
In an exemplary embodiment of the present application, traversing the abstract syntax tree based on the above scheme includes: traversing the abstract syntax tree based on a visitor pattern and a breadth traversal pattern.
In an example embodiment of the present application, based on the above scheme, the target operating system is a windows operating system, and the target command language is powershell language.
According to a second aspect of an example of the present application, there is provided a system interaction apparatus, comprising: the analysis module is used for analyzing the target SQL statement and generating an abstract syntax tree corresponding to the target SQL statement based on an analysis result; traversing the abstract syntax tree, and determining nodes to be converted of the abstract syntax tree based on the types of language elements corresponding to the traversed nodes; taking the language elements corresponding to the nodes to be converted as the elements to be converted in the target SQL sentences; the conversion module is used for converting the elements to be converted in the target SQL sentences into operation commands corresponding to a target command language of a target operating system so as to obtain converted target SQL sentences; the preset mapping relation comprises a mapping relation between a language element in the target SQL statement and an operation command of the target command language; and the generating module is used for generating a command statement corresponding to the target command language based on the converted target SQL statement.
In an example embodiment of the present application, based on the above scheme, the parsing module includes: the lexical analysis unit is used for carrying out lexical analysis on the target SQL statement and generating a plurality of language elements corresponding to the target SQL statement; and the syntax analysis unit is used for carrying out syntax analysis on the target SQL statement so as to generate the abstract syntax tree corresponding to the target SQL statement based on the plurality of language elements.
In an example embodiment of the present application, based on the above scheme, the parsing module traverses the abstract syntax tree based on a visitor pattern and a breadth traversal mode.
In an example embodiment of the present application, based on the above scheme, the target operating system is a windows operating system, and the target command language is powershell language.
According to a third aspect of embodiments of the present application, there is provided a system interaction device, including: a processor; and a memory configured to store computer executable instructions that, when executed, cause the processor to implement the steps of the system interaction method of any of the first aspects described above.
According to a fourth aspect of embodiments herein, there is provided a storage medium for storing computer-executable instructions that, when executed, implement the steps of the system interaction method of any one of the above first aspects.
According to the technical scheme in the embodiment of the application, on one hand, the target SQL statement is analyzed, the elements to be converted in the target SQL statement are determined, and the language elements needing to be converted in the target SQL statement can be accurately determined; on the other hand, the elements to be converted are converted into the operation commands corresponding to the target command language based on the preset mapping relation, so that the elements to be converted in the target SQL statement can be efficiently converted into the operation commands corresponding to the target command language, and the conversion efficiency is improved; on the other hand, the command statement corresponding to the target command language is generated to interact with the target operating system based on the command statement, the command statement can interact with the operating system through the SQL language, a large amount of time and energy are not needed to be spent on learning the command language, the use threshold of interaction between the command language and the operating system is reduced, and the working efficiency of interaction between the user and the operating system through the command language is improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without any creative effort.
FIG. 1 illustrates a flow diagram of a system interaction method provided in accordance with some embodiments of the present application;
FIG. 2 illustrates a flow diagram for determining an element to be converted in a target SQL statement according to some embodiments of the present application;
FIG. 3 illustrates a schematic diagram of an abstract syntax tree corresponding to a target SQL statement provided in accordance with some embodiments of the present application;
FIG. 4 illustrates a flow diagram of a system interaction method provided in accordance with further embodiments of the present application;
FIG. 5 illustrates a schematic block diagram of a system interaction device provided in accordance with some embodiments of the present application;
FIG. 6 illustrates a schematic block diagram of a parsing module provided in accordance with some embodiments of the present application;
FIG. 7 illustrates a schematic block diagram of a translation module provided in accordance with some embodiments of the present application;
fig. 8 illustrates a schematic block diagram of a system interaction device provided in accordance with some embodiments of the present application.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
SQL (Structured Query Language) Language is a general-purpose data Query Language that is learned and accepted by most people. If the SQL language can be used for interacting with the operating system, namely the SQL statement is converted into the command statement corresponding to the command language, the use threshold of interaction between the user and the operating system through the command language can be greatly reduced, and the working efficiency of interaction between the user and the operating system through the command language is improved.
Based on the above, the present application first provides a system interaction method. Fig. 1 illustrates a flow diagram of a system interaction method provided in accordance with some embodiments of the present application. The system interaction method can be applied to terminal equipment and executed by the terminal equipment, and the terminal equipment comprises but is not limited to a desktop computer, a portable notebook computer or a tablet computer. Referring to fig. 1, the system interaction method includes steps S110 to S130, and the system interaction method in the exemplary embodiment of the present application is described in detail below with reference to fig. 1.
Referring to fig. 1, in step S110, the target SQL statement is parsed, and an element to be converted in the target SQL statement is determined.
In an example embodiment, the element to be converted in the target SQL statement represents a language element of the target SQL statement that needs to be converted into the operation command in the target command language. The language elements in the SQL statement represent lexical units in the SQL language, and the types of the language elements in the SQL language may include: the element to be converted in the SQL statement can comprise the keyword and/or the identifier in the SQL statement. By way of example, the keywords in the SQL statement may include: insert, delete, update, select, from, where, and, or, not, etc.; the identifier in the SQL statement may include: database names, table names, file names, path names, etc.; the literal volume in an SQL statement may include: numbers, strings, percentages, etc.; the operators may include: +, -, +, > and the like; delimiters in the SQL statement may include: commas, semicolons, quotations, etc.
In an example embodiment, the target SQL statement is parsed, a keyword and/or an identifier in the target SQL statement are determined, and the determined keyword and/or identifier is used as an element to be converted in the target SQL statement. For example, let the target SQL statement be select files from mycomputer where path =' E: \ music', this SQL statement is used to view the directory E of the computer named mycomputer: after analyzing the target SQL statement, generating a plurality of language elements corresponding to the target SQL statement, wherein the types of the language elements "select", "from", "where" are keywords, and the types of the language elements "files", "mycumuputer" and "path" are identifiers; the type of the language element "=", "quotation mark", is a delimiter; the language element "E: the type of music is the font size, i.e., the font size of the string.
In this exemplary embodiment, the keywords select, from, where, identifiers files, mycomputer, and path in the target SQL statement need to be transformed, so the language elements select, from, where, files, mycomputer, and path are used as the elements to be transformed in the target SQL statement.
Further, in the example embodiment, the lexical analysis and the syntactic analysis are performed on the target SQL statement, the element to be converted of the target SQL statement is determined based on the analysis result, for example, a keyword and/or an identifier in the target SQL statement is determined based on the analysis result, and the determined keyword and/or identifier is used as the element to be converted of the target SQL statement.
In step S120, based on a preset mapping relationship, converting an element to be converted in the target SQL statement into an operation command corresponding to a target command language of the target operating system, so as to obtain a converted target SQL statement; the preset mapping relation comprises a mapping relation between a language element in the target SQL statement and an operation command of the target command language.
In an example embodiment, the target operating system is a windows operating system, the target command language is powershell language, the command language is a language used by the operating system, and interaction between a user and the operating system is achieved through the command language. The preset mapping relationship includes a mapping relationship between a language element in the target SQL statement and an operation command in the target command language, and the mapping relationship between the language element in the target SQL statement and the operation command in the target command language may be a one-to-one or many-to-one mapping relationship, that is, a mapping relationship in which one language element is mapped to one operation command or a plurality of language elements are mapped to one operation command. In an example embodiment, the preset mapping relationship may be implemented by MAP, or may be implemented by other suitable manners, such as key value pairs, which is not particularly limited in this application. Further, the elements to be converted in the target SQL statement are converted into corresponding operation commands in the preset mapping relationship based on the preset mapping relationship.
For example, setting the target command language as powershell language, the one-to-one mapping relationship between the language element of SQL language and the operation command of powershell language may include: insert to write, update to set, select to get, etc.; the many-to-one mapping relationship between the SQL language and the powershell language can include: select content from maps to get-content; select files from maps to get-childitem, select files from 8230, where page maps to get-childitem-page, etc. Thus, in an example embodiment, select content from in the target SQL statement is converted to get-content in the powershell language; mapping select files from in the target SQL statement to get-child in the powershell language; the select files from 8230in the target SQL statement is converted into get-child-path in powershell language.
It should be noted that, in the exemplary embodiment of the present application, the target operating system may also be a Linux operating system or a MacOS operating system, and the corresponding target command language may be a shell language or another suitable command language, which is not particularly limited in this application.
In step S130, based on the converted target SQL statement, a command statement corresponding to the target command language is generated to interact with the target operating system based on the command statement.
In an example embodiment, after the element to be converted of the target SQL statement is converted into the operation command corresponding to the target command language, the converted target SQL statement is processed to generate a command statement corresponding to the target command language, and the command statement is executed to interact with the target operating system. Processing the converted target SQL statement may include: it is also within the scope of the present application to delete redundant language elements, such as redundant identifiers, in the target SQL statement or replace language elements in the target SQL statement with language elements of the target command language, or to include other suitable processes.
For example, let the target command language be powershell language, let the target SQL statement be select files from mycomputer where path =' E: \ music', the preset mapping relationship comprises: select files from 8230, where. get-child-path mycomputer' E: \ music', the converted target SQL statement is processed, namely the redundant identifier mycomputer is deleted (the operating system defaults that the computer is the currently logged-in computer), and a command statement of powershell language corresponding to the target SQL statement is generated: get-childitem-path E: \ music, interacting with a target operating system based on the command statement, and returning a file list under the folder music of the E disk under the computer which logs in currently.
According to the system interaction method in the example embodiment of fig. 1, on one hand, a target SQL statement is analyzed, elements to be converted in the target SQL statement are determined, and language elements required to be converted in the target SQL statement can be accurately determined; on the other hand, the elements to be converted are converted into the operation commands corresponding to the target command language based on the preset mapping relation, so that the elements to be converted in the target SQL statement can be efficiently converted into the operation commands corresponding to the target command language, and the conversion efficiency is improved; on the other hand, the command statement corresponding to the target command language is generated to interact with the target operating system based on the command statement, the SQL language can interact with the operating system, a great deal of time and energy are not needed to be spent on learning the command language, and the use threshold of interaction with the operating system through the command language is reduced.
Fig. 2 illustrates a flow diagram for determining an element to be converted in a target SQL statement according to some embodiments of the present application.
Referring to fig. 2, in step S210, the target SQL statement is parsed, and an abstract syntax tree corresponding to the target SQL statement is generated based on the parsing result.
In an example embodiment, a lexical analysis is performed on a target SQL statement to generate a plurality of language elements corresponding to the target SQL statement. For example, let the target SQL statement be select myfile from mycomputer where path =' E: \ music', after parsing the target SQL statement, the following language elements are generated: select, myfile, from, mycomputer, where, path, =, E: \\ music.
Further, in the example embodiment, the types of the respective linguistic elements in the target SQL statement are determined, for example, the types of the linguistic elements "select", "from", "where" are keywords, and the types of the linguistic elements "myfile", "mycenuter", "path" are identifiers; the type of the linguistic element "=" is a delimiter; the language element "E: the type of music is the character string size.
Furthermore, the target SQL statement is analyzed in syntax, and an abstract syntax tree corresponding to the target SQL statement is generated. For example, the syntax parser sequentially obtains syntax elements in the target SQL statement, and generates a corresponding abstract syntax tree based on the obtained syntax elements. In an example embodiment, the target SQL statement may be parsed by the SQL parser to generate an abstract syntax tree corresponding to the target SQL statement. It should be noted that the target SQL statement may also be parsed by another suitable parser, such as ANTLR or JsqlParser, which is not particularly limited in this application.
Figure 3 illustrates a schematic diagram of an abstract syntax tree corresponding to a target SQL statement provided in accordance with some embodiments of the present application. Referring to FIG. 3, the target SQL statement is select content from mycomputer where path =' E: \ myfile', the target SQL statement is used to get the directory E: under root node root, the file content of the myfile under myfile contains a plurality of syntax elements of a target SQL statement, and the syntax elements are arranged according to the sequence of syntax rules, wherein keywords select, from and where are used as child nodes of the root node, identifiers in the SQL statement are used as identifiers defined in the syntax rules, mycomputer is used as child nodes of identifiers computername defined in the syntax rules, an identifier path is used as an identifier defined in the syntax rules, and the word size E: \ myfile is a child node of the identifier path.
In step S220, the abstract syntax tree is traversed, and a node to be converted of the abstract syntax tree is determined based on the type of the language element corresponding to the traversed node.
In an example embodiment, the abstract syntax tree is traversed in a breadth traversal mode, whether the type of the language element corresponding to the traversed node is a keyword or an identifier is determined, and the node of which the type of the language element is the keyword or the identifier is determined as a node to be converted of the abstract syntax tree. For example, the types of the language elements "select", "from", "where" are keywords, and the types of the language elements "content", "mycomputer", "path" are identifiers; the type of the linguistic element "=" is a delimiter; the language element "E: the type of music is literal. It should be noted that the abstract syntax tree may also be traversed in a deep traversal manner or other suitable traversal manners, which is not particularly limited in this application.
In step S230, the language element corresponding to the node to be converted of the abstract syntax tree is used as the element to be converted in the target SQL statement.
In an example embodiment, a language element corresponding to a node to be converted of the abstract syntax tree is used as an element to be converted in the target SQL statement. For example, in the above embodiment, "select", "content", "from", "where", "mycommuter", "path" corresponding to the node to be converted is determined as the element to be converted in the SQL statement.
Further, in an example embodiment, based on the preset mapping relationship, the element to be converted of the target SQL statement is converted into an operation command corresponding to a target command language of the target operating system. For example, a select content from keyword is converted into a get-content command in powershell language, and the converted target SQL statement becomes get-content-path-mycomputer E: \\ myfile.
Next, a command statement corresponding to the target command language is generated based on the converted target SQL statement to interact with the target operating system based on the command statement. In an example embodiment, the converted target SQL statement is processed to generate a command corresponding to the target command language, for example, let the converted target SQL statement change to get-content-path-mycomputer E: \ myfile, deleting redundant language elements such as mycomputer (i.e. defaulted to the currently logged computer) in the target SQL statement, and generating a corresponding command statement, i.e. get-content-path E: \ myfile, executing the generated command statement, and returning the file content of the myfile by the operating system.
FIG. 4 illustrates a flow diagram of a system interaction method provided in accordance with further embodiments of the present application.
Referring to fig. 4, in step S410, the target SQL statement is parsed to generate an abstract syntax tree corresponding to the target SQL statement.
In an example embodiment, a lexical analysis is performed on a target SQL statement to generate a plurality of language elements corresponding to the target SQL statement. For example, let the target SQL statement be select from mycomputer where path =' C: after parsing the target SQL statement, the following language elements are generated: select, from, mycomputer, where, path, =, C: \ is used.
Further, in an example embodiment, the types of the respective linguistic elements in the target SQL statement are determined, for example, the types of the linguistic elements "select", "from", "where" are keywords, and the types of the linguistic elements "", "mycumuputer", "path" are identifiers; the type of the linguistic element "=" is a delimiter; the language element "C: the type of \ "is literal.
Furthermore, the target SQL statement is analyzed in syntax, and an abstract syntax tree corresponding to the target SQL statement is generated. For example, the syntax parser sequentially obtains syntax elements in the target SQL statement, and generates a corresponding abstract syntax tree based on the obtained syntax elements. In an example embodiment, the target SQL statement may be parsed by SqlParser, generating an abstract syntax tree corresponding to the target SQL statement. It should be noted that the target SQL statement may also be parsed by another suitable parser, such as ANTLR or JsqlParser, which is not particularly limited in this application.
In step S420, the generated abstract syntax tree is traversed in a breadth traversal manner based on the visitor pattern, and a node to be converted is determined.
In an example embodiment, the nodes in the generated abstract syntax tree are accessed through a visitor mode, each node of the abstract syntax tree is traversed in a breadth traversal mode, the type of a syntax element corresponding to the traversed node is determined, and the node of which the type of the syntax element is a keyword and/or an identifier is determined as the node to be converted. For example, the nodes corresponding to the keywords "select", "from", "where", and the identifiers "", "mycumkuuter", and "path" are determined as the nodes to be converted.
In step S430, the operation node to be converted is converted into an operation command corresponding to the target command language.
In an example embodiment, based on a preset mapping relationship, a language element corresponding to an operation node to be converted is converted into an operation command corresponding to a target command language. For example, the node to be converted corresponding to select, from, and path is converted into get-child-path, and the converted target SQL statement is get-child-path-meter C: \ is used.
In step S440, a corresponding command statement is generated based on the converted target SQL statement, the command statement is executed, and an interaction result is returned.
In an example embodiment, the converted target SQL statement is processed to generate a command corresponding to the target command language, the command statement is executed, and an interaction result is returned. For example, let the translated target SQL statement become get-child-path-mycomputer C: \\ deleting redundant language elements such as mycomputer (i.e. defaulted to the currently logged-on computer) in the target SQL statement, and generating a corresponding command statement, i.e. get-child-path C: v, executing the generated command statement, and returning a file list under the C disk of the currently logged-in computer by the operating system.
Further, in an example implementation, a first abstract syntax tree containing the operation command is converted into a second abstract syntax tree corresponding to the target command language; generating a command statement corresponding to the target command language based on the second abstract syntax tree. The second abstract syntax tree is an abstract syntax tree which accords with the syntax rule of the target command language, and the second abstract syntax tree is introduced to generate a corresponding command statement, so that the conversion efficiency of the SQL can be improved under many conditions, and the user experience is improved.
In an example embodiment of the present application, a system interaction apparatus is also provided. Referring to fig. 5, the system interaction apparatus 500 includes: parsing module 510, converting module 520, and generating module 530. The parsing module 510 is configured to parse a target SQL statement, and determine an element to be converted in the target SQL statement; the conversion module 520 is configured to convert, based on a preset mapping relationship, an element to be converted in the target SQL statement into an operation command corresponding to a target command language of a target operating system, so as to obtain a converted target SQL statement; the preset mapping relation comprises a mapping relation between a language element in the target SQL statement and an operation command of the target command language; the generating module 530 is configured to generate a command statement corresponding to the target command language based on the converted target SQL statement, so as to interact with the target operating system based on the command statement.
In some example embodiments of the present application, based on the above scheme, the parsing module 510 includes: a syntax tree generating unit 610, configured to parse the target SQL statement, and generate an abstract syntax tree corresponding to the target SQL statement based on a parsing result; a traversal unit 620, configured to traverse the abstract syntax tree, and determine a node to be converted of the abstract syntax tree based on a type of a language element corresponding to the traversed node; a determining unit 630, configured to use a language element corresponding to the node to be converted as an element to be converted in the target SQL statement.
In some example embodiments of the present application, based on the above scheme, the conversion module 520 includes: a searching unit 710, configured to search, based on a language element corresponding to the node to be converted in the abstract syntax tree, a corresponding operation command from the preset mapping relationship; an element converting unit 720, configured to, if the corresponding operation command is found, convert the language element corresponding to the node to be converted into the operation command corresponding to the target command language.
In some example embodiments of the present application, based on the above scheme, the syntax tree generating unit includes: the lexical analysis unit is used for carrying out lexical analysis on the target SQL statement and generating a plurality of language elements corresponding to the target SQL statement; and the syntax analysis unit is used for carrying out syntax analysis on the target SQL statement so as to generate the abstract syntax tree corresponding to the target SQL statement based on the plurality of language elements.
In some example embodiments of the present application, based on the above scheme, the traversal unit is configured to: and traversing the abstract syntax tree based on the visitor mode and the breadth traversal mode.
In some example embodiments of the present application, based on the above solution, the target operating system is a windows operating system, and the target command language is powershell language.
According to the system interaction device in the example embodiment of fig. 5, on one hand, the target SQL statement is analyzed, the elements to be converted in the target SQL statement are determined, and the language elements to be converted in the target SQL statement can be accurately determined; on the other hand, the elements to be converted are converted into the operation commands corresponding to the target command language based on the preset mapping relation, so that the elements to be converted in the target SQL statement can be efficiently converted into the operation commands corresponding to the target command language, and the conversion efficiency is improved; on the other hand, the command statement corresponding to the target command language is generated to interact with the target operating system based on the command statement, the command statement can interact with the operating system through the SQL language, a large amount of time and energy are not needed to be spent on learning the command language, the use threshold of interaction between the command language and the operating system is reduced, and the working efficiency of interaction between a user and the operating system through the command language is improved.
The system interaction device provided by the embodiment of the application can realize each process in the method embodiments and achieve the same functions and effects, and the process is not repeated here.
Further, an embodiment of the present application also provides a system interaction device, as shown in fig. 8.
The system interaction device may vary significantly in configuration or performance and may include one or more processors 801 and memory 802, where the memory 802 may store one or more stored applications or data. Wherein the memory 802 may be a transient storage or a persistent storage. The application programs stored in memory 802 may include one or more modules (not shown), each of which may include a series of computer-executable instructions for the system interaction device. Still further, the processor 801 may be configured to communicate with the memory 802 to execute a series of computer-executable instructions in the memory 802 on the system interaction device. The system interaction apparatus may also include one or more power supplies 803, one or more wired or wireless network interfaces 804, one or more input-output interfaces 805, one or more keyboards 806, and the like.
In one particular embodiment, the system interaction device includes a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the system interaction device, and the one or more programs configured to be executed by the one or more processors include computer-executable instructions for: analyzing a target SQL statement and determining an element to be converted in the target SQL statement; converting the element to be converted into an operation command corresponding to a target command language of a target operation system based on a preset mapping relation, wherein the preset mapping relation comprises a mapping relation between a language element in the target SQL statement and the operation command of the target command language; and generating a command statement corresponding to the target command language based on the converted target SQL statement so as to interact with the target operating system based on the command statement.
Optionally, when executed, the computer executable instructions parse the target SQL statement to determine an element to be converted in the target SQL statement, including: analyzing the target SQL statement, and generating an abstract syntax tree corresponding to the target SQL statement based on an analysis result; traversing the abstract syntax tree, and determining nodes to be converted of the abstract syntax tree based on the types of language elements corresponding to the traversed nodes; and taking the language elements corresponding to the nodes to be converted as the elements to be converted in the target SQL sentences.
Optionally, when executed, the computer-executable instructions convert the element to be converted into an operation command corresponding to a target command language of a target operating system based on a preset mapping relationship, and include: searching a corresponding operation command from the preset mapping relation based on a language element corresponding to the node to be converted in the abstract syntax tree; if the corresponding operation command is found, converting the language element corresponding to the node to be converted into the operation command corresponding to the target command language.
Optionally, when executed, the computer-executable instructions parse the target SQL statement, and generate an abstract syntax tree corresponding to the target SQL statement based on a parsing result, including: performing lexical analysis on the target SQL statement to generate a plurality of language elements corresponding to the target SQL statement; parsing the target SQL statement to generate the abstract syntax tree corresponding to the target SQL statement based on the plurality of language elements.
Optionally, computer executable instructions, when executed, traverse the abstract syntax tree, comprising: and traversing the abstract syntax tree based on the visitor mode and the breadth traversal mode.
Optionally, when the computer-executable instructions are executed, the target operating system is a windows operating system, and the target command language is powershell language.
The system interaction device provided by the embodiment of the application can realize each process in the method embodiments and achieve the same functions and effects, and the process is not repeated here.
In addition, the present application further provides a storage medium for storing computer-executable instructions, and in a specific embodiment, the storage medium may be a usb disk, an optical disk, a hard disk, and the like, and when the storage medium stores the computer-executable instructions, the following process can be implemented: analyzing a target SQL statement, and determining an element to be converted in the target SQL statement; converting the element to be converted into an operation command corresponding to a target command language of a target operation system based on a preset mapping relation, wherein the preset mapping relation comprises a mapping relation between a language element in the target SQL statement and the operation command of the target command language; and generating a command statement corresponding to the target command language based on the converted target SQL statement so as to interact with the target operating system based on the command statement.
Optionally, when executed by a processor, the computer-executable instructions stored in the storage medium parse a target SQL statement to determine an element to be converted in the target SQL statement, and include: analyzing the target SQL statement, and generating an abstract syntax tree corresponding to the target SQL statement based on an analysis result; traversing the abstract syntax tree, and determining nodes to be converted of the abstract syntax tree based on the types of language elements corresponding to the traversed nodes; and taking the language element corresponding to the node to be converted as the element to be converted in the target SQL statement.
Optionally, when executed by a processor, the computer-executable instructions stored in the storage medium convert the element to be converted into an operation command corresponding to a target command language of a target operating system based on a preset mapping relationship, and include: searching a corresponding operation command from the preset mapping relation based on the language element corresponding to the node to be converted in the abstract syntax tree; if the corresponding operation command is found, converting the language element corresponding to the node to be converted into the operation command corresponding to the target command language.
Optionally, the computer-executable instructions stored in the storage medium, when executed by the processor, parse the target SQL statement and generate an abstract syntax tree corresponding to the target SQL statement based on a result of the parsing, including: performing lexical analysis on the target SQL statement to generate a plurality of language elements corresponding to the target SQL statement; parsing the target SQL statement to generate the abstract syntax tree corresponding to the target SQL statement based on the plurality of language elements.
Optionally, the storage medium stores computer-executable instructions that, when executed by the processor, traverse the abstract syntax tree, comprising: and traversing the abstract syntax tree based on the visitor mode and the breadth traversal mode.
Optionally, the storage medium stores computer-executable instructions that, when executed by the processor, the target operating system is a windows operating system and the target command language is powershell language.
The computer-readable storage medium provided by the embodiment of the present application can implement the processes in the foregoing method embodiments, and achieve the same functions and effects, which are not repeated here.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing an Integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as ABEL (Advanced Boolean Expression Language), AHDL (alternate Hardware Description Language), traffic, CUPL (core universal Programming Language), HDCal, jhddl (Java Hardware Description Language), lava, lola, HDL, PALASM, rhyd (Hardware Description Language), and vhigh-Language (Hardware Description Language), which is currently used in most popular applications. It will also be apparent to those skilled in the art that hardware circuitry for implementing the logical method flows can be readily obtained by a mere need to program the method flows with some of the hardware description languages described above and into an integrated circuit.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, atmel AT91SAM, microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, respectively. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising a," "...," or "comprising" does not exclude the presence of other like elements in a process, method, article, or apparatus comprising the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art to which the present application pertains. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A system interaction method, comprising:
analyzing a target Structured Query Language (SQL) statement, and generating an abstract syntax tree corresponding to the target SQL statement based on an analysis result; traversing the abstract syntax tree, and determining nodes to be converted of the abstract syntax tree based on the types of language elements corresponding to the traversed nodes; taking the language elements corresponding to the nodes to be converted as the elements to be converted in the target SQL sentences;
converting the element to be converted in the target SQL statement into an operation command corresponding to a target command language of a target operating system based on a preset mapping relation so as to obtain the converted target SQL statement; the preset mapping relation comprises a mapping relation between a language element in the target SQL statement and an operation command of the target command language;
and generating a command statement corresponding to the target command language based on the converted target SQL statement.
2. The system interaction method according to claim 1, wherein parsing the target SQL statement and generating an abstract syntax tree corresponding to the target SQL statement based on the parsing result comprises:
performing lexical analysis on the target SQL statement to generate a plurality of language elements corresponding to the target SQL statement;
parsing the target SQL statement to generate the abstract syntax tree corresponding to the target SQL statement based on the plurality of language elements.
3. The system interaction method of claim 1, wherein traversing the abstract syntax tree comprises:
traversing the abstract syntax tree based on a visitor pattern and a breadth traversal pattern.
4. The system interaction method of any one of claims 1 to 3, wherein the target operating system is a windows operating system, and the target command language is powershell language.
5. A system interaction apparatus, comprising:
the analysis module is used for analyzing the target SQL statement and generating an abstract syntax tree corresponding to the target SQL statement based on an analysis result; traversing the abstract syntax tree, and determining nodes to be converted of the abstract syntax tree based on the types of language elements corresponding to the traversed nodes; taking the language elements corresponding to the nodes to be converted as the elements to be converted in the target SQL sentences;
the conversion module is used for converting the elements to be converted in the target SQL sentences into operation commands corresponding to a target command language of a target operating system based on a preset mapping relation so as to obtain converted target SQL sentences; the preset mapping relation comprises a mapping relation between a language element in the target SQL statement and an operation command of the target command language;
and the generating module is used for generating a command statement corresponding to the target command language based on the converted target SQL statement.
6. The system interaction device of claim 5, wherein the parsing module comprises:
the lexical analysis unit is used for performing lexical analysis on the target SQL statement and generating a plurality of language elements corresponding to the target SQL statement;
and the syntax analysis unit is used for carrying out syntax analysis on the target SQL statement so as to generate the abstract syntax tree corresponding to the target SQL statement based on the plurality of language elements.
7. The system interaction device of claim 5, wherein the parsing module traverses the abstract syntax tree based on visitor patterns and breadth traversal patterns.
8. The system interaction device of any one of claims 5 to 7, wherein the target operating system is a windows operating system, and the target command language is powershell language.
9. A system interaction device, comprising: a processor; and a memory configured to store computer-executable instructions that, when executed, cause the processor to implement the steps of the system interaction method of any of claims 1 to 4 above.
10. A storage medium storing computer-executable instructions, wherein the computer-executable instructions, when executed, implement the steps of the system interaction method of any of the preceding claims 1 to 4.
CN202310042058.1A 2019-05-23 2019-05-23 System interaction method, device, equipment and storage medium Pending CN115981791A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310042058.1A CN115981791A (en) 2019-05-23 2019-05-23 System interaction method, device, equipment and storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202310042058.1A CN115981791A (en) 2019-05-23 2019-05-23 System interaction method, device, equipment and storage medium
CN201910435910.5A CN110245002B (en) 2019-05-23 2019-05-23 System interaction method, device, equipment and storage medium

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN201910435910.5A Division CN110245002B (en) 2019-05-23 2019-05-23 System interaction method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115981791A true CN115981791A (en) 2023-04-18

Family

ID=67884851

Family Applications (2)

Application Number Title Priority Date Filing Date
CN201910435910.5A Active CN110245002B (en) 2019-05-23 2019-05-23 System interaction method, device, equipment and storage medium
CN202310042058.1A Pending CN115981791A (en) 2019-05-23 2019-05-23 System interaction method, device, equipment and storage medium

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN201910435910.5A Active CN110245002B (en) 2019-05-23 2019-05-23 System interaction method, device, equipment and storage medium

Country Status (1)

Country Link
CN (2) CN110245002B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111061757B (en) * 2019-12-19 2023-03-31 用友网络科技股份有限公司 Language conversion method and device of database, electronic equipment and storage medium
CN111178052A (en) * 2019-12-20 2020-05-19 中国建设银行股份有限公司 Method and device for constructing robot process automation application
CN111367893A (en) * 2020-03-31 2020-07-03 中国建设银行股份有限公司 Method and device for database version iteration
CN112230934B (en) * 2020-10-27 2023-08-29 北京人大金仓信息技术股份有限公司 Method and device for converting code language
CN112328621B (en) * 2020-11-05 2023-11-21 中国平安财产保险股份有限公司 SQL conversion method, SQL conversion device, SQL conversion computer equipment and SQL conversion computer readable storage medium
CN114546981A (en) * 2020-11-24 2022-05-27 奇安信科技集团股份有限公司 Database operation method and device
CN113797545A (en) * 2021-08-25 2021-12-17 广州三七网络科技有限公司 Game script processing method and device, computer equipment and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7761411B2 (en) * 2007-07-20 2010-07-20 Oracle International Corporation Delta operations on a large object in a database
CN104536987B (en) * 2014-12-08 2017-12-05 联动优势电子商务有限公司 A kind of method and device for inquiring about data
CN108228628B (en) * 2016-12-15 2020-11-17 亿度慧达教育科技(北京)有限公司 Wide table generation method and device in structured query language database
CN106970802B (en) * 2017-04-25 2024-04-09 北京航天飞行控制中心 Method and device for integrating programming script language in domain-specific language

Also Published As

Publication number Publication date
CN110245002B (en) 2023-02-17
CN110245002A (en) 2019-09-17

Similar Documents

Publication Publication Date Title
CN110245002B (en) System interaction method, device, equipment and storage medium
CN107038207B (en) Data query method, data processing method and device
CN107526777B (en) Method and equipment for processing file based on version number
CN110968601A (en) Data query processing method and device
CN107391101B (en) Information processing method and device
CN111400681B (en) Data authority processing method, device and equipment
Kuhlmann et al. Lexicalization and generative power in CCG
CN110245468A (en) A kind of Compilation Method, device, equipment and system
CN115756449B (en) Page multiplexing method and device, storage medium and electronic equipment
CN113434533A (en) Data tracing tool construction method, data processing method, device and equipment
CN115982416A (en) Data processing method and device, readable storage medium and electronic equipment
JP2021099771A (en) Method for translation, device, electronic apparatus, readable storage medium, and computer program
CN112269566B (en) Script generation processing method, device, equipment and system
CN113467785A (en) SQL translation method and system for mimicry database
CN111209389A (en) Movie story generation method
CN107239270B (en) Code processing method and device
CN115391426A (en) Data query method and device, storage medium and electronic equipment
CN113391806A (en) Method, device, equipment and readable medium for converting color codes
JP2019121166A (en) Index generation program, index generation apparatus and index generation method
CN113868375A (en) Data query method, device, equipment and storage medium based on structured query language
CN109614082B (en) Translation method, device and equipment for data query script
CN110874350A (en) Method and device for processing structured log data
CN111753990A (en) Quantum computer environment simulation method, equipment and medium
US20240143298A1 (en) Data processing methods and apparatuses, devices, and storage mediums
CN113296754B (en) Script language conversion method, editor, equipment and storage medium based on xml

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