Database management method and device, electronic equipment, storage medium and program product
By dynamically obtaining dynamic secondary properties of database types and rendering subforms, we solve the problem of manually adjusting the code to adapt to the complexity of different database characteristics, and achieve the effect of simplifying configuration, reducing error risk and improving efficiency.
Patent Information
- Application Number
- CN202411823935.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-04-01
AI Technical Summary
During the development process, manually adjusting and modifying the code to adapt to the characteristics of different databases will increase the complexity of the code, increase maintenance difficulty, and prone to errors.
By responding to the database type selected by the user in the database management form, the corresponding interface is called to obtain dynamic secondary attributes, and the corresponding subform is rendered based on these attributes, and the target database configuration is finally generated.
Simplifies the database configuration process, reduces code complexity, reduces the risk of human errors, and improves the accuracy and efficiency of database configuration.
Smart Images

Figure CN119739416A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a database management method, device, electronic device, storage medium and program product. Background Art
[0002] In the process of developing big data products, it is usually necessary to use various types of databases, because different database systems have their own advantages in performance, scalability, data models and query capabilities, and different database systems are suitable for different data storage and processing requirements. Common types of databases on the market include MySQL, Oracle, MongoDB, neo4j, hbase, redis, etc. While completing data storage, each database has its own unique characteristics and limitations, such as data models, query languages, transaction processing, scalability, etc. These differences require specific processing for each database during the development process.
[0003] At present, the database characteristics are generally solidified through the front-end page, that is, certain parameters or properties of the database are fixed through configuration files, these configurations are read at startup, and remain unchanged during the entire operation process. When the properties need to be adjusted, the configuration and code are manually modified one by one.
[0004] However, when there are many types of databases involved, manually adjusting and modifying the code to adapt to the characteristics of each database will increase the complexity of the code, make maintenance more difficult, and be prone to errors. Summary of the invention
[0005] The present application provides a database management method, device, electronic device, storage medium and program product, which are used to solve the technical problem that manual adjustment and modification of codes to manage databases will lead to increased code complexity.
[0006] In a first aspect, the present application provides a database management method, comprising:
[0007] In response to the database type selected by the user in the database management form, an interface corresponding to the database type is called to obtain a dynamic secondary attribute corresponding to the database type, where the dynamic secondary attribute represents a personalized attribute related to the database type;
[0008] According to the dynamic secondary attributes, render the subform corresponding to the database type to obtain the target subform;
[0009] Get the target database configuration based on the static properties and the target subform.
[0010] Optionally, a subform corresponding to the database type is rendered according to the dynamic secondary attribute to obtain a target subform, including:
[0011] According to the preset parsing rules, the dynamic secondary attributes are parsed to determine the data type of the field;
[0012] Determine the rendering component type based on the data type of the field;
[0013] According to the rendering component type, the form element corresponding to the field is rendered to obtain the target subform.
[0014] Optionally, after parsing the dynamic secondary attribute according to a preset parsing rule to determine the data type of the field, the method further includes:
[0015] According to the parsing rules, the dynamic secondary attributes are parsed to determine the relevant attributes of the constraint field, which are attributes related to the validation rules, restriction conditions, and display conditions of the field;
[0016] Set the field according to the relevant attribute to obtain the first sub-attribute value;
[0017] Determine the target subform based on the first sub-attribute value.
[0018] Optionally, the method further comprises:
[0019] Get the special field requirements corresponding to the database type. Special field requirements are customized requirements for fields in different scenarios.
[0020] Determine the association between dynamic secondary attributes based on special field requirements;
[0021] The association relationship is set to obtain the second sub-attribute value;
[0022] The target subform is determined based on the second sub-attribute value.
[0023] Optionally, before rendering a subform corresponding to the database type according to the dynamic secondary attribute to obtain the target subform, the method further includes:
[0024] Obtain a file name that conforms to a preset format, where the file name represents a subform of a database of different types;
[0025] Determine the corresponding subform based on the file name and database type.
[0026] Optionally, in response to the database type selected by the user in the database management form, before calling the interface corresponding to the database type to obtain the dynamic secondary attribute corresponding to the database type, the method further includes:
[0027] Initialize the database management form. The page of the database management form contains selection controls and static properties of the database type.
[0028] In a second aspect, the present application provides a database management device, comprising:
[0029] A calling module, for responding to the database type selected by the user in the database management form, calling the interface corresponding to the database type, and obtaining the dynamic secondary attribute corresponding to the database type, wherein the dynamic secondary attribute represents the personalized attribute related to the database type;
[0030] A rendering module is used to render a subform corresponding to the database type according to the dynamic secondary attributes to obtain a target subform;
[0031] Get module, used to get target database configuration according to static attributes and target subform.
[0032] Optionally, the rendering module is specifically used to:
[0033] According to the preset parsing rules, the dynamic secondary attributes are parsed to determine the data type of the field;
[0034] Determine the rendering component type based on the data type of the field;
[0035] According to the rendering component type, the form element corresponding to the field is rendered to obtain the target subform.
[0036] Optionally, the rendering module is also used to:
[0037] According to the parsing rules, the dynamic secondary attributes are parsed to determine the relevant attributes of the constraint field, which are attributes related to the validation rules, restriction conditions, and display conditions of the field;
[0038] Set the field according to the relevant attribute to obtain the first sub-attribute value;
[0039] Determine the target subform based on the first sub-attribute value.
[0040] Optionally, the rendering module is also used to:
[0041] Get the special field requirements corresponding to the database type. Special field requirements are customized requirements for fields in different scenarios.
[0042] Determine the association between dynamic secondary attributes based on special field requirements;
[0043] The association relationship is set to obtain the second sub-attribute value;
[0044] The target subform is determined based on the second sub-attribute value.
[0045] Optionally, get the module, also for:
[0046] Obtain a file name that conforms to a preset format, where the file name represents a subform of a database of different types;
[0047] Determine the corresponding subform based on the file name and database type.
[0048] Optionally, the calling module is also used to:
[0049] Initialize the database management form. The page of the database management form contains selection controls and static properties of the database type.
[0050] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0051] Memory stores computer-executable instructions;
[0052] The processor executes the computer-executable instructions stored in the memory to implement the method as described in the first aspect and various possible implementations of the first aspect.
[0053] In a fourth aspect, the present application provides a computer-readable storage medium, which stores computer execution instructions. When the computer execution instructions are executed by a processor, they are used to implement the method as described in the first aspect and various possible implementation methods of the first aspect.
[0054] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, is used to implement the method as described in the first aspect and various possible implementation methods of the first aspect.
[0055] The database management method, device, electronic device, storage medium and program product provided by the present application can further obtain relevant dynamic secondary attributes by calling the interface corresponding to the database type in response to the specific database type selected by the user in the database management form. These dynamic secondary attributes represent the personalized characteristics of the database type. Since these attributes usually vary between different databases, after being dynamically obtained according to the selected database type, a target subform related to the database type can be rendered, which includes personalized configuration items that the user needs to fill in. On the basis of the rendered target subform, the static attributes and the dynamic attributes entered by the user in the target subform are combined to finally obtain a configuration of the target database. By dynamically obtaining the secondary attributes through the back-end interface and rendering the subform according to the selected database type, the user can configure the database more easily. At the same time, the dynamically rendered subform will automatically load the corresponding configuration items according to the database type selected by the user, avoiding errors that occur when manually modifying the configuration and reducing code complexity. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0057] Figure 1 Schematic diagram of the process of the database management method provided in the embodiment of the present application Figure 1 ;
[0058] Figure 2 A schematic diagram of a database management form page provided in an embodiment of the present application;
[0059] Figure 3 Schematic diagram of the process of the database management method provided in the embodiment of the present application Figure 2 ;
[0060] Figure 4 Schematic diagram of the process of the database management method provided in the embodiment of the present application Figure 3 ;
[0061] Figure 5 A flowchart of another database management method provided in an embodiment of the present application;
[0062] Figure 6 A schematic diagram of the structure of a database management device provided in an embodiment of the present application;
[0063] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0064] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0065] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0066] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0067] Current database management systems usually fix the parameters or properties of the database through configuration files, read these configurations when the application starts, and remain unchanged throughout the operation. Every time the properties or configuration of the database need to be adjusted, developers must manually modify the code and configuration files, which is particularly cumbersome and error-prone for multiple database types. With the increase in database types and configurations, the complexity and maintenance difficulty of the code will also increase significantly. Manually modifying configurations and codes is prone to human errors, such as inconsistent modifications, missing configurations, and incorrect adaptation of certain database features. These errors may cause the application to be unable to correctly connect or operate different databases, affecting the stability and reliability of the system. With the continuous development and introduction of new databases, existing systems are often unable to quickly adapt to these new database features, resulting in developers needing to re-modify the code and configuration files to support new database types. This not only increases the expansion cost of the system, but also reduces the flexibility of the system.
[0068] Based on this, the present application proposes a database management method, device, electronic device, storage medium and program product. The method transfers multiple database attributes that need to be managed by the front end to the back end. By calling the interface corresponding to the database type, the system can return specific personalized configuration items according to the database type, thereby reducing the complexity of the front-end code. Then, considering that the attributes of the database include dynamic attributes and static attributes, the required dynamic attributes are further filled by dynamically creating sub-forms, without the need to manually configure complex database attributes, thereby avoiding errors that may occur during manual configuration. For static attributes, since they do not depend on the fields of a specific database type, the attributes can be set directly, that is, filled by the user, thereby combining into a complete database.
[0069] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0070] Figure 1 Schematic diagram of the process of the database management method provided in the embodiment of the present application Figure 1 .like Figure 1 As shown, the method may include:
[0071] S101. In response to a database type selected by a user in a database management form, an interface corresponding to the database type is called to obtain a dynamic secondary attribute corresponding to the database type.
[0072] Among them, the dynamic secondary attributes represent personalized attributes related to the database type.
[0073] The database type refers to a specific type of database system, such as MySQL, PostgreSQL, MongoDB, oracle, MongoDB, neo4j, hbase, redis, etc. Different database types may have different characteristics and configuration requirements. In this embodiment, the database type is a dynamic first-level attribute, which can be switched according to the user's choice, so as to dynamically manage the database.
[0074] The database management form is a part of the user interface that allows users to enter and manage information related to the database. The form usually includes multiple fields, each field corresponding to a certain attribute of the database.
[0075] Dynamic secondary attributes may refer to personalized attributes related to a specific database type, which are usually obtained by calling a specific interface. These attributes include database-specific configuration options, connection parameters, etc., such as database engine, storage engine, index settings, connection pool configuration, cache size, and other parameters required for a specific database type.
[0076] In this embodiment, a database management form is created in advance. The user selects a specific database type in the database management form. The system will respond to the user's selection and call the Application Programming Interface (API) corresponding to the selected database type. The API will return dynamic secondary attributes related to the database type.
[0077] It can be understood that the user only needs to select the database type, and the system can automatically load the relevant properties and update the interface, reducing the complexity of manual input and configuration by the user, and can flexibly adapt to the configuration requirements of multiple database types without the need to design a separate form for each database type. By using the interface to obtain dynamic properties, the system can be easily expanded to support new database types by simply adding the corresponding interface support, reducing manual intervention and code adjustments.
[0078] S102: Render a subform corresponding to the database type according to the dynamic secondary attribute to obtain a target subform.
[0079] The subform is a part of the database management form, which is used to display and input properties related to a specific database type. Each database type has a different subform.
[0080] The target subform may refer to a final user interface obtained after converting the dynamic secondary attributes into a form element that a user can interact with (ie, rendering), in which the user can enter or view configuration information related to a specific database type.
[0081] In this embodiment, by parsing the obtained dynamic secondary attributes, it can be determined how each attribute should be presented in the user interface, including selecting the appropriate input component type (such as a text box, drop-down menu, check box, etc.), and then based on the parsing results, the system generates and renders a sub-form, converting the dynamic secondary attributes into form elements with which the user can interact. After the rendering is completed, the user interface displays the target sub-form, in which the user can enter or view the configuration information.
[0082] In some embodiments, after obtaining the target subform, it can also be appropriately adjusted according to the preset layout and style, such as the arrangement order of fields, the spacing between fields, the display method of labels, the validation logic of fields, etc., so as to improve the usability and user experience of the form.
[0083] S103. Obtain target database configuration according to static attributes and target subform.
[0084] Among them, static attributes may refer to configuration items that are independent of the database type and are always fixed throughout the system. They are shared and universal and do not change with the choice of database type. For example, fields such as data source name, version, and description. Exemplarily, static attributes may include: general connection settings for the database (such as the database port, the size of the connection pool, etc.), database log settings (such as the location of the log file, the log level, etc.), and some system-level default parameters (such as character set, timeout settings, etc.). Static attributes are usually fixed at initialization or configured by the system administrator. They apply to all database types and do not depend on the type of database selected by the user.
[0085] In this embodiment, after the sub-form is rendered, it is necessary to combine static attributes (such as database table structure, fixed fields, etc.) for final integration to ensure that the generated sub-form meets the requirements of the database, and finally obtain a complete database configuration that meets user needs. The database configuration can be used for database management or other operations.
[0086] In some embodiments, after the target database configuration is generated, it may also be validated to ensure that all required properties are correctly configured and then the configuration is saved to a database or configuration file.
[0087] Correspondingly, before the above step S101, it is also necessary to initialize the database management form, and the page of the database management form includes a selection control and static properties of the database type.
[0088] Initialization refers to the automatic generation of a form interface when the database management system is first loaded, allowing users to configure database-related parameters. This form is a component of the database management interface, and its purpose is to allow users to easily select and configure different database types and related configuration items. Since different database types have different characteristics and configuration requirements, the user's choice will directly affect the subsequent configuration sub-form content.
[0089] A selector is an interactive element in a user interface that lets users select the database type they want to configure from a list of available database types.
[0090] It should be noted that the selection control can be a drop-down box, a radio button, or any other selectable form, and this application does not limit this.
[0091] like Figure 2 As shown, Figure 2 A schematic diagram of a database management form provided in an embodiment of the present application, including database type, static attributes, and dynamic secondary attributes. In this embodiment, the dynamic primary attribute consists of the database type, and the page is displayed as a selection control with multiple radio buttons. The static attributes consist of the data source name, version, and description. The dynamic secondary attributes consist of the table structure, field type, and constraints.
[0092] It should be noted that when the selection control switches the database, for static properties, the form will always be displayed for the user to configure or confirm. For dynamic properties, the form will dynamically generate and display corresponding options based on the database type selected by the user. That is, it is necessary to render it according to the dynamic secondary attributes in the subform corresponding to the database to obtain the complete target subform and display it in the database management form on the front end.
[0093] As an example, the initialization of the database management form contains the following:
[0094] Database type selection control: a drop-down box or radio button for users to select the database type (such as MySQL, PostgreSQL, Oracle, etc.).
[0095] Static properties: These properties are globally applicable, such as the database connection timeout (which can be set to a global default value, such as 30 seconds) and the log file path (such as the default path / var / log / database / ).
[0096] Dynamic secondary attributes: These attributes depend on the database type selected. For example, if the user selects MySQL, the form will display MySQL-specific parameters such as innodb_buffer_pool_size, and if PostgreSQL is selected, PostgreSQL-specific settings such as shared_buffers will be displayed.
[0097] It can be understood that when initializing the database management form, the page contains selection controls and static properties of the database type, which can guide users to configure through a clear user interface. At the same time, it combines common and global configuration items to avoid confusion caused by different database types, thereby allowing users to easily configure different database types.
[0098] The database management method provided in the embodiment of the present application improves the accuracy and efficiency of database configuration, and enhances the flexibility and scalability of database configuration. It also simplifies the database management process, reduces the risk of human error, and can be applied to application systems that support multiple database types by dynamically acquiring relevant dynamic secondary attributes using the corresponding interface according to the database type selected by the user, rendering the corresponding sub-form, and combining the static attributes to generate the final database configuration.
[0099] Figure 3 Schematic diagram of the process of the database management method provided in the embodiment of the present application Figure 2 .like Figure 3 As shown, this embodiment is Figure 1 Based on the embodiment, the process of S102 is described in detail, which specifically includes the following steps:
[0100] S301. Parse the dynamic secondary attribute according to the preset parsing rules to determine the data type of the field.
[0101] The parsing rules may refer to a set of rules predefined by the front-end and back-end for parsing dynamic secondary attributes. These rules are usually formulated by developers based on business requirements and database characteristics, and these rules can help the system understand the meaning and requirements of each attribute. For example, if the field value is a numeric type, the system will recognize it as an integer (Integer) or floating point (Float) type, and if it is text, it may be recognized as a string (String) type.
[0102] The data type of a field refers to the type of data that each field accepts, such as string, integer, floating point number, Boolean value, etc. These types determine how the input is presented and validated in the user interface.
[0103] In this embodiment, the system uses preset parsing rules to analyze the dynamic secondary attributes obtained by calling the interface. During the parsing process, the data type of each field is determined, and according to the determined data type, a suitable input component is prepared to be rendered in the user interface.
[0104] S302: Determine the rendering component type according to the data type of the field.
[0105] The rendering component type refers to a specific user interface (UI) component type used to display and input data in a user interface, such as a text box, a drop-down menu, a check box, a date selector, and the like.
[0106] In this embodiment, a set of predefined mapping rules may be used to convert the data type of each field into a corresponding rendering component type, and then a suitable UI component is selected to render the field in the user interface.
[0107] In some embodiments, a third-party component library may also be integrated into the system to quickly introduce new component types and functions, thereby improving the richness of the interface.
[0108] S303: Render the form element corresponding to the field according to the rendering component type to obtain the target subform.
[0109] Among them, form elements may refer to specific UI elements used for data input and interaction in a user interface, which are generated according to a rendering component type and are associated with specific fields.
[0110] In this embodiment, the system generates corresponding form elements according to the rendering component type of each field. For example, a string type generates a text input box, an integer or floating point type generates a number input box, a Boolean type generates a check box or switch, and a date type generates a date selector. The generated form elements are then rendered into the user interface to form a complete target subform, so that users can enter data or interact in the interface.
[0111] It can be understood that by rendering appropriate form elements, an intuitive and easy-to-use user interface is provided, allowing users to easily input and manage data, and the automated rendering process reduces the time and complexity of manual configuration and improves processing efficiency.
[0112] In one achievable method, after the above step S301, the dynamic secondary attributes can also be parsed according to the parsing rules to determine the relevant attributes of the constraint field; then, the field is set according to the relevant attributes to obtain the first sub-attribute value; and then the target sub-form is determined according to the first sub-attribute value.
[0113] Among them, related attributes are attributes related to the validation rules, restrictions, and display conditions of the field, such as maximum length (limiting the maximum number of characters in the field), minimum value, and maximum value (for numeric fields, limiting the value range).
[0114] The first sub-attribute value may refer to field validation, constraint conditions, display format and other information obtained through preset parsing rules after parsing the dynamic secondary attribute, which determines how each field is displayed in the form.
[0115] In this embodiment, the first sub-attribute value is the basis of the target sub-form field attribute, which determines the field's presentation and interaction mode. For example, if the first sub-attribute value of a field is set to "required" and "data format is date", the field in the target sub-form will be set to required, and only valid date formats can be entered.
[0116] Furthermore, the special field requirements corresponding to the database type can also be obtained; then, the association relationship between the dynamic secondary attributes is determined according to the special field requirements; then, the association relationship is set to obtain the second sub-attribute value; finally, the target sub-form is determined according to the second sub-attribute value.
[0117] Among them, special field requirements are customized requirements for fields in different scenarios. For special fields, additional logical processing may be required. For example, some fields may need to display special input controls (such as date pickers, file upload controls), or some fields may need to enable / disable or dynamically display different options based on specific conditions.
[0118] The second sub-attribute value can refer to association rules between fields, control information for field display, dependencies, etc. It defines how fields affect each other. For example, the value of a field may affect the visibility or selection range of other fields.
[0119] In this embodiment, the second sub-attribute value determines the dynamic association and interaction rules between fields, affecting the rendering of the target sub-form. For example, if the second sub-attribute value of a field sets "when the value of field A is X, field B is displayed", then in the target sub-form, the display of field B will be closely related to the value of field A.
[0120] It should be noted that the data type of the field, the related attributes of the constraint field, and the special fields are all used to describe and process the requirements of different dimensions of the form field. The data type of the field mainly describes the basic information of the field itself, including the field type, rendering method, whether it is required, etc. These attributes determine how the front end renders the field. The related attributes of the constraint field usually refer to the attributes related to field validation and rules, which control the constraints of the field input and are mainly used for input validation to ensure that the set attributes (input data) meet the requirements. Special fields are usually additional logical processing for certain special fields. They can be custom attributes or rules dynamically generated according to the association between dynamic secondary attributes. They are not applicable to all fields, but are determined by the database type, or are related to specific business needs and specific field types, such as dynamic validation rules that associate certain field values with other field values.
[0121] It can be understood that by applying validation rules and restrictions, it is possible to ensure that the data entered by the user conforms to the expected format and constraints, thereby improving the accuracy of the data. In addition, the implementation of special field requirements allows the system to provide customized interfaces and functions based on specific business scenarios or user roles, thereby improving the user experience.
[0122] The database management method provided in the embodiment of the present application, by using preset parsing rules, the system can accurately understand and process dynamic secondary attributes, ensure that the data type of each field is correct, and by selecting the appropriate rendering component type, the system can provide an intuitive and easy-to-use user interface to improve the user experience, and through a standardized rendering process, the system can maintain consistent interface behavior and reliability in different database types and scenarios.
[0123] Figure 4 Schematic diagram of the process of the database management method provided in the embodiment of the present application Figure 3 .like Figure 4 As shown, before rendering a subform corresponding to the database type according to the dynamic secondary attribute to obtain the target subform, the method may further include:
[0124] S401, obtaining a file name that complies with a preset format, where the file name represents a subform of a database of a different type.
[0125] The preset format refers to a file naming format agreed upon by the front-end and back-end in the project, such as dbType-form.js, where dbType is a placeholder for the database type.
[0126] S402: Determine the corresponding subform according to the file name and database type.
[0127] In this embodiment, a context can be created by utilizing the require.context function of Webpack, allowing modules that conform to the naming convention to be dynamically loaded at runtime. The database type information is then extracted from the module name using a regular expression. For example, according to the database type selected by the user, the regular expression / (\w+)-form\.js$ / is used to match and extract dbType and determine the corresponding module. Then, the dynamic loading function of Webpack is used to load the corresponding subform module according to the matching result of the file name and the database type.
[0128] Specifically, the Webpack tool can be used to package various resources in the project into one or more files. At runtime, the sub-form module is loaded as needed, and regular expressions are combined to match expressions of a certain pattern in the string, that is, the file name is parsed to determine the database type. At the same time, in the project module, each independent sub-form module needs to be named in advance according to the preset format (protocol or specification) agreed between the front-end and the back-end. Therefore, when the user selects the database type, the system can automatically scan the project module and obtain all file names that meet the naming requirements, thereby determining the corresponding sub-form module, parsing the sub-form module to extract the structure and properties of the sub-form, and rendering the parsed sub-form in the user interface for user input and interaction.
[0129] As an example, first, organize the subform module files in the project in a conventional format. For example, the naming of each subform module file can follow the format:
[0130] dbType-<database type>.js
[0131] Among them, dbType-<database type>.js indicates that the file corresponds to a specific type of database subform module. For example, for MySQL and PostgreSQL type databases, there are the following files: dbType-mysql.js and dbType-postgresql.js.
[0132] Then, through the dynamic import() function of Webpack, require.context() is used to create a context so as to batch load modules that meet a certain pattern in the specified directory, that is, to create a collection of all files that meet specific rules in the specified directory, so as to match and load the corresponding subform module through regular expressions according to the database type passed in. Among them, require.context() is used to dynamically load modules or files.
[0133] At the same time, in the project, the naming of all subform module files needs to follow a specific format, such as dbType-<database type>.js. This convention ensures that when the loadSubFormModule method is called, the database type (such as mysql or postgresql) passed in can be accurately matched to the corresponding module. The loadSubFormModule method is used to dynamically load subform modules or subform components.
[0134] Therefore, when the user selects a database type in the database management form, the corresponding sub-form module can be loaded through the loadSubFormModule method and displayed to the user.
[0135] It is understandable that the core of the above process is to map the database type through the file naming convention, and dynamically load the subform module corresponding to the database type at runtime. Specifically, through the principle of dynamic module loading of Webpack, combined with regular expressions, the subform module of each database type can be named in the project according to the agreed format, and the corresponding subform can be dynamically loaded according to the database type selected by the user, so as to achieve efficient modular management of the project, and each module is loaded on demand, instead of loading all modules when the application starts, to achieve the effect of optimizing performance.
[0136] The database management method provided in the embodiment of the present application can realize modular management of the project through the dynamic loading and agreed format of Webpack, which is easy to maintain and expand. At the same time, dynamic loading reduces the initial loading time and improves the performance and response speed of the application. Through the agreed format and regular expression parsing and matching, the system can easily support new database types. It only needs to add the corresponding module files without redeploying the front end, which reduces the amount of code and makes the code hierarchy more concise and clear.
[0137] Figure 5 A flowchart of another database management method provided in an embodiment of the present application. Figure 5 As shown, the method may include:
[0138] S501. Use the form provided by antd to implement a database management form. The form elements are divided into static general attributes and dynamic personalized attributes.
[0139] Antd is the abbreviation of the React implementation version of Ant Design. It is a React component library based on the Ant Design design specification. It provides a variety of UI components, such as buttons, forms, tables, modal boxes, etc., through which you can quickly build the user interface of the application.
[0140] S502: Request the interface to obtain corresponding secondary attributes according to the selected type, that is, personalized attributes of corresponding different databases.
[0141] S503. Using the principle of dynamic module loading of webpack, encapsulate a method that can read file names, combine it with regular expressions, name each independent module in the project module according to the agreed format, pass in the database type, and load the corresponding subform.
[0142] S504: While loading the corresponding subform according to the database type passed in, receive the corresponding database attributes from the interface, and parse the target attributes according to the agreed rules of the front-end and back-end.
[0143] Among them, the target attributes include the rendering component type, such as whether it is a normal input box or a numeric input box, and other attributes, such as maximum length, minimum value, maximum value, etc., as well as extended attributes, such as logic processing specifically for certain special fields. Extended attributes can be agreed upon according to specific needs.
[0144] S505: Combine the static general attributes and the dynamic sub-attribute values, save and submit.
[0145] In this embodiment, first, the static general properties (general configuration options applicable to all database types) entered or selected by the user in the form are integrated with the dynamic sub-properties (personalized configuration options loaded according to the specific database type) to ensure that the final configuration contains all necessary information. Before submission, the combined data needs to be verified to ensure that all required fields have been filled in and the values of each field are in the expected format and range. This step can be achieved through the verification logic of the front end, or it can be performed before submission to the back end. Then, the complete configuration data that has passed the verification is submitted to the back-end server for saving, and the server will store these configurations in the database or process them in other ways. After submission is completed, the system can provide feedback to the user to confirm that the configuration has been successfully saved. The feedback method can be to display a success message or update the interface status, etc.
[0146] The database management method provided in the embodiment of the present application solves the problems of bloated front-end code and complex logic processing in the past by transferring the various database properties that need to be managed by the front-end to the back-end interface for acquisition, and utilizes a combination of dynamic and static methods. At the same time, the webpack loading module principle is utilized to encapsulate dynamically loaded sub-files, making the code hierarchy more concise and clear. In addition, according to the front-end and back-end agreements, the back-end can completely complete the dynamic maintenance of properties by operating the database, without the need to redeploy the front-end, thereby reducing maintenance costs. Therefore, by combining the flexible interaction between the front-end and the back-end, efficient management of different database types is achieved.
[0147] Figure 6This is a schematic diagram of the structure of the database management device provided in the embodiment of the present application. Figure 6 As shown, the database management device 60 includes:
[0148] The calling module 601 is used to call the interface corresponding to the database type in response to the database type selected by the user in the database management form, and obtain the dynamic secondary attribute corresponding to the database type, where the dynamic secondary attribute represents the personalized attribute related to the database type;
[0149] The rendering module 602 is used to render a subform corresponding to the database type according to the dynamic secondary attribute to obtain a target subform;
[0150] The obtaining module 603 is used to obtain the target database configuration according to the static attributes and the target subform.
[0151] Optionally, the rendering module 602 is specifically configured to:
[0152] According to the preset parsing rules, the dynamic secondary attributes are parsed to determine the data type of the field;
[0153] Determine the rendering component type based on the data type of the field;
[0154] According to the rendering component type, the form element corresponding to the field is rendered to obtain the target subform.
[0155] Optionally, the rendering module 602 is further configured to:
[0156] According to the parsing rules, the dynamic secondary attributes are parsed to determine the relevant attributes of the constraint field, which are attributes related to the validation rules, restriction conditions, and display conditions of the field;
[0157] Set the field according to the relevant attribute to obtain the first sub-attribute value;
[0158] Determine the target subform based on the first sub-attribute value.
[0159] Optionally, the rendering module 602 is further configured to:
[0160] Get the special field requirements corresponding to the database type. Special field requirements are customized requirements for fields in different scenarios.
[0161] Determine the association between dynamic secondary attributes based on special field requirements;
[0162] The association relationship is set to obtain the second sub-attribute value;
[0163] The target subform is determined based on the second sub-attribute value.
[0164] Optionally, module 603 is obtained, further used for:
[0165] Obtain a file name that conforms to a preset format, where the file name represents a subform of a database of different types;
[0166] Determine the corresponding subform based on the file name and database type.
[0167] Optionally, the calling module 603 is further used to:
[0168] Initialize the database management form. The page of the database management form contains selection controls and static properties of the database type.
[0169] The database management device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be described in detail here.
[0170] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 7 As shown, the electronic device 70 provided in the embodiment of the present application includes: at least one processor 701 and a memory 702. The electronic device 70 also includes a communication component 703. The processor 701, the memory 702 and the communication component 703 are connected via a bus 704.
[0171] In a specific implementation process, at least one processor 701 executes the computer-executable instructions stored in the memory 702, so that at least one processor 701 executes the above method.
[0172] The specific implementation process of the processor 701 can be found in the above-mentioned method embodiment, and its implementation principle and technical effect are similar, so the embodiments of the present application will not be repeated here.
[0173] In the above Figure 7 In the illustrated embodiment, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc. The steps of the method disclosed in the present application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0174] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.
[0175] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0176] The present application also provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0177] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above method is implemented.
[0178] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0179] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0180] The division of units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0181] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present application.
[0182] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0183] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can essentially or in other words, the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0184] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0185] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0186] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.
[0187] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.
[0188] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. If not specifically stated, the processor may be any appropriate hardware processor, such as a CPU, a graphics processing unit (GPU), a field-programmable gate array (FPGA), a DSP, and an ASIC, etc. If not specifically stated, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc.
[0189] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0190] In the above embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0191] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0192] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A database management method, characterized in that: include: In response to a database type selected by a user in a database management form, an interface corresponding to the database type is called to obtain a dynamic secondary attribute corresponding to the database type, wherein the dynamic secondary attribute represents a personalized attribute related to the database type; Rendering a subform corresponding to the database type according to the dynamic secondary attribute to obtain a target subform; According to the static attributes and the target subform, the target database configuration is obtained.
2. The method according to claim 1, characterized in that The step of rendering a subform corresponding to the database type according to the dynamic secondary attribute to obtain a target subform includes: According to the preset parsing rules, the dynamic secondary attribute is parsed to determine the data type of the field; Determine the rendering component type according to the data type of the field; According to the rendering component type, a form element corresponding to the field is rendered to obtain the target subform.
3. The method according to claim 2, characterized in that After parsing the dynamic secondary attribute according to the preset parsing rules to determine the data type of the field, the method further includes: According to the parsing rule, the dynamic secondary attribute is parsed to determine the relevant attributes of the constraint field, where the relevant attributes are attributes related to the validation rule, restriction condition, and display condition of the field; Setting the field according to the relevant attribute to obtain a first sub-attribute value; The target subform is determined according to the first sub-attribute value.
4. The method according to claim 3, characterized in that The method further comprises: Acquire special field requirements corresponding to the database type, where the special field requirements are customized requirements for the field in different scenarios; Determining the association relationship between the dynamic secondary attributes according to the special field requirements; The association relationship is set to obtain a second sub-attribute value; The target subform is determined according to the second sub-attribute value.
5. The method according to any one of claims 1 to 4, characterized in that Before rendering a subform corresponding to the database type according to the dynamic secondary attribute to obtain a target subform, the method further includes: Obtaining a file name that conforms to a preset format, wherein the file name represents a subform of a database of a different type; The corresponding subform is determined according to the file name and the database type.
6. The method according to any one of claims 1 to 4, characterized in that In response to the database type selected by the user in the database management form, before calling the interface corresponding to the database type to obtain the dynamic secondary attribute corresponding to the database type, the method further includes: Initialize the database management form, the page of which includes a selection control for the database type and the static properties.
7. A database management device, characterized in that: include: A calling module, configured to, in response to a database type selected by a user in a database management form, call an interface corresponding to the database type to obtain a dynamic secondary attribute corresponding to the database type, wherein the dynamic secondary attribute represents a personalized attribute related to the database type; A rendering module, used for rendering a subform corresponding to the database type according to the dynamic secondary attribute to obtain a target subform; The obtaining module is used to obtain the target database configuration according to the static attributes and the target subform.
8. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 6 when executed by a processor.
10. A computer program product, characterized in that The method comprises a computer program, which is used to implement the method according to any one of claims 1 to 6 when the computer program is executed by a processor.