Automatic page generation method, device and equipment based on SQL statement query and medium
Through the automatic page generation method based on SQL statements, the problems of low efficiency and different quality of web page development are solved, and the page layout configuration and data display are realized, the development efficiency and quality are improved, and labor costs are saved.
Patent Information
- Application Number
- CN202410945594.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-15
- Publication Date
- 2024-11-29
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In modern web development, creating pages with complex data display and interactive functions requires developers to write code manually, resulting in increased development time, high error rate, low efficiency, and high repetitive work, which consumes high labor costs.
Provide a page automatic generation method based on query SQL statements. By obtaining data table field information and receiving user input SQL statements, defining out parameter fields and entering parameter fields, generating page generation code, automatically configuring the display page layout, and realizing page page Quickly generate and present.
It greatly saves data review time, improves page development efficiency and quality, reduces labor costs, automates page layout and configuration, and improves development efficiency and consistency.
Smart Images

Figure CN119045816A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of Internet technology, and specifically relates to an application request processing method, device, equipment and medium. Background Art
[0002] In modern web development, pages that contain complex data display and interactive functions have a wide range of application scenarios.
[0003] Currently, the creation of data pages requires developers to manually write the corresponding code, which not only increases development time, but also easily introduces erroneous data. In addition, developers also need to manually configure and adjust page layouts and functions, which greatly increases the workload of developers and seriously affects development efficiency.
[0004] Therefore, the low efficiency of page development, the uneven quality of page development, and the need for a large amount of repetitive work during the development process, which consumes high manpower costs, are technical problems that technical personnel in this field need to solve urgently. Summary of the invention
[0005] The embodiments of the present application provide a method, apparatus, device and medium for automatically generating pages based on query SQL statements, the purpose of which is to generate a display page based on a query statement of a data table, so that users can quickly obtain required data from a large amount of data through key fields, greatly saving data search time, and can automatically configure the layout of the display page, thereby improving page development efficiency and page quality.
[0006] In a first aspect, this embodiment provides a method for automatically generating a page based on a query SQL statement, the method comprising:
[0007] Obtaining field information of at least one pre-built data table;
[0008] Receive the SQL statement input by the user, and obtain the output parameter fields in the SQL statement;
[0009] Determine the output parameter data corresponding to the output parameter field according to the data table;
[0010] Determine a page generation code based on the output parameter field and the output parameter data corresponding to the output parameter field;
[0011] Generate a target page to be displayed according to the page generation code.
[0012] Furthermore, after receiving the SQL statement input by the user, the method further includes:
[0013] Obtaining input parameter fields and output parameter fields in the SQL statement, and conditional data input for at least one of the input parameter fields;
[0014] According to the matching of the condition data of the input parameter field with the field information, the output parameter data corresponding to the output parameter field is determined;
[0015] Determine a page generation code based on the input parameter fields, conditional data input for at least one of the input parameter fields, the output parameter fields, and output parameter data corresponding to the output parameter fields;
[0016] Generate a target page to be displayed according to the page generation code.
[0017] Furthermore, after receiving the SQL statement input by the user, the method further includes:
[0018] If the SQL statement is a new type query statement, then the field information of the target data table is obtained;
[0019] Using the field information of the target data table as an output parameter field, and determining a page generation code based on the output parameter field;
[0020] Generate a target page to be displayed according to the page generation code;
[0021] Receive additional data input by the user;
[0022] The added data is added to the target data table.
[0023] Furthermore, after receiving the SQL statement input by the user, the method further includes:
[0024] If the SQL statement is a delete type query statement, then the primary key information of the target data table is obtained;
[0025] Using the primary key information of the target data table as output information, and determining a page generation code based on the output information;
[0026] Generate a target page to be displayed according to the page generation code;
[0027] Receive the user's deletion operation;
[0028] The deletion object primary key corresponding to the deletion operation is deleted from the target data table.
[0029] Furthermore, after receiving the SQL statement input by the user, the method further includes:
[0030] If the SQL statement is a modification type query statement, then obtaining the field information of the target data table and the data content corresponding to the field information;
[0031] Using the field information of the target data table as the output parameter field, using the data content corresponding to the field information as the output parameter data corresponding to the output parameter field, and determining the page generation code based on the output parameter field and the output parameter data;
[0032] Generate a target page to be displayed according to the page generation code;
[0033] Receive data change operations from users;
[0034] The change object data corresponding to the data change operation is modified in the target data table.
[0035] Further, after receiving the additional data input by the user, the method includes:
[0036] Obtain the required data type corresponding to each field information in the target data table;
[0037] Identify the data type of the added data;
[0038] When the data type of the added data is inconsistent with the required data type of the information field, a prompt message of an error in the type of the added data is generated.
[0039] Further, obtaining field information of at least one pre-built data table includes:
[0040] Obtain table creation statement information of at least one pre-built data table;
[0041] The field information of each data table is parsed based on the table creation statement information, and the type information of each data table is parsed.
[0042] In a second aspect, this embodiment provides a device for automatically generating a page based on a query SQL statement, the device comprising:
[0043] A field information acquisition module, used to acquire field information of at least one pre-built data table;
[0044] The output parameter field acquisition module is used to receive the SQL statement input by the user and obtain the output parameter fields in the SQL statement;
[0045] An output parameter data determination module, used to determine the output parameter data corresponding to the output parameter field according to the data table;
[0046] A page generation code determination module, used to determine the page generation code based on the output parameter field and the output parameter data corresponding to the output parameter field;
[0047] The target page generation module is used to generate the target page to be displayed according to the page generation code.
[0048] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.
[0049] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0050] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.
[0051] In an embodiment of the present application, the field information of at least one pre-built data table is obtained; an SQL statement input by a user is received, and an output parameter field in the SQL statement is obtained; the output parameter data corresponding to the output parameter field is determined according to the data table; a page generation code is determined based on the output parameter field and the output parameter data corresponding to the output parameter field; and a target page to be displayed is generated according to the page generation code. Through the above-mentioned method for automatically generating a page based on a query SQL statement, a display page can be generated based on a query statement of a data table, so that users can quickly obtain required data from a large amount of data through key fields, which greatly saves data search time, and can automatically configure the layout of the display page, improving page development efficiency and page quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 It is a flowchart of a method for automatically generating a page based on a query SQL statement provided in Example 1 of the present application;
[0053] Figure 2 This is a flow chart of a method for automatically generating a page based on a query SQL statement provided in Example 2 of the present application;
[0054] Figure 3 This is a flow chart of generating a user query result page provided in Example 2 of the present application;
[0055] Figure 4 This is a flow chart of a method for automatically generating a page based on a query SQL statement provided in Example 3 of the present application;
[0056] Figure 5 This is a flow chart of a method for automatically generating a page based on a query SQL statement provided in Embodiment 4 of the present application;
[0057] Figure 6 This is a flow chart of a method for automatically generating a page based on a query SQL statement provided in Example 5 of the present application;
[0058] Figure 7 This is a flow chart of a method for automatically generating a page based on a query SQL statement provided in Example 6 of the present application;
[0059] Figure 8 It is a structural diagram of a device for automatically generating pages based on query SQL statements provided in Embodiment 7 of the present application;
[0060] Fig. 9 It is a schematic diagram of the structure of the electronic device provided in Example 8 of the present application. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical scheme and advantages of the present application clearer, the specific embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. It is understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for the convenience of description, only the part related to the present application but not all the contents are shown in the accompanying drawings. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow chart describes each operation (or step) as a sequential process, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. The process can be terminated when its operation is completed, but it can also have additional steps not included in the accompanying drawings. The process can correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.
[0062] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0063] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0064] In conjunction with the accompanying drawings, a method, device, equipment and medium for automatically generating pages based on query SQL statements provided by an embodiment of the present application are described in detail through specific embodiments and their application scenarios.
[0065] Embodiment 1
[0066] Figure 1 It is a flow chart of a method for automatically generating pages based on query SQL statements provided in Example 1 of the present application.
[0067] like Figure 1 As shown, the specific steps include:
[0068] S101, obtaining field information of at least one pre-built data table;
[0069] The application scenario of this solution may be a scenario in which a corresponding query result page is generated according to an SQL statement input by a user.
[0070] Based on the above scenario, it can be understood that the execution subject of this scenario can be the front-end and back-end used to generate the query result page code, wherein the back-end code is generated by the server, and the front-end code can be generated by the client, or generated by the server and sent to the client. No excessive restrictions are made here.
[0071] A data table can be the main data storage container in a database, organizing data by rows and columns. Each column in a table has a name, and each column has a specified data type and size. The logical structure of a data table is a two-dimensional table consisting of rows and columns. A row in a table is usually called a record, and a column in a table is called an attribute column. A record describes an entity, and an attribute column describes an attribute of the entity.
[0072] Field information can be the header information in a data table, which is used to describe the attributes of each column in the data table. For example, in a class personnel record data table, the header information such as student name, student number, gender, and enrollment time is used as field information.
[0073] The method for obtaining the field information of at least one pre-constructed data table is that the staff may input the field information in the data table to be stored and its corresponding specific content information into the server through the terminal device in advance, and the server stores the field information and its corresponding specific content information in the database according to the prescribed format. When the user needs to query the service, the server extracts the field information from the database.
[0074] S102, receiving an SQL statement input by a user, and obtaining an output parameter field in the SQL statement;
[0075] SQL (Structured Query Language) statements can be a standard programming language used to manage and operate relational databases. SQL statements can perform various database operations such as querying, updating, inserting, and deleting data.
[0076] The output parameter field can be one or more fields that the user wants to query. For example, if the user wants to query which students are recorded in the data table of class 1, the student name can be used as the output parameter field; if the user wants to query the age of the students recorded in the data table of class 1, the student name and age can be used as the output parameter fields.
[0077] The method of obtaining the output parameter fields in the SQL statement can be that the user enters the information to be queried in the specified input box of the query interface, and the client generates the corresponding SQL statement based on the information input by the user and sends it to the server. After receiving the SQL statement, the server interprets the SQL statement and extracts the information input by the user as the output parameter fields.
[0078] S103, determining the output parameter data corresponding to the output parameter field according to the data table;
[0079] The output parameter data can be the content that the user wants to know corresponding to the output parameter field. For example, if the output parameter field is the name of the student in class 1, the corresponding output parameter data is all the names under the student name header in the data table of class 1.
[0080] The method of determining the output parameter data corresponding to the output parameter field according to the data table can be that after obtaining the output parameter field, at least one data table in the database is queried for header information consistent with the output parameter field, and all elements under its attribute column are obtained as the output parameter data.
[0081] S104, determining a page generation code based on the output parameter field and the output parameter data corresponding to the output parameter field;
[0082] Page generation code can be programming code used to create and build web pages. These codes define the structure, style and behavior of the page. Page generation code usually includes three parts: HTML (used to define the structure and content of the page), CSS (used to control the style and layout of the page) and JavaScript (used to increase the interactivity of the page), but other technologies or frameworks may also be involved for personalized pages.
[0083] The method for determining the page generation code can be that the developer pre-builds a framework for the page generation code based on the style of the page to be displayed and the layout of the page content and other reusable structures as needed. After obtaining the output parameter fields and output parameter data, fill them into the specified position of the preset code framework to obtain the page generation code.
[0084] S105: Generate a target page to be displayed according to the page generation code.
[0085] The method of generating the target page to be displayed according to the page generation code can be to run the page generation code and obtain the specified display type of the output parameter field, for example, specify that the student name is displayed in the page using the string type, and the student age is displayed in the page using the integer type, etc. After adjusting the format of the corresponding output parameter data according to the specified display type of the output parameter field, the output parameter data is displayed in the page, and the code running result is obtained. The running result is tested, that is, whether the output parameter field and the output parameter data are displayed in the specified position, and whether the buttons, links, forms and other elements in the page perform correct operations through manual operation by the developer or using test scripts. After the test is qualified, the current page is determined to be the target page.
[0086] In an embodiment of the present application, the field information of at least one pre-built data table is obtained; an SQL statement input by a user is received, and an output parameter field in the SQL statement is obtained; the output parameter data corresponding to the output parameter field is determined according to the data table; a page generation code is determined based on the output parameter field and the output parameter data corresponding to the output parameter field; and a target page to be displayed is generated according to the page generation code. Through the above-mentioned method for automatically generating a page based on a query SQL statement, a display page can be generated based on a query statement of a data table, so that users can quickly obtain required data from a large amount of data through key fields, which greatly saves data search time, and can automatically configure the layout of the display page, improving page development efficiency and page quality.
[0087] Embodiment 2
[0088] Figure 2It is a flow chart of a method for automatically generating pages based on query SQL statements provided in Example 2 of the present application. This solution makes a better improvement on the above-mentioned embodiment, and the specific improvement is: after receiving the SQL statement input by the user, the method also includes: obtaining the input parameter field and the output parameter field in the SQL statement, and the conditional data input for at least one of the input parameter fields; matching the conditional data of the input parameter field with the field information to determine the output parameter data corresponding to the output parameter field; determining the page generation code based on the input parameter field, the conditional data input for at least one of the input parameter fields, the output parameter field and the output parameter data corresponding to the output parameter field; generating the target page to be displayed according to the page generation code.
[0089] like Figure 2 As shown, specifically including the following:
[0090] S201, obtaining field information of at least one pre-built data table;
[0091] S202, receiving an SQL statement input by a user;
[0092] S203, obtaining input parameter fields and output parameter fields in the SQL statement, and conditional data input for at least one of the input parameter fields;
[0093] The input field can be the field information that the user wants to query, for example, student age, student gender, etc.
[0094] Conditional data can be a constraint that limits the search scope of input data to make the query results more accurate. For example, for the input field of student gender, if female is used as the conditional data, only data information of students with female gender will appear in the output data; for the input field of student age, if the conditional data is 15 to 20 years old, only the output data of students aged 15 to 20 in the data table will be queried.
[0095] The method of obtaining the input parameter field and the output parameter field in the SQL statement, as well as the conditional data input for at least one input parameter field, can be that the user enters the information to be queried and the query condition in the designated input box of the query interface, and the client generates a corresponding SQL statement according to the information content entered by the user and sends it to the server. After receiving the SQL statement, the server interprets the SQL statement and extracts the input parameter field, the output parameter data, and the conditional data input for at least one input parameter field at the corresponding positions in the SQL statement.
[0096] S204, matching the conditional data of the input parameter field with the field information to determine the output parameter data corresponding to the output parameter field;
[0097] The method of determining the output parameter data corresponding to the output parameter field can be to find the information content corresponding to the field that is consistent with the input parameter field and the output parameter field in the data table as the field information, filter the field information according to the conditional data, and only retain the field information that meets the conditional data, and use the retained field information as the output parameter data. For example, if the input parameter field is the student age, the output parameter field is the student name, and the output parameter data is the student age range of 15 to 20 years old, first extract the two columns of data with the table headers of student name and student age from the data table, remove the data of student age less than 15 years old and greater than 20 years old, and remove the data corresponding to the removed student age in the student name, and use the retained student age of 15 to 20 years old and the corresponding student name as the output parameter data.
[0098] S205, determining a page generation code based on the input parameter fields, conditional data input for at least one of the input parameter fields, the output parameter fields, and output parameter data corresponding to the output parameter fields;
[0099] To determine the page generation code, the input parameter fields, the conditional data input for at least one of the input parameter fields, and the output parameter fields can be filled in as user input information into a specified position of a preset code frame, and the output parameter fields and the output parameter data corresponding to the output parameter fields can be written as query results into a specified position of the preset code frame, thereby constructing a complete page generation code.
[0100] S206: Generate a target page to be displayed according to the page generation code.
[0101] For example, Figure 3 is a flow chart of generating a user query result page provided in the second embodiment of the present application, such as Figure 3 As shown, the user inputs table creation statement information into the database, such as the header, field, and type of the data table. The database parses the input data table, organizes the field information in the data table, and stores it. When the user needs to query the information in the data table, the client inputs the query SQL statement, and the client sends the query SQL statement to the server. The server parses the query SQL statement, extracts the output parameter field and the input parameter field, and obtains the field information corresponding to the output parameter field and the input parameter field in the data table. The information content that needs to be displayed on the page is determined based on the output parameter field, the input parameter field, and the field information. The front-end and back-end codes that can make the page are generated based on the information content that needs to be displayed on the page. The display page can be obtained by running the front-end and back-end codes.
[0102] The advantage of this setting is that the queried information can be further filtered according to the conditional data provided by the user, narrowing the display scope of the query results, so that users can accurately obtain the required information without having to browse through a large number of query results, thereby improving the user experience and query efficiency.
[0103] Embodiment 3
[0104] Figure 4 This is a flow chart of a method for automatically generating a page based on a query SQL statement provided in Example 3 of the present application. This solution makes a better improvement on the above-mentioned embodiment, and the specific improvement is: after receiving the SQL statement input by the user, the method also includes: if the SQL statement is a new type query statement, then obtaining the field information of the target data table; using the field information of the target data table as the output parameter field, and determining the page generation code based on the output parameter field; generating the target page to be displayed according to the page generation code; receiving the added data input by the user; and adding the added data to the target data table.
[0105] like Figure 4 As shown, specifically including the following:
[0106] S401, obtaining field information of at least one pre-built data table;
[0107] S402, receiving an SQL statement input by a user;
[0108] S403: If the SQL statement is a new type query statement, obtain the field information of the target data table;
[0109] The new type query statement can be a query SQL statement that the user wants to add new data to the storage location corresponding to the specified field information in the data table. For example, add the name of student A to the student name field information in the data table of class 1.
[0110] The field information of the target data table can be the column attribute classification of the data that the user wants to add in the data table. For example, if the user wants to add the name of student A in the data table of class 1, the field information of the target data table is the student name in the data table of class 1.
[0111] The target data table may be determined by obtaining the target data table name input by the user in the SQL statement, and retrieving a target data table with the same name in the database; or, the target data table may be determined by obtaining the field information input by the user in the SQL statement, and retrieving a data table with the same field information in the database as the target data table.
[0112] The method for obtaining the field information of the target data table is that the user enters the data table to be added and the adding location in the specified input box through the client. The client generates a corresponding SQL statement based on the information entered by the user and sends it to the server. The server receives the SQL statement and interprets it to extract the information entered by the user as the field information of the target data table.
[0113] S404, using the field information of the target data table as an output parameter field, and determining a page generation code based on the output parameter field;
[0114] A method for determining page generation code may be to, after obtaining the field information of the target data table, use the field information of the target data table as an output parameter field, fill the output parameter field into a specified position in a preset code framework, so as to obtain a page generation code for a page that can display the field information of the target data table and add a data acquisition input box after the field information of each target data table.
[0115] S405, generating a target page to be displayed according to the page generation code;
[0116] S406, receiving additional data input by the user;
[0117] Adding data can be specific content that the user wants to add. For example, if the user wants to add student A to the data table of class 1, the added data can be information such as student A's name, gender, and student ID.
[0118] The method of receiving the added data input by the user can be that the user enters the corresponding added data in the input box after the field information of the target data table in the page displayed by the client, and the client uses the content input by the user as the added data, and the client sends the added data and the corresponding field information of the target data table to the server, which is received by the server. For example, if the user wants to add the name of student a, then fill in a in the input box after the student name in the page displayed by the client.
[0119] S407: Add the added data to the target data table.
[0120] The method of adding the added data to the target data table can be to extract the target data table from the database, query the field information in the target data table, and fill in the added data in the corresponding field information. For example, if the added data is a and 12, the field information of the student name and the student age is queried in the target data table, and a and 12 are filled in under the corresponding student name and student age table header.
[0121] The benefit of this arrangement is that it can support users to add data information to the target data table, making the data adding operation simpler, improving user work efficiency and database usage experience.
[0122] In this embodiment, optionally, after receiving the additional data input by the user, the method includes:
[0123] Obtain the required data type corresponding to each field information in the target data table;
[0124] Identify the data type of the added data;
[0125] When the data type of the added data is inconsistent with the required data type of the information field, a prompt message of an error in the type of the added data is generated.
[0126] Data types can specify the nature of data and the types of operations that can be performed, making data storage, retrieval, and other behaviors more standardized and efficient. For example, integers are used to store integer values, floating-point types are used to store values with decimal parts, and strings are used to store text data.
[0127] To obtain the required data type corresponding to each field information in the target data table, the user may set the required data type of each field information in the data table in advance when storing the data table in the database. For example, the required data type of the student name may be set to a string, and the required data type of the student age may be set to an integer, etc.
[0128] The method of identifying the data type of the added data may be to identify the format of the added data. If the added data is text information, the data type is a string (String); if the added data consists of numbers, the data type of the integer is an integer (int), and the data type of the decimal is a floating point type (float, double); if the added data has only true or false, the data type is a Boolean type (boolean).
[0129] The method of generating the type error prompt information of the added data may be to identify the field information corresponding to the added data, match the data type of the added data with the required data type of the corresponding field information, and if the match is inconsistent, write the result of the type matching inconsistency into the prompt information, and generate the type error prompt information of the added data to prompt the user to check the type of the added data. For example, the added data is 12.6, the data type is floating point type, and the required data type of the corresponding field information of the student age is integer type. The floating point type and the integer type do not match each other, and the type error prompt information of the added data should be generated.
[0130] The advantage of this setting of the scheme is that the data type of the user's added data can be detected to promptly discover the user's input errors and keep the data format in the data table unified, which is conducive to avoiding the problem of data incompatibility in the data table.
[0131] Embodiment 4
[0132] Figure 5 This is a flow chart of a method for automatically generating a page based on a query SQL statement provided in Example 4 of the present application. This solution makes a better improvement on the above-mentioned embodiment, and the specific improvement is: after receiving the SQL statement input by the user, the method also includes: after receiving the SQL statement input by the user, the method also includes: if the SQL statement is a delete type query statement, then the primary key information of the target data table is obtained; the primary key information of the target data table is used as output information, and the page generation code is determined based on the output information; the target page to be displayed is generated according to the page generation code; the user's deletion operation is received; and the primary key of the deletion object corresponding to the deletion operation is deleted from the target data table.
[0133] like Figure 5 As shown, specifically including the following:
[0134] S501, obtaining field information of at least one pre-built data table;
[0135] S502, receiving a SQL statement input by a user;
[0136] S503: If the SQL statement is a delete type query statement, obtain the primary key information of the target data table;
[0137] The delete type query statement can be a query SQL statement sent by the user to delete the existing data at a specified location in the data table. For example, delete all the information of student B in the data table of class 1.
[0138] The primary key information can be representative information in the same row of data in the data table. For example, in a class data table, if the student number is the primary key information, then by querying the student number, you can obtain all the data such as the name and age of the student corresponding to the student number in the same row.
[0139] The method for obtaining the primary key information of the target data table is that the user enters the information to be deleted in the specified input box through the client. The client generates a corresponding SQL statement based on the information entered by the user and sends it to the server. The server interprets the SQL statement after receiving it and extracts the information entered by the user as the deletion information of the target data table.
[0140] S504, taking the primary key information of the target data table as output information, and determining a page generation code based on the output information;
[0141] A method for determining the page generation code may be to obtain, after obtaining the deletion information of the target data table, the information content of the same row corresponding to the primary key information of the target data table, and use the primary key information and the information content of the same row as the output information, and fill the output information into a specified position in a preset code framework to obtain a page generation code that can display the output information of the target data table and has a deletion option.
[0142] S505, generating a target page to be displayed according to the page generation code;
[0143] S506, receiving a deletion operation from the user;
[0144] The method of receiving the user's deletion operation can be that the user clicks the deletion option corresponding to the data to be deleted in the target page. After the client receives the user's click operation, it obtains the deletion object, that is, the data content that the user wants to delete, and sends the deletion object and the deletion instruction to the server, which is received by the server.
[0145] S507: Delete the deletion object primary key corresponding to the deletion operation from the target data table.
[0146] The method of deleting the primary key of the deleted object corresponding to the deletion operation from the target data table may be to extract the target data table from the database, query the deleted object in the target data table, and delete the corresponding primary key of the deleted object.
[0147] The benefit of this setting is that it can support users to delete data information in the target data table, perform simple data deletion operations, and improve user work efficiency and database usage experience.
[0148] Embodiment 5
[0149] Figure 6 This is a flow chart of a method for automatically generating a page based on a query SQL statement provided in Example 5 of the present application. This solution makes a better improvement on the above-mentioned embodiment, and the specific improvement is: if the SQL statement is a modification type query statement, the field information of the target data table and the data content corresponding to the field information are obtained; the field information of the target data table is used as the output parameter field, and the data content corresponding to the field information is used as the output parameter data corresponding to the output parameter field, and the page generation code is determined based on the output parameter field and the output parameter data; the target page to be displayed is generated according to the page generation code; the user's data change operation is received; and the change object data corresponding to the data change operation is modified in the target data table.
[0150] like Figure 6 As shown, specifically including the following:
[0151] S601, obtaining field information of at least one pre-built data table;
[0152] S602, receiving a SQL statement input by a user;
[0153] S603: If the SQL statement is a modification type query statement, then obtain the field information of the target data table and the data content corresponding to the field information;
[0154] The modification type query statement can be a query SQL statement sent by the user to change the existing data at a specified position in the data table to new data. For example, change the student name a to b in the data table of class 1.
[0155] The method of obtaining the field information of the target data table and the data content corresponding to the field information can be that the user enters the existing data that he wants to change in the specified input box through the client, and the client generates a corresponding SQL statement based on the information entered by the user and sends it to the server. After receiving the SQL statement, the server interprets it and extracts the information entered by the user as the field information and the data content corresponding to the field information. For example, if the user wants to change the name a in the student name, the field information is the student name, and the data content corresponding to the field information is a.
[0156] S604, using the field information of the target data table as an output parameter field, using the data content corresponding to the field information as output parameter data corresponding to the output parameter field, and determining a page generation code based on the output parameter field and the output parameter data;
[0157] A method for determining page generation code may be to, after obtaining the field information of the target data table and the data content corresponding to the field information, use the field information of the target data table as the output parameter field, and use the data content corresponding to the field information as the output parameter data corresponding to the output parameter field, and fill the output parameter field and the output parameter data into a specified position in a preset code framework to obtain a page generation code that can display the field information of the target data table and the data content corresponding to the field information, and add an input box for obtaining new data after each data content.
[0158] S605, generating a target page to be displayed according to the page generation code;
[0159] S606, receiving a data modification operation from a user;
[0160] The method of receiving the user's data change operation can be that the user enters the modified new data in the input box corresponding to the data content to be modified in the target page, and the client sends the new data and the corresponding original data to the server, which receives it.
[0161] S607: Modify the change object data corresponding to the data change operation in the target data table.
[0162] The method of modifying the change object data corresponding to the data change operation in the target data table can be, after receiving the new data and the corresponding original data, taking the original data as the change object data, extracting the target data table in the database, extracting the change object data in the target data table, deleting the change object data, and filling in the new data in that position.
[0163] The benefit of this setting is that it can support users to change the data information in the target data table, making the data change operation simpler and improving the user's work efficiency and database usage experience.
[0164] Embodiment 6
[0165] Figure 7 This is a flow chart of a method for automatically generating a page based on a query SQL statement provided in Example 6 of the present application. This solution makes a better improvement on the above-mentioned embodiment, and the specific improvement is: obtaining the field information of at least one pre-built data table, including: obtaining the table building statement information of at least one pre-built data table; parsing the field information of each data table based on the table building statement information, and parsing the type information of each data table.
[0166] like Figure 7 As shown, specifically including the following:
[0167] S701, obtaining table creation statement information of at least one pre-built data table;
[0168] The table creation statement information may be the specific content of the data table that needs to be stored in the database. The table creation statement information may include the table name, table fields, field types, field contents, and comment information.
[0169] The method for obtaining the table creation statement information of at least one pre-built data table may be that the user enters the table creation statement information of the data table to be stored into the server, and the server receives the information entered by the user and stores it in the database.
[0170] S702, parsing the field information of each data table based on the table creation statement information, and parsing the type information of each data table;
[0171] By parsing the field information and type information of each data table based on the table creation statement information, after the server receives the table creation statement information input by the user, the table creation statement information can be interpreted, and the table header information therein can be used as the field information of the data table, and the data type of each field information can be used as the type information of the data table.
[0172] S703, receiving an SQL statement input by a user, and obtaining an output parameter field in the SQL statement;
[0173] S704, determining the output parameter data corresponding to the output parameter field according to the data table;
[0174] S705, determining a page generation code based on the output parameter field and the output parameter data corresponding to the output parameter field;
[0175] S706: Generate a target page to be displayed according to the page generation code.
[0176] Preferably, this embodiment provides a method for generating a target page for reference:
[0177] The user inputs the table creation statement information of each data table through the client, and the client sends the table creation statement information to the server. After the server parses the table creation statement information, it obtains the field information and requirement type in each data table, modifies the format of the specific record content of the field information according to the corresponding requirement type, and stores it in the corresponding position in the database, and establishes the interface for adding, deleting, and modifying related interfaces and interface input and output parameters according to the field information and requirement type. After the user enters the query SQL statement, the client sends the statement to the server, which parses it and extracts the input and output parameter data in the query SQL statement. According to the input and output parameter data and the corresponding field information and requirement type, the content to be displayed in the target page is generated, for example, it can include the user's input parameter data, output parameter data, the information content that the user wants to query, and the function options for adding, deleting or modifying the information content, etc., and according to the content to be displayed in the target page, the front-end code and back-end code that can display the target page are generated, and the front-end code and back-end code are run to debug and view the results.
[0178] For example, a user needs to design information for a student list page, which includes a student table and a class table. A field in the student table is associated with class data. The table creation statements for the class table and the student table are as follows:
[0179] Student table:
[0180]
[0181]
[0182]
[0183] After the server receives the student table and class table input by the user, it can first parse out the fields and types of the fields in the class table and the student table, as well as the primary key of the student table, which is ID. At the same time, the types of the front-end and back-end codes can be confirmed based on the database type. For example, if the front-end uses vue3 and the back-end uses go, then for example, if the database field is of type varchar, the front-end type of the field is String and the back-end type is string.
[0184] When the user needs to display the student information list page, he can enter a query SQL statement as follows:
[0185]
[0186] After receiving the above query SQL statement on the server side, the query SQL statement is parsed to obtain the corresponding input parameters of student NAME, student AGE, student creation time CREATED_AT, and the corresponding output parameters are student ID, class NAME, student NAME, student GENDER, student AGE, student CREATED_BY, student CREATED_AT, student UPDATED_BY, student UPDATED_AT. At the same time, the type of each field is obtained to obtain the page information. The list of related fields in the page information is as above. When adding a new interface, other fields in the student table can be used as parameters for the new field. When updating and deleting interfaces, the primary key is generally used as the interface input parameter to generate the front-end and back-end addition, deletion, modification and query code. After generating the front-end and back-end code, deploy the corresponding front-end and back-end services to see the generated page effect.
[0187] The advantage of this arrangement of the solution is that the data tables input by the user can be classified and stored according to a predetermined format, avoiding overlaps between data tables and data, resulting in data storage confusion and affecting the user experience.
[0188] Embodiment 7
[0189] Figure 8 It is a structural diagram of the automatic page generation device based on query SQL statements provided in Example 7 of the present application.
[0190] like Figure 8 As shown, specifically including the following:
[0191] The field information acquisition module 801 is used to acquire the field information of at least one pre-built data table;
[0192] The output parameter field acquisition module 802 is used to receive the SQL statement input by the user and obtain the output parameter field in the SQL statement;
[0193] An output parameter data determination module 803 is used to determine the output parameter data corresponding to the output parameter field according to the data table;
[0194] A page generation code determination module 804, configured to determine a page generation code based on the output parameter field and the output parameter data corresponding to the output parameter field;
[0195] The target page generation module 805 is used to generate a target page to be displayed according to the page generation code.
[0196] In the embodiment of the present application, the field information acquisition module is used to acquire the field information of at least one pre-built data table; the output parameter field acquisition module is used to receive the SQL statement input by the user and acquire the output parameter field in the SQL statement; the output parameter data determination module is used to determine the output parameter data corresponding to the output parameter field according to the data table; the page generation code determination module is used to determine the page generation code based on the output parameter field and the output parameter data corresponding to the output parameter field; the target page generation module is used to generate the target page to be displayed according to the page generation code. Through the above-mentioned device for automatic page generation based on query SQL statements, a display page can be generated based on the query statement of the data table, so that users can quickly obtain the required data from a large amount of data through key fields, which greatly saves data query time, and can automatically configure the layout of the display page to improve the page development efficiency and page quality.
[0197] In the embodiment of the present application, a device for automatically generating a page based on a query SQL statement can be a device, or a component, an integrated circuit, or a chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc., and the non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0198] In the embodiment of the present application, a device for automatically generating a page based on a query SQL statement may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0199] The device for automatically generating pages based on query SQL statements provided in the embodiment of the present application can implement the various processes implemented in the above-mentioned method embodiments. To avoid repetition, they will not be described here.
[0200] Embodiment 8
[0201] like Fig. 9 As shown, an embodiment of the present application also provides an electronic device 900, including a processor 901, a memory 902, and a program or instruction stored in the memory 902 and executable on the processor 901. When the program or instruction is executed by the processor 901, each process of an embodiment of the device for automatically generating pages based on query SQL statements is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0202] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0203] Embodiment 9
[0204] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned device embodiment for automatically generating pages based on query SQL statements is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0205] The processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0206] Embodiment 10
[0207] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned device embodiment for automatically generating pages based on query SQL statements, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0208] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0209] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0210] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0211] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
[0212] The above are only preferred embodiments of the present application and the technical principles used. The present application is not limited to the specific embodiments described herein, and various obvious changes, readjustments and substitutions that can be made by those skilled in the art will not deviate from the scope of protection of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the claims.
Claims
1. A method for automatically generating pages based on SQL statements, characterized in that: The method comprises: Obtaining field information of at least one pre-built data table; Receive the SQL statement input by the user, and obtain the output parameter fields in the SQL statement; Determine the output parameter data corresponding to the output parameter field according to the data table; Determine a page generation code based on the output parameter field and the output parameter data corresponding to the output parameter field; Generate a target page to be displayed according to the page generation code.
2. The method for automatically generating pages based on query SQL statements according to claim 1, characterized in that: After receiving the SQL statement input by the user, the method further includes: Obtaining input parameter fields and output parameter fields in the SQL statement, and conditional data input for at least one of the input parameter fields; According to the matching of the condition data of the input parameter field with the field information, the output parameter data corresponding to the output parameter field is determined; Determine a page generation code based on the input parameter fields, conditional data input for at least one of the input parameter fields, the output parameter fields, and output parameter data corresponding to the output parameter fields; Generate a target page to be displayed according to the page generation code.
3. The method for automatically generating pages based on query SQL statements according to claim 1, characterized in that: After receiving the SQL statement input by the user, the method further includes: If the SQL statement is a new type query statement, then the field information of the target data table is obtained; Using the field information of the target data table as an output parameter field, and determining a page generation code based on the output parameter field; Generate a target page to be displayed according to the page generation code; Receive additional data input by the user; The added data is added to the target data table.
4. The method for automatically generating pages based on query SQL statements according to claim 1, characterized in that: After receiving the SQL statement input by the user, the method further includes: If the SQL statement is a delete type query statement, then the primary key information of the target data table is obtained; Using the primary key information of the target data table as output information, and determining a page generation code based on the output information; Generate a target page to be displayed according to the page generation code; Receive the user's deletion operation; The deletion object primary key corresponding to the deletion operation is deleted from the target data table.
5. The method for automatically generating pages based on query SQL statements according to claim 1, characterized in that: After receiving the SQL statement input by the user, the method further includes: If the SQL statement is a modification type query statement, then obtaining the field information of the target data table and the data content corresponding to the field information; Using the field information of the target data table as the output parameter field, using the data content corresponding to the field information as the output parameter data corresponding to the output parameter field, and determining the page generation code based on the output parameter field and the output parameter data; Generate a target page to be displayed according to the page generation code; Receive data change operations from users; The change object data corresponding to the data change operation is modified in the target data table.
6. The method for automatically generating pages based on query SQL statements according to claim 3, characterized in that: After receiving the added data input by the user, the method includes: Obtain the required data type corresponding to each field information in the target data table; Identify the data type of the added data; When the data type of the added data is inconsistent with the required data type of the information field, a prompt message of an error in the type of the added data is generated.
7. The method for automatically generating pages based on query SQL statements according to claim 1, characterized in that: Get the field information of at least one pre-built data table, including: Obtain table creation statement information of at least one pre-built data table; The field information of each data table is parsed based on the table creation statement information, and the type information of each data table is parsed.
8. A device for automatically generating pages based on query SQL statements, characterized in that: The device comprises: A field information acquisition module, used to acquire field information of at least one pre-built data table; The output parameter field acquisition module is used to receive the SQL statement input by the user and obtain the output parameter fields in the SQL statement; An output parameter data determination module, used to determine the output parameter data corresponding to the output parameter field according to the data table; A page generation code determination module, used to determine the page generation code based on the output parameter field and the output parameter data corresponding to the output parameter field; The target page generation module is used to generate the target page to be displayed according to the page generation code.
9. An electronic device, characterized in that: It includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor. When the program or instruction is executed by the processor, the steps of a method for automatically generating a page based on a query SQL statement as described in any one of claims 1 to 7 are implemented.
10. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the steps of the method for automatically generating a page based on a query SQL statement as described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Method and device for automatically generating code
CN105487864A
Application building method and device, apparatus and computer readable storage medium
CN113434133A
Data query method and device, storage medium and electronic equipment
CN113656439A
Software development method and platform, electronic equipment and computer readable storage medium
CN114741079A
Method and system for generating code and interface document based on sql and terminal equipment
CN118210488A
Cited By
Page display method, system and equipment for health record data and medium
CN120296066A
Method, system, device and medium for displaying health record data on a page
CN120296066B
Large data screen generation method and device, server and storage medium
CN121117348A
