A method, system, electronic device and medium for managing sub-libraries and sub-tables
By analyzing the permission verification of SQL statements and scanning the DingTalk to log in, the problems of lack of strict permission control and low security in the management of sub-databases and sub-tables of large companies have been solved, table-level permission management and database query security are realized, account password leakage is prevented, and audit and automatic recycling of permissions are supported.
Patent Information
- Application Number
- CN202410146902.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-01
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2044-02-01
AI Technical Summary
In the management of sub-databases and tables of large companies, there are problems such as data updates and querying, complex permission management, inability to audit operations, leaks of account and passwords, and the lack of strict permission control, especially after the number of databases reaches the level of 1,000.
Permission verification is performed by parsing SQL statements, and execution statements are generated through statement templates and permission verification, and their legality is verified before user input, the database address and account password are blocked, and DingTalk scan code login is integrated to ensure security.
It realizes strict permission control to the table level, improves database query security, prevents account password leakage, supports auditing and automatic recycling of permissions of resigned employees, and enhances the security and management efficiency of the system.
Smart Images

Figure CN118012869B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of database management, and in particular to a method, system, electronic equipment and medium for managing sub-libraries and sub-tables. Background Art
[0002] As the scale of a company's business grows, sharding has become a necessity for large companies. However, querying and maintaining sharded databases and tables is also difficult. When the number of databases reaches over 1,000, the following problems will arise:
[0003] (1) It is extremely difficult to update and query data in large quantities of homogeneous tables;
[0004] () Based on business needs, each business department needs to develop online read-only permissions or read-write permissions to troubleshoot and solve problems, which makes permission management difficult;
[0005] (3) Online inquiries and operations cannot be audited or traced;
[0006] (4) The operator may enter high-risk statements (such as drop table statements and updates without where conditions);
[0007] (5) The online database address and read-only account password need to be sent to the developer in plain text, which makes it impossible to centrally manage and control the account password and online database address. This makes it easy for the account password and online database address to be leaked.
[0008] (6) Employee resignation may lead to account password leakage;
[0009] (7) Only allow users to enter specific statements, for example: only allow SELECT commands, not ANALYZE commands. Summary of the Invention
[0010] Based on this, the purpose of the present invention is to provide a method, system, electronic equipment and medium for managing sub-libraries and sub-tables.
[0011] To achieve the above object, the present invention provides the following solutions:
[0012] A method for managing sharded libraries and tables, comprising:
[0013] Determine the sub-database to be changed based on the parameters that need to be changed in the database;
[0014] When the background verification finds that the user has access rights to the sub-database, the user enters a statement; the statement entered by the user includes a query statement, a delete statement, and an update statement;
[0015] When the background verifies that the user has the query authority for the sub-database, the statement input by the user is parsed;
[0016] After the table, database, and statement template corresponding to the parsed statement are verified for permissions, an execution statement is generated based on the parsed statement;
[0017] The parameters that need to be changed in the sub-database are changed according to the execution statement.
[0018] Optionally, the user's access rights and query rights are verified by parsing a statement template for access rights and a statement template for query rights in an SQL statement.
[0019] Optionally, after the table, database, and statement template corresponding to the parsed statement are verified for permissions, an execution statement is generated based on the parsed statement, specifically including:
[0020] Determine whether the commands involved in the parsed statement contain dangerous instructions;
[0021] If so, an error message is returned;
[0022] If not, verify that the user has the table access permission;
[0023] If not, an error message is returned;
[0024] If so, after the permissions of the table, database, and statement template corresponding to the parsed statement are checked, an execution statement is generated based on the parsed statement.
[0025] The present invention also provides a sub-library and sub-table management system, comprising:
[0026] A sub-database determination module is used to determine the sub-database to be changed according to the parameters that need to be changed in the database;
[0027] The statement input module is used to allow the user to input statements when the background verification shows that the user has the access rights to the sub-database; the statements input by the user include query statements, delete statements and update statements
[0028] A parsing module, configured to parse the statement input by the user when the background verifies that the user has query authority for the sub-database;
[0029] The execution statement generation module is used to generate an execution statement based on the parsed statement after the table, library, and statement template corresponding to the parsed statement have been verified for permissions;
[0030] The changing module is used to change the parameters that need to be changed in the sub-database according to the execution statement.
[0031] The present invention also provides an electronic device, comprising a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the above-mentioned sub-library and sub-table management method.
[0032] The present invention also provides a computer-readable storage medium storing a computer program, which implements the above-mentioned method for managing sharded libraries and tables when executed by a processor.
[0033] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0034] (1) The present invention uses the method of parsing SQL statements to perform permission verification to determine whether the defined statement template and permissions are met. If the verification fails, the execution will be terminated.
[0035] (2) Permission control can be performed at the table level. For the core library, some tables require separate permission control. In this invention, the core library tables that need to be controlled can be mapped separately to user settings.
[0036] (3) In the process of querying the database, the system of the present invention shields the actual database address, account number and password, thereby greatly improving the security of the program. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0038] Figure 1 Flowchart of the sub-library and sub-table management provided by the present invention;
[0039] Figure 2 Asynchronous execution flowchart. DETAILED DESCRIPTION
[0040] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0041] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0042] Example 1
[0043] like Figure 1 As shown, the method for managing sharded libraries and tables provided by the present invention includes the following steps:
[0044] S1: Determine the sub-database to be changed based on the parameters that need to be changed in the database.
[0045] S2: When the background verification finds that the user has access rights to the sub-database, the user enters statements, including query statements, delete statements, and update statements.
[0046] S3: When the background verifies that the user has the query authority for the sub-database, the statement input by the user is parsed.
[0047] S4: After the permissions of the tables, libraries, and statement templates corresponding to the parsed statements are verified, an execution statement is generated based on the parsed statements.
[0048] S5: Modify the parameters that need to be changed in the sub-database according to the execution statement.
[0049] In this embodiment, the access authority statement template and the query authority statement template in the SQL statement are parsed to verify the user's access authority and query authority.
[0050] Database permissions include: read-only permission, read-write permission, and administrator permission.
[0051] (1) Read-only permission: only query permission is granted to the data in the database. The limited statement template is: SELECT, etc.
[0052] (2) Read and write permissions, including read-only permissions and permissions to modify data. The limited statement templates are: UPDATE, DELETE, INSERT, etc.
[0053] (3) Administrator privileges include read and write privileges, as well as the privileges to add, delete, and modify table structures. The limited statement templates are: ALTER, CREATE, etc.
[0054] A statement (SQL statement) is a structured query language specifically for databases. Common examples are as follows:
[0055] (1) Query: SELECT * FROM dbo.order_1 WHERE co_id = 1;
[0056] (2) Update: UPDATE dbo.order_1 SET id=2 WHERE id=2;
[0057] (3) Delete: DELETE FROM dbo.order_1 WHERE id = 2;
[0058] (4) High-risk commands:
[0059] 1) Delete (high risk): TRUNCATE TABLE dbo.order_1;
[0060] 2) Deleting a table (high risk): DROP TABLE dbo.order_1;
[0061] 3) Update (high risk, unconditional): UPDATE dbo.order_1 SET id=2;
[0062] 4) Delete (high risk, unconditional): DELETE FROM dbo.order_1.
[0063] Statement templates analyze and classify statements entered by users. For example, SELECT * FROM dbo.order_1 WHERE co_id = 1 is classified as a SELECT template. To facilitate permission verification, this embodiment presets the following default templates:
[0064] (1) Define statement templates allowed by read-only permissions: SELECT, etc.
[0065] (2) Define statement templates that are allowed by read and write permissions: UPDATE, DELETE, INSERT, etc.;
[0066] (3) Define statement templates allowed by administrator privileges: ALTER, CREATE, etc.;
[0067] (4) Define dangerous statement templates: DROP TABLE, TRUNCATE TABLE, unconditional update, etc.
[0068] The present invention performs query and change operations under the database set selected by the user. After the user enters a statement, the statement is verified, parsed, and the placeholders in the statement are processed. After a series of operations, the statement is executed according to the final generated statement, and the execution results are automatically merged and output to the front desk.
[0069] Figure 2 The specific steps are as follows:
[0070] 1: The user selects the scope to be modified on the web (for example, a group of companies, a group of shard tables, or a group of databases), and initializes a channel based on the selected parameters. Built-in variables, such as **co_id**, represent the company ID.
[0071] **seq** represents the subtable number where the company data resides. These variables can be included in statements, and they are replaced with actual values within the context. For example, if a user issues the statement: SELECT * FROM dbo.order_**seq** WHERE co_id = **co_id**, the resulting statement sent to the database might be 99 statements, as shown below:
[0072] SELECT*FROM dbo.order_1 WHERE co_id=1
[0073] SELECT*FROM dbo.order_2 WHERE co_id=2 ...
[0075] SELECT*FROM dbo.order_99 WHERE co_id=99.
[0076] 2: The background verifies whether there is database query module permission, verifies one by one whether the user has access to the database in the channel, and verifies the maximum read and write permissions of the library (read-only, read-write, administrator). After the verification is passed, the created channel number is returned and a new channel query page is opened on the Web.
[0077] 3: In the open web channel, the user enters a statement and clicks "Execute" to submit it to the backend for execution.
[0078] 4: The background checks whether there is database query module permission, checks one by one whether the user has access rights to the database in the channel, and checks the maximum read and write permissions of the library (read-only, read and write, administrator) 。
[0079] 5: Analyze whether the commands involved in the user input statement contain dangerous instructions (drop, truncate). If so, return an error message.
[0080] 6: Analyze whether the table referenced in the statement entered by the user has query permissions. If there is no query permission for the table, an error message is returned.
[0081] 7: Parse the statement based on the channel initialization parameters and placeholders in the statement and replace the actual statement.
[0082] Example: User input:
[0083] ALTERTABLE t ADD id INT
[0084] ALTERTABLE t_**seq**ADD idint
[0085] After this processing, it becomes:
[0086] ALTERTABLE t ADD id INT
[0087] ALTERTABLE t_99 ADD idint
[0088] ALTERTABLE t_98 ADD idint
[0089] ALTERTABLE t_97 ADD idint
[0090] ...t_96–t_3 are omitted here...
[0091] ALTERTABLE t_2 ADD id int
[0092] ALTERTABLE t_1 ADD id int
[0093] ALTERTABLE t_0 ADD id int
[0094] 8: Asynchronously execute the processed statement and immediately return the result to the foreground.
[0095] 9: Pull data incrementally in the front-end.
[0096] 10: The background records the statements executed by the user and the returned results for auditing.
[0097] In the above method:
[0098] User database permission check: Check whether the current user has the access rights to the currently selected database resources, that is, the platform administrator has set query permissions for the user. If yes, it passes, otherwise an error is returned.
[0099] User database data permission check: Check whether the permission applied by the current user is included in the permission configured by the platform administrator. The platform administrator has assigned read and write permissions to database A. If the user applies for read-only or read-write permissions, it will be approved. If the user applies for administrator permissions, an error will be reported directly.
[0100] User database table permission check: Check whether the tables involved in the current user statement are in the queryable tables configured by the platform administrator and are not in the inaccessible tables. If so, the verification passes. Otherwise, an error is reported directly if the verification fails.
[0101] The usage of the management tool that applies the above method is as follows:
[0102] 1: DingTalk QR code scanning management tool web platform website. If you have not registered, you will be automatically registered as a user after logging in. Otherwise, you will be logged in.
[0103] Only employees currently working in the company are allowed to log in. Once an employee leaves, HR will delete that person from the company's DingTalk. Therefore, once an employee leaves, after being removed from DingTalk, the former employee will no longer be able to log in to this platform, achieving the effect of automatic account recovery.
[0104] 2: If you are a platform administrator, you can set the accessible database resources for each employee account.
[0105] 3: On the web page, select the corresponding database using the database instance name and database name.
[0106] The data displayed here is the list of visible databases configured by the platform administrator for the user. When the user chooses which database to connect to, the key information exposed to the user is only the instance name and database name, and does not include the actual address of the database and the account and password. It can be found that when querying the database through this platform, the actual address, account, and password of the database are blocked, thereby avoiding the risk of leakage of core database information.
[0107] 4: After selecting multiple database names in the third step, click Create Channel.
[0108] Creating a channel will verify the currently selected library [User Database Permission Verification] [User Database Data Permission Verification]. After creation, you can find that there are two libraries currently being queried, and the query context contains two companies. The current permissions for operating these libraries are configured by the platform administrator as read-only, read-write, and administrator.
[0109] 5: Execute the statement. Suppose the user enters the statement:
[0110] SELECT TOP 100*FROM dbo.Order_**seq**o INNER JOIN dbo.Order_Item_**seq**oi ON oi.o_id=o.o_id WHERE o.coid=**co_id**.
[0111] The permission verification steps include:
[0112] 1: First, identify **co_id** and **seq**, and replace them according to the actual company number and the corresponding sub-table number of the company, obtaining the following two statement lists:
[0113] SELECT TOP 100*FROM dbo.Order_1 o INNER JOIN dbo.Order_Item_1 oi ONoi.o_id=o.o_id WHERE o.coid=1;
[0114] SELECT TOP 100*FROM dbo.Order_2 o INNER JOIN dbo.Order_Item_2 oi ONoi.o_id=o.o_idWHERE o.coid=2.
[0115] 2. Traverse and parse the above table.
[0116] SELECT TOP 100*FROM aaa.dbo.Order_1 o INNER JOIN dbo.Order_Item_1 oiON oi.o_id=o.o_idWHERE o.coid=1.
[0117] The following information is obtained:
[0118] (1) Operation database: aaa;
[0119] (2) Statement template: SELECT template;
[0120] (3) Operation tables: Order_1, Order_Item_1;
[0121] (4) Condition: WHERE o.coid = 1;
[0122] (5)Company number of the operation: 1.
[0123] 3. Verification.
[0124] (1) Check whether the database aaa currently being operated on has permissions;
[0125] (2) Verify the current permissions (read-only, read-write, administrator) and the corresponding statement template to see if they meet the system's built-in permission corresponding template;
[0126] (3) Verify the table permissions of the table operated in the statement with those configured in the platform;
[0127] (4) If it is an UPDATE or DELETE template, determine whether there is a condition;
[0128] (5) Determine whether Company 1 has the authority to query.
[0129] 4. Secondary verification: including user database permission verification and user database data permission verification.
[0130] 5. Send the two statements generated in the first step to the database for execution, then merge the two results and display them on the front end, and record the executed statements in the log.
[0131] 6. The front-end web pulls data from the back-end interface in real time through incremental pull until all the data is read.
[0132] Account and password issues:
[0133] The system integrates DingTalk scan code login, no account password is required, which is more secure. Only company employees can log in to the management system. After leaving the company, you will not be able to log in to the system immediately
[0134] Database account password issue:
[0135] Each database instance has a unified read-only account, read-write account, and administrator account. Users log in to the system with a DingTalk account and configure the accessible database and read-only, read-write, and administrator account permissions.
[0136] Permission issues:
[0137] Define the statements allowed by read-only permissions: SELECT, etc.
[0138] Define the statements allowed by read and write permissions: UPDATE, DELETE, INSERT, etc.;
[0139] Define statements allowed by administrator privileges: ALTER, CREATE, etc.;
[0140] Define dangerous statements: DROP TABLE, TRUNCATE TABLE, UPDATE without WHERE, etc.
[0141] Define non-executable statements: ANALYZE, etc.
[0142] Permission verification is performed by parsing SQL statements. All statements entered by the user are parsed, and then it is determined whether they meet the statement template and permissions defined above. If the verification fails, the execution will be terminated.
[0143] Permission control can be implemented at the table level. For core libraries, some tables require separate permission control. In this system, the core library tables that need to be controlled can be mapped individually to user settings.
[0144] When using this system to query the database, the system shields the actual database address, account number and password, significantly improving program security. It also integrates DingTalk login, which can quickly and automatically reclaim online database access rights when employees leave.
[0145] Example 2
[0146] In order to execute the method corresponding to the above-mentioned embodiment 1 and achieve the corresponding functions and technical effects, a sub-library and sub-table management system is provided below.
[0147] The system includes:
[0148] The sub-database determination module is used to determine the sub-database to be changed according to the parameters that need to be changed in the database.
[0149] The statement input module is used for the user to input a statement when the background verification finds that the user has the access authority of the sub-database.
[0150] The parsing module is used to parse the statement input by the user when the background verifies that the user has the query authority of the sub-database.
[0151] The execution statement generation module is used to generate an execution statement based on the parsed statement after the table, library and statement template corresponding to the parsed statement are verified for permissions.
[0152] The changing module is used to change the parameters that need to be changed in the sub-database according to the execution statement.
[0153] Example 3
[0154] A third embodiment of the present invention provides an electronic device, including a memory and a processor. The memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the sub-library and sub-table management method provided in the first embodiment.
[0155] In practical applications, the above-mentioned electronic device may be a server.
[0156] In practical applications, an electronic device includes at least one processor, a memory, a bus, and a communications interface.
[0157] Wherein: the processor, the communication interface, and the memory communicate with each other via a communication bus.
[0158] Communication interface, used to communicate with other devices.
[0159] The processor is used to execute the program, and specifically can execute the method described in the above embodiment.
[0160] Specifically, the program may include program codes including computer operation instructions.
[0161] The processor may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the electronic device may be processors of the same type, such as one or more CPUs, or processors of different types, such as one or more CPUs and one or more ASICs.
[0162] The memory is used to store programs. The memory may include high-speed RAM memory and may also include non-volatile memory (non-volatile memory), such as at least one disk storage.
[0163] Example 4
[0164] Based on the description of the third embodiment, the fourth embodiment of the present invention provides a storage medium on which a computer program is stored. The computer program can be executed by a processor to implement the sharding method for managing sharded libraries and tables of the first embodiment.
[0165] The sharding management system provided in the second embodiment of the present invention exists in various forms, including but not limited to:
[0166] (1) Mobile communication devices: These devices are characterized by their mobile communication capabilities and are primarily designed to provide voice and data communications. These terminals include smartphones (e.g., iPhones), multimedia phones, feature phones, and low-end phones.
[0167] (2) Ultra-mobile personal computer devices: These devices fall under the category of personal computers, have computing and processing capabilities, and generally also have mobile Internet access capabilities. These terminals include PDAs, MIDs, and UMPC devices, such as the iPad.
[0168] (3) Portable entertainment devices: These devices can display and play multimedia content. These devices include audio and video players (such as iPods), handheld game consoles, e-books, smart toys, and portable car navigation devices.
[0169] (4) Other electronic devices with data interaction functions.
[0170] Thus far, specific embodiments of the present subject matter have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions recited in the claims can be performed in a different order and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing may be advantageous.
[0171] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0172] For ease of description, the above devices are described in terms of their functions and are divided into various units and described separately. Of course, when implementing the present invention, the functions of each unit can be implemented in the same or multiple software and / or hardware. It should be understood by those skilled in the art that the embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0173] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0174] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0175] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0176] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0177] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0178] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in the present invention, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0179] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0180] The invention may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer.
[0181] Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0182] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.
[0183] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The above examples are only intended to help understand the method and core concept of the present invention. At the same time, those skilled in the art will find that the specific implementation methods and application scopes may vary based on the concept of the present invention. In summary, the contents of this specification should not be construed as limiting the present invention.
Claims
1. A method for managing sharded libraries and tables, characterized in that: include: Determine the sub-database to be changed based on the parameters that need to be changed in the database; When the background verification finds that the user has access rights to the sub-database, the user enters a statement; the statement entered by the user includes a query statement, a delete statement, and an update statement; The user selects the scope to be changed on the Web side, and initializes a channel and built-in variables based on the selected parameters; The backend verifies whether the user has the database query module permission, verifies one by one whether the user has the access permission to the database in the channel, and verifies the maximum read and write permissions of the database. After the verification passes, the created channel number is returned and a new channel query page is opened on the web. In the open web channel, the user enters a statement and clicks "Execute" to submit it to the backend for execution; When the background verifies that the user has the query authority for the sub-database, the statement input by the user is parsed; After the table, database, and statement template corresponding to the parsed statement are verified for permissions, an execution statement is generated based on the parsed statement. The statement is parsed based on the channel initialization parameters and the placeholders in the statement and the actual statement is replaced. Changing the parameters that need to be changed in the sub-database according to the execution statement; Verify the user's access rights and query rights by parsing the access rights statement template and query rights statement template in the SQL statement; To facilitate permission verification, the following default templates are preset: Define the statement template allowed by read-only permission: SELECT; Define statement templates allowed by read and write permissions: UPDATE, DELETE, and INSERT; Define statement templates allowed by administrator privileges: ALTER and CREATE; Define dangerous statement templates: DROP TABLE, TRUNCATE TABLE, and unconditional update; The platform administrator configures a list of visible databases for users. When users choose which database to connect to, the key information exposed to them is only the instance name and database name, and does not include the actual address of the database or the account password.
2. The method for managing sub-libraries and sub-tables according to claim 1, characterized in that: After the table, database, and statement template corresponding to the parsed statement are verified for permissions, an execution statement is generated based on the parsed statement, specifically including: Determine whether the commands involved in the parsed statement contain dangerous instructions; If so, an error message is returned; If not, check whether the user has the table query permission; If not, an error message is returned; If so, after the permissions of the table, database, and statement template corresponding to the parsed statement are checked, an execution statement is generated based on the parsed statement.
3. A sub-library and sub-table management system, characterized in that: include: A sub-database determination module is used to determine the sub-database to be changed according to the parameters that need to be changed in the database; A statement input module is used for the user to input statements when the background verification shows that the user has access rights to the sub-database; the statements input by the user include query statements, delete statements and update statements; The user selects the scope to be changed on the Web side, and initializes a channel and built-in variables based on the selected parameters; The backend verifies whether the user has the database query module permission, verifies one by one whether the user has the access permission to the database in the channel, and verifies the maximum read and write permissions of the database. After the verification passes, the created channel number is returned and a new channel query page is opened on the web. In the open web channel, the user enters a statement and clicks "Execute" to submit it to the backend for execution; A parsing module, configured to parse the statement input by the user when the background verifies that the user has query authority for the sub-database; The execution statement generation module is used to generate execution statements based on the parsed statements after the corresponding tables, libraries, and statement templates are verified for permissions. The module also parses statements based on channel initialization parameters and placeholders in the statements and replaces the actual statements. A change module, configured to change the parameters that need to be changed in the sub-database according to the execution statement; Verify the user's access rights and query rights by parsing the access rights statement template and query rights statement template in the SQL statement; To facilitate permission verification, the following default templates are preset: Define the statement template allowed by read-only permission: SELECT; Define statement templates allowed by read and write permissions: UPDATE, DELETE, and INSERT; Define statement templates allowed by administrator privileges: ALTER and CREATE; Define dangerous statement templates: DROP TABLE, TRUNCATE TABLE, and unconditional update; The platform administrator configures a list of visible databases for users. When users choose which database to connect to, the key information exposed to them is only the instance name and database name, and does not include the actual address of the database or the account password.
4. An electronic device, characterized in that: The electronic device comprises a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the sub-library and sub-table management method according to any one of claims 1 to 2.
5. A computer-readable storage medium, characterized in that It stores a computer program, which, when executed by a processor, implements the method for managing sharded libraries and tables as described in any one of claims 1-2.
Citation Information
Patent Citations
Database access permission control method and device and electronic equipment
CN111756752A
Database access control method and system
CN113239372A
Structured query statement processing method, device and system
CN114969126A
Data authority management method and device, electronic equipment and storage medium
CN116415218A