A Visual Conversion System for SQL Language in an iPaaS Platform

By designing the SQL language visual conversion system in the iPaaS platform, the problem of inefficiency and error-prone when facing SQL statements from multiple different databases is solved, and fast and accurate database type prediction and intuitive visual representation are achieved, which improves the ability to handle complex queries.

CN119759939BActive Publication Date: 2025-05-30XIAN HUZHI DIGITAL TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411891768.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-20
Publication Date
2025-05-30
Estimated Expiration
2044-12-20

AI Technical Summary

Technical Problem

The prior art is inefficient and prone to errors when facing SQL statements from multiple different databases, especially when dealing with complex SQL statements or unfamiliar databases, which may lead to query writing errors, performance problems and even system failures.

Method used

A SQL language visual conversion system in the iPaaS platform is designed, including data acquisition and storage module, feature extraction module, model training module, syntax analysis module and visual conversion module. By collecting SQL statement samples from different databases, extracting feature vectors, training classification models, predicting the database type to which the SQL statement belongs, and using the corresponding syntax parser to parse and visual representation of SQL statements.

Benefits of technology

The system can quickly and accurately predict the database type to which the SQL statement belongs, improve the accuracy and efficiency of subsequent processing, generate intuitive visual representations, and improve users' understanding of SQL statements, especially when dealing with complex queries or unfamiliar database syntax.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119759939B_ABST
    Figure CN119759939B_ABST
Patent Text Reader

Abstract

The present invention discloses a SQL language visualization conversion system in an iPaaS platform, including: a data collection and storage module: collecting SQL statement samples of different databases and storing them in a suitable storage structure; a feature extraction module: extracting information that can reflect database dialect features from SQL statements and converting them into feature vector representations; a model training module: training a classification model using the extracted feature vectors to predict the database type to which the SQL statement belongs; a syntax parsing module: parsing the SQL statement using the corresponding syntax parser according to the predicted database type; a visualization conversion module: converting the parsed SQL statement structure into a visual representation, and at the same time processing the visual display of special syntax and functions of different databases, which enables the system to deeply understand the syntax structure of SQL statements and provides a reliable basis for subsequent operations such as visual display and query optimization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of information processing, and particularly to a SQL language visualization conversion system in an iPaaS platform. Background Art

[0002] In the current era of rapid development of information technology, enterprises and organizations widely use various database systems to store, manage, and process data. As a standard language for interacting with databases, there are dialect differences in SQL among different database systems. For example, Oracle and MySQL have differences in function usage, syntax structure, keywords, etc.

[0003] During their daily work, developers and database administrators often need to handle SQL statements involving multiple different databases. However, existing tools and methods have many deficiencies in the face of this diversity. The traditional approach often requires manual judgment based on experience to determine the database type to which the SQL statement belongs, and then use the corresponding syntax rules for processing. This is not only inefficient but also error-prone. Especially when dealing with complex SQL statements or unfamiliar databases, due to syntax differences, it may lead to query writing errors, performance issues, and even system failures. Therefore, a SQL language visualization conversion system in an iPaaS platform is proposed here. Summary of the Invention

[0004] The purpose of the present invention is to solve the disadvantages of low efficiency and easy error in the face of SQL statements of multiple different databases in the prior art, and to propose a SQL language visualization conversion system in an iPaaS platform.

[0005] To achieve the above purpose, the present invention adopts the following technical solutions:

[0006] A SQL language visualization conversion system in an iPaaS platform, comprising:

[0007] A data collection and storage module: collecting SQL statement samples of different databases and storing them in a suitable storage structure;

[0008] A feature extraction module: extracting information that can reflect database dialect features from SQL statements and converting them into feature vector representations;

[0009] A model training module: using the extracted feature vectors to train a classification model for predicting the database type to which the SQL statement belongs;

[0010] A syntax parsing module: parsing the SQL statement using the corresponding syntax parser according to the predicted database type;

[0011] Visualization Conversion Module: Convert the parsed SQL statement structure into a visual representation, and at the same time handle the visual display of special syntax and functions of different databases;

[0012] The data collection and storage module collects SQL statement samples from multiple channels, annotates each SQL statement to determine the database type it belongs to. The feature extraction module counts the occurrence times of keywords in the SQL statement, counts the occurrence times of functions in the SQL statement, extracts structural features such as the depth of subqueries and the number of join operations in the SQL statement, counts the occurrence times of data types in the SQL statement, counts the occurrence times of operators in the SQL statement, and combines various feature vectors into a comprehensive feature vector. The model training module trains and evaluates a random forest classification model to predict the database type to which the SQL statement belongs. The syntax parsing module creates a syntax parser for each database type, predicts the database type to which the SQL statement belongs based on the trained classification model, and then calls the corresponding syntax parser to parse the SQL statement to generate a syntax tree or other internal data structures. The visualization conversion module defines mapping rules from syntax tree nodes to visual elements, generates a basic visual representation, combines the basic visual elements and visual elements of special syntax to generate a final visual representation, which is displayed on the user interface to provide an intuitive visual display and operation interface for SQL statements.

[0013] The process of collecting SQL statement samples from different databases is as follows:

[0014] Collect SQL statements from multiple channels, including open-source database projects, enterprise database application systems, database tutorials, and online code libraries. Let the set of collected SQL statements be S = {s 1 , s 2 ,..., s n}, where s i represents the i-th SQL statement. For each SQL statement s i , determine its belonging database type t i based on database-specific identification information;

[0015] The set of database types is T = {t 1 , t 2 ,..., t m}. Store the annotated SQL statements as a dataset D in the form of tuples: D = {(s 1 , t 1 ), (s 2 , t 2 ),..., (s n , t n )}.

[0016] Furthermore, select an open-source database project, such as MySQL. Find the official repository of the open-source database project through a code hosting platform. Use a text editor or programming language to read and parse the content of these files, and identify the SQL statements in the files. According to the selected open-source database project, record the database type to which each SQL statement belongs, and organize the extracted SQL statements and the corresponding database types in the form of a binary tuple.

[0017] The process of storing in a suitable storage structure is as follows:

[0018] Create a table to store the data set D with two fields: storing the SQL statement content and the stored database type. Insert the collected SQL statements and their corresponding database types into the created table;

[0019] In one embodiment, prepare a data set containing SQL statements and their corresponding database types.

[0020] Use the SQL INSERT statement to insert each record into the table. For example, insert a MySQL-type SQL statement and an Oracle-type SQL statement. Use the SQL query statement to retrieve specific types of SQL statements from the table, and use the database management tool to perform operations such as adding, deleting, modifying, and querying data;

[0021] The process of extracting information that can reflect the database dialect characteristics and converting it into a feature vector representation is as follows:

[0022] Construct a keyword dictionary K;

[0023] Collect all the keywords of common databases, construct a keyword dictionary K, count the number of occurrences of keywords. For each SQL statement s i , count the number of occurrences of each keyword in it. Let the keyword be k j in s i be f k (k j , s i ), generate the keyword feature vector k i = [f k (k 1 , s i ), f k (k 1 , s i ), …, f k (k 1 , s i )];

[0024] Collect all the functions of common databases and establish a function library F;

[0025] Collection function: Extract common function names from various database documents, official manuals, and community resources;

[0026] Organize the list: Organize the collected function names into a list to ensure coverage of common SQL functions;

[0027] Standardize: Standardize the format of function names, for example, convert all to uppercase or lowercase to ensure consistency;

[0028] For each SQL statement s i , count the number of occurrences of each function in it, convert the SQL statement to a standard format, use regular expressions or a lexical analyzer to identify functions in the SQL statement, and combine the occurrence counts of all functions into a vector f i ;

[0029] Combine the above types of feature vectors to obtain the final feature vector v i of the SQL statement s i = [k i , f i .

[0030] In one embodiment, by collecting data from multiple sources, the comprehensiveness and accuracy of keywords and function libraries are ensured, the formats of keywords and functions are unified, regular expressions are used to automatically identify keywords and functions in SQL statements, and the SQL statements are converted into feature vector form for further processing and analysis.

[0031] The implementation process of training a classification model is as follows:

[0032] Select a random forest model, collect a dataset D containing SQL statements and their database type labels, and based on the final feature vector v i , represent the database type label of each SQL statement as Y to form a dataset;

[0033] Divide the dataset into a training set and a test set, with a division ratio of r. Then the size of the training set is |D train | = r · |D|, and the size of the test set is |D test | = (1 - r) · |D|;

[0034] Use the training set D train to train the random forest model to learn the mapping relationship between SQL statements and database types. Assume the random forest model contains n decision trees, create a random forest model M, and for the jth decision tree, according to the final feature vector v of the training data iLearn decision rules with the corresponding database type label Y. Traverse each possible value of each feature in the feature vector, divide the split points through the information gain ratio. Based on the selected split points, recursively repeat the above process of feature selection and dataset partitioning for each subset until the stopping condition is met;

[0035] In one embodiment, the stopping condition may include that the depth of the tree reaches a preset maximum value, the number of samples in the subset is less than a certain threshold, or the sample class purity in the subset reaches a certain standard. For example, set the maximum depth of the tree to 10 and stop growing when the depth of the tree reaches 10; or stop splitting when the number of samples in the subset is less than 5; or consider the subset to be pure enough and stop splitting when the proportion of samples of a certain class in the subset exceeds 95%;

[0036] The model integration repeats the above decision tree training process. After each decision tree is trained, they are integrated to form a random forest model.

[0037] The process of predicting the database type to which the SQL statement belongs is as follows:

[0038] In the prediction stage, for a new SQL statement feature vector, the prediction result of the random forest model is obtained by voting on the prediction results of each decision tree. That is, each decision tree predicts the statement feature vector to obtain a database type prediction result, and then counts the prediction results of all decision trees. The database type that appears the most times is the final prediction result of the random forest model.

[0039] The process of using the syntax parser to parse the SQL statement is as follows:

[0040] Create a syntax parser that precisely adapts to different database types;

[0041] When the statement parsing is executed and the SQL statement to be parsed is received, first use the trained classification model to predict the database type to which it belongs. The predicted database types include Oracle database and MySQL database. According to the predicted database type, call the corresponding syntax parser to parse the SQL statement. During the parsing process, the parser decomposes the SQL statement into syntax elements (keywords, identifiers, expressions, clauses, etc.) step by step according to the syntax rules of the database, constructs the corresponding internal data structure, and constructs an abstract syntax tree that reflects the syntax structure of the statement, where the nodes represent syntax elements and the relationships between the nodes represent the syntax structure.

[0042] In one embodiment, for an Oracle database, its syntax parser can accurately identify and process Oracle-specific syntax structures (such as ROWNUM to limit the number of returned rows, CONNECTBY for hierarchical queries), keywords (such as PRIOR for specifying hierarchical relationships, etc.), and functions (such as NVL for processing null values); for a MySQL database, the parser can correctly parse its specific syntax and functions.

[0043] The process of converting the parsed SQL statement structure into a visual representation is:

[0044] Special visual representation rules are formulated for different parsed SQL statement structures. For Oracle's ROWNUM keyword, an input box or drop-down menu specifically for setting the limit on the number of returned rows is added in the query area of ​​the visual interface, and it is clearly marked as related to ROWNUM. When the user enters a value in the input box, the system automatically converts it into the corresponding ROWNUM syntax structure. For MySQL's LIMIT keyword, an area specifically for setting the LIMIT parameter is added at the end of the query area, which contains two input boxes, one for specifying the starting position and the other for specifying the number of returned rows.

[0045] The process of handling the special syntax and visual display of functions for different databases is as follows:

[0046] For the parsed SQL statement, the database type is d, and the parsing result is the internal data structure G. According to the visual representation rules, the grammatical structure is converted into a basic visual element set M, and the special grammatical structures and functions contained in the statement are identified. For each special grammatical structure or function, a visual element of the special grammar is generated through the visualization function SPV.

[0047] For ROWNUM in Oracle statements and LIMIT in MySQL, the corresponding visual input box or drop-down menu is generated through SPV, and then all the visual elements of special syntax are combined to obtain a set of special syntax visual elements.

[0048] In one embodiment, the visualization function SPV is a visualization conversion function specifically used to process special syntax and functions in a specific database type;

[0049] Finally, the basic visualization element set and the special syntax visualization element set are combined to obtain the final visualization representation. These visualization elements are integrated into the visualization interface according to a reasonable layout and interaction logic, providing users with an intuitive, easy-to-understand and easy-to-operate SQL statement visualization display and operation interface.

[0050] The present invention has the following beneficial effects:

[0051] 1. In the present invention, by collecting a large number of SQL statement samples from various databases through multiple channels, constructing a comprehensive data set, and extracting multi-dimensional feature vectors including keywords, functions, structural features, data types, operators, etc., and training using a random forest model, it is possible to accurately predict the database type to which the SQL statement belongs. This helps to quickly determine the applicable syntax rules and processing methods when facing SQL statements of different databases, improving the accuracy and efficiency of subsequent processing.

[0052] 2. In the present invention, a precisely adapted syntax parser is created for different database types, and based on the predicted database type, the corresponding parser is called to parse the SQL statement, which can generate an accurate syntax tree or internal data structure. This enables the system to deeply understand the syntax structure of the SQL statement, providing a reliable basis for subsequent visualization display, query optimization, and other operations.

[0053] 3. In the present invention, by defining mapping rules from syntax tree nodes to visualization elements, the parsed SQL statement structure can be converted into an intuitive visualization representation. At the same time, for the special syntax and functions of different databases, they are processed through special visualization functions to generate visualization elements that are easy to understand and operate. This greatly improves the user's ability to understand SQL statements. Especially for complex queries or unfamiliar database syntax, users can quickly grasp the logic and function of the statement through the visualization interface. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 It is a system block diagram of an SQL language visualization conversion system in an iPaaS platform proposed by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0055] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0056] Embodiment 1

[0057] As Figure 1 shown, an SQL language visualization conversion system in an iPaaS platform proposed by the present invention includes:

[0058] Data acquisition and storage module: Collect SQL statement samples of different databases and store them in a suitable storage structure;

[0059] Feature extraction module: Extract information that can reflect database dialect features from SQL statements and convert them into feature vector representations;

[0060] Model training module: Use the extracted feature vectors to train a classification model for predicting the database type to which the SQL statement belongs;

[0061] Syntax parsing module: According to the predicted database type, use the corresponding syntax parser to parse the SQL statement;

[0062] Visualization conversion module: Convert the parsed SQL statement structure into a visual representation, and at the same time handle the visual display of special syntax and functions of different databases;

[0063] The data collection and storage module collects SQL statement samples from various sources (such as open-source database projects, enterprise database application systems, database tutorials, online code libraries, etc.), annotates each SQL statement to determine the database type to which it belongs. The feature extraction module counts the number of occurrences of keywords in the SQL statement, counts the number of occurrences of functions in the SQL statement, extracts structural features such as the subquery depth and the number of join operations in the SQL statement, counts the number of occurrences of data types in the SQL statement, counts the number of occurrences of operators in the SQL statement, combines various feature vectors into a comprehensive feature vector. The model training module trains and evaluates a random forest classification model to predict the database type to which the SQL statement belongs. The syntax parsing module creates a syntax parser for each database type, based on the trained classification model to predict the database type to which the SQL statement belongs, and then calls the corresponding syntax parser to parse the SQL statement, generating a syntax tree or other internal data structures. The visualization conversion module defines the mapping rules from syntax tree nodes to visual elements, generates a basic visual representation, combines the basic visual elements and the visual elements of special syntax to generate the final visual representation, which is displayed on the user interface, providing an intuitive visual display and operation interface for SQL statements.

[0064] The process of collecting SQL statement samples from different databases is as follows:

[0065] Collect SQL statements from various sources, including open-source database projects, enterprise database application systems, database tutorials, and online code libraries. Let the set of collected SQL statements be S = {s 1 , s 2 ,..., s n}, where s i represents the i-th SQL statement. For each SQL statement s i , determine its belonging database type t i based on database-specific identification information;

[0066] The set of database types is T = {t 1 , t 2 ,..., t m}. The labeled SQL statements are stored as a dataset D in the form of tuples: D = {(s 1 , t 1 ), (s 2 , t 2 ),..., (s n , t n )};

[0067] Furthermore, select an open-source database project, such as MySQL. Find the official repository of the open-source database project through a code hosting platform. Use a text editor or programming language to read and parse the content of these files, and identify the SQL statements in the files. According to the selected open-source database project, record the database type to which each SQL statement belongs, and organize the extracted SQL statements and the corresponding database types into the form of tuples.

[0068] The process of storing in a suitable storage structure is as follows:

[0069] Create a table with two fields, one for storing the content of the SQL statement and the other for storing the database type, to store the dataset D. Insert the collected SQL statements and their corresponding database types into the created table;

[0070] In one embodiment, prepare a dataset containing SQL statements and their corresponding database types.

[0071] Use the SQL INSERT statement to insert each record into the table. For example, insert a MySQL-type SQL statement and an Oracle-type SQL statement. Use the SQL query statement to retrieve specific types of SQL statements from the table, and use a database management tool to perform operations such as adding, deleting, modifying, and querying data;

[0072] The process of extracting information that can reflect the characteristics of the database dialect and converting it into a feature vector representation is as follows:

[0073] Construct a keyword dictionary K;

[0074] Collect the keywords of all common databases, construct a keyword dictionary K, and count the number of times each keyword appears. For each SQL statement s i , count the number of times each keyword appears in it. Let the number of times the keyword k j appears in s i be f k (k j , s i ), and generate the keyword feature vector k i = [fk (k 1 , s i ), f k (k 1 , s i ), …, f k (k 1 , s i )];

[0075] Collect all the functions of common databases to establish a function library F;

[0076] Collection function: Extract common function names from various database documents, official manuals, and community resources;

[0077] Sort the list: Organize the collected function names into a list to ensure coverage of common SQL functions;

[0078] Standardize: Unify the format of function names, for example, convert all to uppercase or lowercase to ensure consistency;

[0079] For each SQL statement s i , count the number of occurrences of each function in it, convert the SQL statement to the standard format, use regular expressions or lexical analyzers to identify functions in the SQL statement, and combine the occurrence counts of all functions into a vector f i ;

[0080] Combine the above types of feature vectors to obtain the final feature vector v i of the SQL statement s i = [k i , f i .

[0081] In one embodiment, by collecting data from multiple sources, the comprehensiveness and accuracy of keywords and function libraries are ensured, the formats of keywords and functions are unified, regular expressions are used to automatically identify keywords and functions in SQL statements, and the SQL statements are converted into feature vector form for further processing and analysis.

[0082] The implementation process of training a classification model is as follows:

[0083] Select a random forest model, collect a dataset D containing SQL statements and their database type labels, and based on the final feature vector v i , represent the database type label of each SQL statement as Y to form a dataset;

[0084] Divide the dataset into a training set and a test set, and the division ratio is r. Then the size of the training set is |D train | = r·|D|, and the size of the test set is |Dtest | = (1 - r)·|D|;

[0085] Use the training set D train Train a random forest model to learn the mapping relationship between SQL statements and database types. Assume that the random forest model contains n decision trees. Create a random forest model M. For the j-th decision tree, according to the final feature vector v of the training data i and the corresponding database type label Y, learn the decision rules. Traverse each possible value of each feature in the feature vector, divide the split points through the information gain ratio, and based on the selected split points, recursively repeat the above process of feature selection and data set partitioning for each subset until the stopping condition is met;

[0086] In one embodiment, the stopping condition may include that the depth of the tree reaches a preset maximum value, the number of samples in the subset is less than a certain threshold, or the sample class purity in the subset reaches a certain standard. For example, set the maximum depth of the tree to 10 and stop growing when the depth of the tree reaches 10; or stop splitting when the number of samples in the subset is less than 5; or when the proportion of samples of a certain class in the subset exceeds 95%, consider that the subset is already pure enough and stop splitting;

[0087] The model integration repeats the above decision tree training process. After each decision tree is trained, they are integrated to form a random forest model.

[0088] The process of predicting the database type to which an SQL statement belongs is as follows:

[0089] In the prediction stage, for a new SQL statement feature vector, the prediction result of the random forest model is obtained by voting on the prediction results of each decision tree, that is, each decision tree predicts the statement feature vector to obtain a database type prediction result, and then counts the prediction results of all decision trees. The database type with the most occurrences is the final prediction result of the random forest model.

[0090] The process of using a syntax parser to parse an SQL statement is as follows:

[0091] Create a syntax parser that is precisely adapted to different database types;

[0092] Statement parsing and execution: When a SQL statement to be parsed is received, first use the trained classification model to predict the database type it belongs to. The predicted database types include Oracle database and MySQL database. According to the predicted database type, call the corresponding syntax parser to parse the SQL statement. During the parsing process, the parser decomposes the SQL statement step by step into syntax elements (keywords, identifiers, expressions, clauses, etc.) according to the syntax rules of the database, constructs the corresponding internal data structure, and constructs an abstract syntax tree reflecting the syntax structure of the statement, where nodes represent syntax elements and the relationships between nodes represent syntax structures.

[0093] In one embodiment, for the Oracle database, its syntax parser can accurately identify and process Oracle-specific syntax structures (such as ROWNUM to limit the number of returned rows, CONNECT BY for hierarchical queries), keywords (such as PRIOR to specify hierarchical relationships, etc.), and functions (such as NVL to handle null values); for the MySQL database, the parser can correctly parse its specific syntax and functions.

[0094] The process of converting the parsed SQL statement structure into a visual representation is as follows:

[0095] For different parsed SQL statement structures, formulate special visual representation rules. For the ROWNUM keyword in Oracle, in the query area of the visual interface, add a dedicated input box or dropdown menu for setting the limit of the number of returned rows, and clearly label its association with ROWNUM. When the user enters a value in this input box, the system automatically converts it into the corresponding ROWNUM syntax structure. For the LIMIT keyword in MySQL, add a dedicated area for setting LIMIT parameters at the end of the query area, including two input boxes for specifying the starting position and the number of returned rows respectively.

[0096] The process of handling the visual display of special syntax and functions in different databases is as follows:

[0097] For the parsed SQL statement, its database type is d and the parsing result is the internal data structure G. According to the visual representation rules, convert the syntax structure into a basic set of visual elements M. Identify the special syntax structures and functions included in the statement. For each special syntax structure or function, generate visual elements for the special syntax through the visualization function SPV.

[0098] For ROWNUM in Oracle statements and LIMIT in MySQL, generate the corresponding visual input boxes or dropdown menus through SPV, and then combine all the visual elements of the special syntax to obtain the set of visual elements for the special syntax.

[0099] In one embodiment, the visualization function SPV is a visualization conversion function specifically designed to handle special syntax and functions in a specific database type;

[0100] Finally, combine the basic visualization element set and the special syntax visualization element set to obtain the final visualization representation, and integrate these visualization elements onto the visualization interface according to a reasonable layout and interaction logic, providing the user with an intuitive, easy-to-understand, and operable SQL statement visualization display and operation interface.

[0101] Although the embodiments of the present invention have been shown and described, for those of ordinary skill in the art, it can be understood that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention, and the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A SQL language visual conversion system in an iPaaS platform, characterized in that: include: Data collection and storage module: collects SQL statement samples from different databases and stores them in a suitable storage structure; Feature extraction module: extracts information that can reflect the characteristics of the database dialect from SQL statements and converts it into a feature vector representation; Model training module: Use the extracted feature vectors to train a classification model to predict the database type to which the SQL statement belongs; Syntax parsing module: according to the predicted database type, use the corresponding syntax parser to parse the SQL statement; Visual conversion module: converts the parsed SQL statement structure into a visual representation, and handles the visual display of special syntax and functions of different databases; The data collection and storage module collects SQL statement samples from multiple channels, labels each SQL statement, and determines the database type to which it belongs. The feature extraction module counts the number of occurrences of keywords in SQL statements, counts the number of occurrences of functions in SQL statements, extracts the subquery depth and the number of connection operations of SQL statements, counts the number of occurrences of data types in SQL statements, counts the number of occurrences of operators in SQL statements, and combines various feature vectors into a comprehensive feature vector. The model training module trains and evaluates a random forest classification model to predict the database type to which the SQL statement belongs. The syntax parsing module creates a syntax parser for each database type, predicts the database type to which the SQL statement belongs based on the trained classification model, and then calls the corresponding syntax parser to parse the SQL statement to generate a syntax tree or other internal data structure. The visualization conversion module defines a mapping rule from syntax tree nodes to visualization elements, generates a basic visualization representation, combines the basic visualization elements with visualization elements of special syntax, generates a final visualization representation, and displays it on a user interface to provide an intuitive SQL statement visualization and operation interface.

2. The SQL language visual conversion system in the iPaaS platform according to claim 1, characterized in that: The process of collecting SQL statement samples from different databases is as follows: SQL statements are collected from various sources, including open source database projects, enterprise database application systems, database tutorials, and online code libraries. Suppose the collected SQL statement set is S = {s1, s2, ..., s n }, where s i Represents the i-th SQL statement. For each SQL statement s i , based on the database-specific identification information, determine the database type to which it belongs i ; The database type set is T = {t1, t2, ..., t m }, the annotated SQL statements are stored as a data set D = {(s1, t1), (s2, t2), ..., (s n , t n )}.

3. The SQL language visual conversion system in the iPaaS platform according to claim 1, characterized in that: The process of storing in a suitable storage structure is: Create a table storage data set D that contains two fields: storing SQL statement content and storing database type. Insert the collected SQL statements and their corresponding database types into the created table.

4. The SQL language visual conversion system in the iPaaS platform according to claim 1, characterized in that: The process of extracting information that can reflect the database dialect characteristics and converting it into a feature vector representation is as follows: Construct keyword dictionary K; Collect keywords of all common databases, build a keyword dictionary K, count the number of keyword occurrences, and for each SQL statement s i , count the number of times each keyword appears in it, let keyword k j In s i The number of occurrences in is f k (k j ,s i ), generate keyword feature vector k i =[f k (k1, s i ), f k (k1, s i ), …, f k (k1, s i )]; Collect all common database functions and build a function library F; Collect functions: extract commonly used function names from various database documents, official manuals, and community resources; Arrange the list: Arrange the collected function names into a list; Standardization: unify the format of function names and convert them all to uppercase or lowercase; For each SQL statement i , count the number of occurrences of each function, convert the SQL statement to a standard format, use regular expressions or a lexical analyzer to identify the functions in the SQL statement, and combine the number of occurrences of all functions into a vector f i ; Combining the above-mentioned feature vectors, we get the SQL statement s i The final eigenvector v of i =[k i ,f i ].

5. The SQL language visual conversion system in the iPaaS platform according to claim 1, characterized in that: The implementation process of training a classification model is as follows: Select a random forest model, collect a dataset D containing SQL statements and their database type labels, and then use the final feature vector v i , denote the database type label of each SQL statement as Y, forming a data set; Divide the data set into a training set and a test set with a division ratio of r, then the size of the training set is |D train |=r·|D|, the test set size is |D test |=(1-r)·|D|; Using the training set D train Train the random forest model to learn the mapping relationship between SQL statements and database types. Suppose the random forest model contains n decision trees. Create a random forest model M. For the jth decision tree, according to the final feature vector v of the training data i and the corresponding database type label Y to learn the decision rule, traverse each possible value of each feature in the feature vector, divide the split point by the information gain ratio, and recursively repeat the feature selection and data set partitioning process for each subset based on the selected split point until the stopping condition is met; Repeat the above decision tree training process. After each decision tree is trained, they are integrated to form a random forest model.

6. The SQL language visual conversion system in the iPaaS platform according to claim 1, characterized in that: The process of predicting the database type to which the SQL statement belongs is as follows: In the prediction stage, for a new SQL statement feature vector, the prediction result of the random forest model is obtained by voting on the prediction results of each decision tree, that is, each decision tree predicts the statement feature vector to obtain a database type prediction result, and then the prediction results of all decision trees are counted. The database type that appears most times is the final prediction result of the random forest model.

7. The SQL language visual conversion system in the iPaaS platform according to claim 1, characterized in that: The process of using the corresponding syntax parser to parse the SQL statement is as follows: Create syntax parsers that are precisely adapted to different database types; When the SQL statement to be parsed is received, the trained classification model is first used to predict the database type to which it belongs. The predicted database types include Oracle database and MySQL database. According to the predicted database type, the corresponding syntax parser is called to parse the SQL statement. During the parsing process, the parser gradually decomposes the SQL statement into syntax elements according to the syntax rules of the database, and constructs the corresponding internal data structure, and constructs an abstract syntax tree that reflects the syntax structure of the statement, in which nodes represent syntax elements and the relationship between nodes represents the syntax structure.

8. The SQL language visual conversion system in the iPaaS platform according to claim 1, characterized in that: The process of converting the parsed SQL statement structure into a visual representation is as follows: Special visual representation rules are formulated for different parsed SQL statement structures. For Oracle's ROWNUM keyword, an input box or drop-down menu specifically for setting the limit on the number of returned rows is added in the query area of ​​the visual interface, and it is clearly marked as related to ROWNUM. When the user enters a value in the input box, the system automatically converts it into the corresponding ROWNUM syntax structure. For MySQL's LIMIT keyword, an area specifically for setting the LIMIT parameter is added at the end of the query area, which contains two input boxes, one for specifying the starting position and the other for specifying the number of returned rows.

9. The SQL language visual conversion system in the iPaaS platform according to claim 1, characterized in that: The process of processing the special syntax and visual display of functions of different databases is as follows: For the parsed SQL statement, the database type is d, and the parsing result is the internal data structure G. According to the visual representation rules, the grammatical structure is converted into a basic visual element set M, and the special grammatical structures and functions contained in the statement are identified. For each special grammatical structure or function, a visual element of the special grammar is generated through the visualization function SPV. For ROWNUM in Oracle statements and LIMIT in MySQL, the corresponding visual input box or drop-down menu is generated through SPV, and then all the visual elements of special syntax are combined to obtain a set of special syntax visual elements; The basic visualization element set and the special syntax visualization element set are combined to obtain the final visualization representation, and these visualization elements are integrated into the visualization interface according to a reasonable layout and interaction logic, providing users with an intuitive, easy-to-understand and easy-to-operate SQL statement visualization display and operation interface.

Citation Information

Patent Citations

  • SQL (Structured Query Language) statement forwarding method and device, electronic equipment and storage medium

    CN117407413A

  • Large language model Text2SQL (Structured Query Language) chart generation method and device

    CN117851445A