Database connection method, device, storage medium and product based on PaaS
By including preset keywords in the executable code command to obtain the encrypted database connection configuration information, the problem of database connection configuration information is solved, and the requirements of data security and dynamic database management are realized.
Patent Information
- Application Number
- CN202111543933.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-16
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2041-12-16
AI Technical Summary
In the prior art, the database connection configuration information or the service interface of the proxy server is easily exposed, resulting in data security risks and cannot meet the dynamic switching and management of the database by users under different online editing projects.
By including preset keywords that do not have database connection configuration information in the executable code command, we judge and obtain the target database connection configuration information after encryption processing, and use the target online editing project process to decrypt and connect to ensure the database connection configuration The information is not visible to the client and allows the user to dynamically adjust the database.
It effectively improves data security and supports users to dynamically switch and manage databases under different online editing projects.
Smart Images

Figure CN114201479B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of cloud computing technology, and in particular to a database connection method, device, storage medium and product based on PaaS. Background Art
[0002] To facilitate data analysts to quickly develop, iterate, test and verify in the fields of analysis and modeling, online editors have become an indispensable tool in the field of data analysis due to their "what you see is what you get" code development and operation features. At the same time, to meet the needs of more data analysts in a company or organization to develop online at the same time, online editors have gradually evolved from single-point services and multi-point services to cloud-based distributed services based on Platform as a Service (PaaS).
[0003] Data analysis cannot be separated from the support of databases. The traditional way to connect to a database is for users to use an online editor to directly write the IP address, port information, and user information of the database to be connected in the code. Or connect to a proxy server and then connect to the database that is previously connected in the proxy server.
[0004] Therefore, the existing method of connecting to a database will expose the database connection configuration information or the service interface of the proxy server, which will cause hidden dangers to the security of the data. In addition, the method of connecting to the proxy server and then connecting to the database previously connected in the proxy server cannot meet the user's dynamic switching and management of the database under different online editing projects. Summary of the invention
[0005] The embodiments of the present invention provide a database connection method, device, storage medium and product based on PaaS, so as to solve the hidden dangers to data security in the prior art and the technical problems that users cannot dynamically switch and manage the database under different online editing projects.
[0006] In a first aspect, an embodiment of the present invention provides a database connection method based on PaaS, comprising:
[0007] Receiving an executable code command sent by a client, wherein the executable code command is sent after a user enters an executable code in a target online editing project of the client and triggers a running operation on the executable code;
[0008] Determining whether the executable code command includes a first preset keyword; the first preset keyword is represented by first preset characters and / or first preset English and / or first preset numbers without database connection configuration information;
[0009] If it is determined that the first preset keyword is included, determining the target database to be connected according to whether the identification information of the database is included after the first preset keyword, and obtaining the target database connection configuration information, wherein the target database connection configuration information is the configuration information after encryption;
[0010] The target database connection configuration information is decrypted using a process corresponding to the target online editing project, and a connection operation of the target database is performed according to the decrypted target database connection configuration information.
[0011] In a second aspect, an embodiment of the present invention provides an electronic device, including: at least one processor, a memory, and a transceiver;
[0012] The processor, the memory and the transceiver circuit are interconnected;
[0013] The memory stores computer-executable instructions; the transceiver is used to send and receive data;
[0014] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the method according to the first aspect.
[0015] In a third aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method described in the first aspect.
[0016] In a fourth aspect, an embodiment of the present invention provides a computer program product, including a computer program, which implements the method described in the first aspect when executed by a processor.
[0017] The PaaS-based database connection method, device, storage medium and product provided by the embodiment of the present invention receive an executable code command sent by a client, wherein the executable code command is sent after a user enters an executable code in a target online editing project of the client and triggers the execution of the executable code; judge whether the executable code command includes a first preset keyword; the first preset keyword is represented by a first preset character and / or a first preset English and / or a first preset number without database connection configuration information; if it is determined that the first preset keyword is included, the target database to be connected is determined according to whether the database identification information is included after the first preset keyword, and the target database connection configuration information is obtained, wherein the target database connection configuration information is the configuration information after encryption processing; the target database connection configuration information is decrypted by using the process corresponding to the target online editing project and the target database connection operation is performed according to the decrypted target database connection configuration information. When the client initiates a database connection request, it is initiated by including the first preset keyword of the database connection configuration information in the executable code, and when determining the target database, it is determined according to whether the database identification information is included after the first preset keyword. Moreover, the target database connection configuration information obtained is the configuration information after encryption processing, and the target database connection configuration information is decrypted by the target online editing project before the target database connection operation is performed. Therefore, from the initiation of the database connection request to the execution of the target database connection operation, the database connection configuration information is invisible to the client, and even if it is illegally obtained, it is encrypted information. Therefore, the database connection configuration information will not be exposed, effectively improving the security of the data. In addition, the user can configure the identification information of any database by whether to enter the identification information of the database after the first preset keyword, so the target database can be adjusted dynamically, so as to meet the user's needs for dynamic switching and management of databases under different online editing projects. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0019] Figure 1 It is a network architecture diagram that can implement the PaaS-based database connection method of the embodiment of the present invention;
[0020] Figure 2 It is a flowchart of a PaaS-based database connection method provided by an embodiment of the present invention;
[0021] Figure 3is a flow chart of a PaaS-based database connection method provided by another embodiment of the present invention;
[0022] Figure 4 is a flow chart of a PaaS-based database connection method provided by another embodiment of the present invention;
[0023] Figure 5 is a schematic diagram of the structure of an electronic device used to implement the PaaS-based database connection method of an embodiment of the present invention;
[0024] Figure 6 It is a block diagram of an electronic device used to implement the PaaS-based database connection method of an embodiment of the present invention.
[0025] The above drawings show clear embodiments of the present disclosure, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present disclosure to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0026] 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 embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0027] First, the terms involved in the embodiments of the present invention are explained:
[0028] Python: A programming language that is a widely used interpreted, high-level, and general-purpose programming language. Python supports multiple programming paradigms, including functional, imperative, structured, object-oriented, and reflective programming. It has a dynamic type system and garbage collection function, can automatically manage memory usage, and has a huge and extensive standard library. The online editing system in the embodiment of the present invention is developed based on the Python language, and the online editor in the online editing system can support multiple programming languages.
[0029] PaaS: In short, it is a platform for deploying services on the cloud, which provides customers with a complete cloud platform (hardware, software, and infrastructure) for developing, running, and managing applications without having to consider the cost, complexity, and inflexibility that would normally come with building and maintaining the platform locally. The online editing system in the embodiment of the present invention is deployed in PaaS.
[0030] k8s: A management tool for service orchestration for cloud deployment. In the embodiment of the present invention, the online editing system is deployed in paaS using the K8s orchestration management tool.
[0031] Jupyter: An online executable editing service framework with front-end and back-end. In the embodiment of the present invention, the online editing system adopts the Jupyter service architecture. It has a client and a server.
[0032] Kernel: The process of executing the program on the jupyter server. Each executed program corresponds to a kernel process. In this embodiment, the kernel process is the process corresponding to the online editing project of the execution target.
[0033] In order to clearly understand the technical solution of the present application, the solution of the prior art is introduced in detail.
[0034] There are two main methods for connecting to a database. One is to use an online editor to directly write the IP address, port information, and user information of the database to be connected in the code. The other is to create a data connection pool in the proxy server in advance. There are multiple databases in the proxy server. By connecting to the proxy server, you can connect to the database that was previously connected in the proxy server.
[0035] In the first database connection method, the connection configuration information and user information of the database are exposed, which may easily lead to malicious access or attack on the database, or leakage of user information, thus posing a hidden danger to the security of the data.
[0036] In the second database connection method, the service interface for accessing the database is exposed, which is prone to malicious access or attacks on the service interface. It also poses a hidden danger to data security. In addition, the proxy server first connects to the database through the database connection configuration. This method is too rigid and cannot meet the user's dynamic switching and management of the database under different online editing projects.
[0037] Therefore, in the face of the technical problems of the prior art, the inventors found through creative research that in order not to expose the database connection configuration information or the service interface of the proxy server, when a database connection is required, the client cannot display the connection configuration information of the target database to be connected. In order to enable the server to know that the target database connection needs to be made, the client and the server can pre-agree on a first preset keyword that can represent the database connection without the database connection configuration information. The first preset keyword can be represented by a first preset character and / or a first English and / or a first number. The first preset keyword can be carried in an executable code command. The executable code command is sent to the server after the user enters the executable code in the target online editing project and triggers the execution of the executable code. The server determines whether it is an executable code command for the database connection request by determining whether the executable code command includes the first preset keyword. After determining that the first preset keyword is included, in order to meet the user's needs for dynamic switching and management of databases under different online editing projects, the database identification information can be selectively added after the first preset keyword. Then the target database to be connected is determined. After the target database to be connected is determined, the target database connection configuration information is obtained. The target database connection configuration information obtained is encrypted configuration information, and the target database connection configuration information is decrypted by the process corresponding to the target online editing project, and the target database connection operation is performed according to the decrypted target database connection configuration information. When the connection request of the target database is initiated, the server is informed that the database connection needs to be performed by including the first preset keyword in the executable code command. And after determining the target database to be connected according to whether the database identification information is included after the first preset keyword, the connection configuration information of the target database is also encrypted. And when performing the connection operation of the target database, it is also executed after decryption by the process corresponding to the target online editing project of the server. Therefore, from the initiation of the database connection request to the execution of the target database connection operation, the database connection configuration information is invisible to the client, and even if it is illegally obtained, it is encrypted information. Therefore, the database connection configuration information will not be exposed, and the security of the data is effectively improved. And the user can configure the identification information of any database by whether to input the identification information of the database after the first preset keyword, so the target database can be dynamically adjusted, so that the user's needs for dynamic switching and management of databases under different online editing projects can be met.
[0038] Therefore, based on the above creative findings, the inventors have proposed a technical solution of the embodiment of the present invention. The network architecture of the PaaS-based database connection method provided by the embodiment of the present invention is introduced below.
[0039] Figure 1 is a network architecture diagram that can implement the PaaS-based database connection method of the embodiment of the present invention, such as Figure 1 As shown, the network architecture of the database connection method based on PaaS provided in this embodiment includes a client 1 and a server 2 of the online editing system, and multiple databases storing data and a permission database 4 communicating with the server 2. The types of the multiple databases storing data can be different. For example, the type of the database can include mysql, gbase or oracle. Figure 1 In the figure, the multiple databases storing data include three, namely database 31, database 32 and database 33. In one application scenario, a user of client 1 enters executable code in the target online editing project of the client and triggers the running operation of the executable code. The client sends the executable code command to the server. The server determines whether the executable code command includes a first preset keyword. If it is determined that the first preset keyword is included, the target database to be connected is determined based on whether the identification information of the database is included after the first preset keyword. For example, the determined target database is 33. After the server 2 determines that the user has the connection permission to the target database, the encrypted target database connection configuration information is obtained from the permission database 4, and the target database connection configuration information is decrypted using the process corresponding to the target online editing project, and the target database connection operation is performed according to the decrypted target database connection configuration information. Figure 1 As shown, a connection operation of the database 33 is performed.
[0040] 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.
[0041] Embodiment 1
[0042] Figure 2 FIG. 1 is a flow chart of a database connection method based on PaaS provided by an embodiment of the present invention. Figure 2 As shown, the PaaS-based database connection method provided in this embodiment is implemented by a PaaS-based database connection device. The PaaS-based database connection device is located at the server end of the online editing system. The server end may be located in the server. The PaaS-based database connection method provided in this embodiment includes the following steps:
[0043] Step 201, receiving an executable code command sent by a client, wherein the executable code command is sent after a user inputs an executable code in a target online editing project of the client and triggers a running operation on the executable code.
[0044] In this embodiment, the client is a client of the online editing system. The online editing system also includes a server. The online editing system is deployed in paaS using K8s orchestration management tools. It is specifically developed based on the python language.
[0045] In this embodiment, the user creates a target online editing file in the user project management interface of the client as a target online editing project. After the target online editing project is started, the executable code can be entered in the executable input box of the target prior editing project. The running operation of the executable code is triggered by a shortcut key or a running component. After receiving the running operation, the client sends an executable code command to the server. The server receives the executable code command sent by the client.
[0046] The executable code command includes the executable code.
[0047] Among them, the executable input box can also be called an executable line module.
[0048] Step 202: determine whether the executable code command includes a first preset keyword.
[0049] The first preset keyword is represented by first preset characters and / or first preset English and / or first preset numbers without database connection configuration information.
[0050] The first preset keyword is a keyword that the client and the server pre-agreed to represent the database connection without database connection configuration information. The first preset keyword includes any one or more of the first preset characters, the first preset English, and the first preset number. For example, the first preset keyword includes the first preset characters and the first preset English, which may be "%INIT db". Among them, "%" is the first preset character, and "INIT db" is the first preset English.
[0051] It can be understood that the first preset character in the first preset keyword can also be other characters, and the first preset English can also be other preset English, which is not limited in this embodiment.
[0052] Specifically, in this embodiment, the server screens out executable code commands including database connection requests by determining whether the executable code commands include a first preset keyword. Whether the executable code command includes a database connection request is determined by determining whether the executable code command includes a first preset keyword. If it is determined that the first preset keyword is included, it means that the executable code command includes a database connection request, and a subsequent connection to the target database is required. If it is determined that the first preset keyword is not included, it means that the executable code command does not include a database connection request, and the executable code in the executable code command is transmitted to the process corresponding to the target online editing project, and the executable code is run by the process corresponding to the target online editing project.
[0053] Step 203: if it is determined that the first preset keyword is included, the target database to be connected is determined according to whether the database identification information is included after the first preset keyword, and the target database connection configuration information is obtained, where the target database connection configuration information is the encrypted configuration information.
[0054] In this embodiment, if it is determined that the first preset keyword is included, it means that the executable code command includes a database connection request, and the target database to be connected needs to be determined. When determining the target database to be connected, the server and the client can pre-agree whether to include database identification information after the first preset keyword in the executable code command including the first preset keyword to determine the target database to be connected. Specifically, when the database identification information is not entered after the first preset keyword in the executable code command, the server determines which database is the target database to be connected, and when the database identification information is entered after the first preset keyword in the specifiable code command, the server determines which database is the target database to be connected.
[0055] In this embodiment, after determining the target database to be connected, the server obtains the connection configuration information of the target database. The connection configuration information of the target database may include: the IP address and port information of the target database, and may also include other information, which is not limited in this embodiment.
[0056] Furthermore, in this embodiment, in order to effectively protect the connection configuration information of the target database, the acquired connection configuration information of the target database is encrypted configuration information.
[0057] When encrypting the connection configuration information of the target database, the specific encryption algorithm is not limited, such as a symmetric encryption algorithm, an asymmetric encryption algorithm, etc.
[0058] Step 204: Decrypt the target database connection configuration information using the process corresponding to the target online editing project and perform a target database connection operation according to the decrypted target database connection configuration information.
[0059] In this embodiment, after obtaining the connection configuration information of the target database, the target database connection configuration information is first decrypted using the process corresponding to the target online editing project. After obtaining the decrypted connection configuration information of the target database, the target database connection configuration information is used to perform the connection operation between the server and the target database.
[0060] When the target database connection configuration information is decrypted by using the process corresponding to the target online editing project, the target database connection configuration information is decrypted by using a decryption algorithm consistent with the encryption algorithm.
[0061] The PaaS-based database connection method provided in this embodiment receives an executable code command sent by a client, the executable code command is sent after a user enters an executable code in a target online editing project of the client and triggers the execution of the executable code; determines whether the executable code command includes a first preset keyword; the first preset keyword is represented by a first preset character and / or a first preset English and / or a first preset number without database connection configuration information; if it is determined that the first preset keyword is included, the target database to be connected is determined according to whether the database identification information is included after the first preset keyword, and the target database connection configuration information is obtained, and the target database connection configuration information is the configuration information after encryption; the target database connection configuration information is decrypted using the process corresponding to the target online editing project and the target database connection operation is performed according to the decrypted target database connection configuration information. Because when the client initiates a database connection request, it is initiated by including the first preset keyword of the database connection configuration information in the executable code, and when determining the target database, it is determined according to whether the database identification information is included after the first preset keyword. Moreover, the target database connection configuration information obtained is the configuration information after encryption processing, and the target database connection configuration information is decrypted by the target online editing project before the target database connection operation is performed. Therefore, from the initiation of the database connection request to the execution of the target database connection operation, the database connection configuration information is invisible to the client, and even if it is illegally obtained, it is encrypted information. Therefore, the database connection configuration information will not be exposed, effectively improving the security of the data. In addition, the user can configure the identification information of any database by whether to enter the identification information of the database after the first preset keyword, so the target database can be adjusted dynamically, so as to meet the user's needs for dynamic switching and management of databases under different online editing projects.
[0062] As an optional implementation, in this embodiment, determining the target database to be connected according to whether the identification information of the database is included after the first preset keyword in step 203 includes the following steps:
[0063] Step 2031: If it is determined that the first preset keyword does not include identification information of the database, the default database is determined as the target database to be connected.
[0064] Step 2032: If it is determined that the first preset keyword includes identification information of the database, the target database to be connected is determined according to the identification information of the database.
[0065] Specifically, in this embodiment, it is determined whether the first preset keyword includes the identification information of the database. If it is determined that the database identification information is included, it means that the target database that the user needs to connect to is the database corresponding to the database identification information, and the database corresponding to the database identification information is determined as the target database. If it is determined that the database identification information is not included, it means that the target database that the user needs to connect to is a default database that the user often connects to, and the default database is determined as the target database.
[0066] The PaaS-based database connection method provided in this embodiment determines the target database to be connected according to whether the database identification information is included after the first preset keyword. If it is determined that the database identification information is not included after the first preset keyword, the default database is determined as the target database to be connected; if it is determined that the database identification information is included after the first preset keyword, the target database to be connected is determined according to the database identification information. The user can dynamically adjust the target database by whether to input the database identification information after the first preset keyword of the executable code, which can meet the user's needs for dynamic switching and management of databases under different online editing projects. And when the database identification information is not included, the default database is determined as the target database, which can effectively reduce the complexity of the user inputting the executable code when there is less demand for database switching.
[0067] Embodiment 2
[0068] Figure 3 FIG. 1 is a flow chart of a database connection method based on PaaS provided by another embodiment of the present invention. Figure 3 As shown, the database connection method based on PaaS provided in this embodiment, on the basis of the database connection method based on PaaS provided in the above embodiment, also includes other steps, so the database connection method based on PaaS provided in this embodiment also includes the following steps:
[0069] Step 301: receiving a start request for a target online editing project sent by a client.
[0070] In this embodiment, the user creates a target online editing file as a target online editing project in the user project management interface of the client. The user triggers an open operation on the file of the target online editing project. The client sends a start request for the target online editing project to the server. The server receives the start request for the target online editing project sent by the client.
[0071] Step 302: Create a process corresponding to the target online editing project according to the start request.
[0072] In this embodiment, the server specially creates a corresponding process for the target online editing project according to the start request of the target online editing project. The created process corresponding to the target online editing project is used to execute all executable codes in the target online editing project.
[0073] Step 303: Feedback the creation success status to the client.
[0074] In this embodiment, after the server completes the creation of the process corresponding to the target online editing project, it sends a creation success status to the client so that the client can open the target online editing project, and the user can enter the executable code in the executable input box of the target online editing project.
[0075] Step 304: receiving an executable code command sent by the client. The executable code command is sent after the user enters the executable code in the target online editing project of the client and triggers the running operation of the executable code.
[0076] Step 305 , determining whether the executable code command includes the first preset keyword, if so, executing step 306 , otherwise executing step 307 .
[0077] Step 306: Determine the target database to be connected according to whether the first preset keyword includes identification information of the database.
[0078] In this embodiment, the implementation of step 304 to step 306 is similar to the implementation of the corresponding parts of step 201 to step 203 in the first embodiment, and will not be described in detail here.
[0079] Step 307: Use the process corresponding to the target online editing project to execute the executable code in the executable code command.
[0080] In this embodiment, if it is determined that the executable code command does not include the first preset keyword, it means that the executable code command does not include a database connection request, and the executable code in the executable code command is transmitted to the target online editing project and executed.
[0081] It can be understood that, in this embodiment, step 308 is executed after step 306 is executed.
[0082] Step 308: extract user identification information from the cookies corresponding to the user.
[0083] In this embodiment, when a user creates a target online editing project on the client, the client maintains a connection with the server, so the cookies corresponding to the user can be obtained. The cookies include user identification information, and the user identification information is extracted from the cookies.
[0084] The user identification information may be a user ID number, employee number, or other information that represents a unique user.
[0085] Step 309 , judging whether the user has the connection authority to the target database according to the user identification information, if yes, executing step 310 , otherwise executing step 311 .
[0086] As an optional implementation, in this embodiment, step 309 includes the following steps:
[0087] Step 3091, encrypt the user identification information to obtain encrypted user identification information.
[0088] In this embodiment, in order to effectively protect the security of the user identification information, an encryption algorithm is used to encrypt the user identification information, and after the encryption process, the encrypted user identification information is obtained.
[0089] Step 3092, sending a permission verification request to the database permission verification interface, the permission verification request including the encrypted user identification information, so that the database permission verification interface queries whether the connection permissions of the target database stored in the permission database include the encrypted user identification information.
[0090] In this embodiment, the server establishes a connection with the authority database through a database authority verification interface. The authority database stores encrypted user identification information with connection authority for each database, and the authority database stores encrypted connection configuration information corresponding to each database.
[0091] Specifically, in this embodiment, the service end sends a permission verification request to the database permission verification interface. The database permission verification interface parses the permission verification request and obtains the encrypted user identification information and the identification information of the target database. The database permission verification interface uses the encrypted user identification information and the identification information of the target database to query whether the connection permission of the target database stored in the permission database includes the encrypted user identification information. If it is determined that the encrypted user identification information is included, it means that the user has the permission to connect to the target database, and the encrypted target database connection configuration information is obtained from the permission database. And the permission verification result is generated based on the result of connecting to the target database with permission and the encrypted target database connection configuration information. If it is determined that the encrypted user identification information is not included, it means that the user does not have the permission to connect to the target database, and the permission verification result is generated based on the result of connecting to the target database without permission.
[0092] Step 3093, receiving the permission verification result sent by the database permission verification interface.
[0093] In this embodiment, after the database permission verification interface generates a permission verification result, the server receives the permission verification result sent by the database permission verification interface.
[0094] Step 3094, judging whether the user has the connection permission to the target database according to the permission verification result.
[0095] In this embodiment, the server parses the permission verification result. If the permission verification result includes the result of permission to connect to the target database and the encrypted target database connection configuration information, it is determined that the user has the connection permission to the target database. If the permission verification result includes the result of no permission to connect to the target database, it is determined that the user does not have the connection permission to the target database.
[0096] Step 310: Obtain corresponding target database connection configuration information from the authority verification result.
[0097] Step 311: Send no connection permission information to the client.
[0098] In this embodiment, if it is determined that the user has the connection authority to the target database, the encrypted target database connection configuration information is obtained from the authority verification result. If it is determined that the user does not have the connection authority to the target database, no connection authority information is sent to the client, so that the client displays the no connection authority information, and the user can adjust the database identification information in the executable code according to the no connection authority information to connect to the database with connection authority.
[0099] Step 312: Decrypt the target database connection configuration information using the process corresponding to the target online editing project and perform a target database connection operation according to the decrypted target database connection configuration information.
[0100] In this embodiment, the implementation of step 311 is similar to the implementation of step 204 in the first embodiment, and will not be described in detail here.
[0101] The database connection method based on PaaS provided in this embodiment extracts user identification information from the cookies corresponding to the user before obtaining the corresponding target database connection configuration information; determines whether the user has the connection permission to the target database based on the user identification information, and obtains the corresponding target database connection configuration information if it is determined that the user has the connection permission to the target database. Since it is determined whether the user has the connection permission to the target database before obtaining the corresponding target database connection configuration information, users who do not have the connection permission cannot connect and obtain data in the target database, thereby further improving the security of the database.
[0102] The database connection method based on PaaS provided in this embodiment, when judging whether the user has the connection authority to the target database according to the user identification information, encrypts the user identification information to obtain the encrypted user identification information; sends a permission verification request to the database permission verification interface, and the permission verification request includes the encrypted user identification information, so that the database permission verification interface queries whether the connection authority of the target database stored in the permission database includes the encrypted user identification information; receives the permission verification result sent by the database permission verification interface; and judges whether the user has the connection authority to the target database according to the permission verification result. By encrypting the user identification information, the security of the user identification information can be effectively guaranteed. And what is stored in the permission database is the encrypted target database connection configuration information and the encrypted user identification information, so even if the data in the permission database is illegally obtained, the information obtained is also the encrypted information. Therefore, the security of the user identification information and the database connection configuration information is effectively guaranteed.
[0103] Embodiment 3
[0104] Figure 4 FIG. 1 is a flow chart of a database connection method based on PaaS provided by another embodiment of the present invention. Figure 4 As shown, the PaaS-based database connection method provided in this embodiment is based on the PaaS-based database connection method provided in any of the above embodiments, and after step 311, further includes the following steps:
[0105] Step 401: Return the connection status to the client user operation interface.
[0106] The connection status is a connection success status or a connection failure status.
[0107] In this embodiment, after the target database connection operation is performed using the process corresponding to the target online editing project, if the target database connection is successful, a connection success status is generated. If the target database connection fails, a connection failure status is generated.
[0108] Step 402: If the connection status is a successful connection status, the executable code command sent by the client is received.
[0109] In this embodiment, if the connection status is a successful connection status, the client displays a prompt message of the successful connection status. After the user views the prompt message of the successful connection status, he continues to enter the executable code in the executable input box, and triggers the running operation of the executable code through a shortcut key or a running component. After receiving the running operation, the client sends an executable code command to the server and marks the executable code as being in the running state. The server receives the executable code command.
[0110] Step 403: parse the executable code command to determine whether the executable code command includes a second preset keyword.
[0111] In this embodiment, the second preset keyword is a keyword that can be pre-agreed by the client and the server to represent the database query but does not have the database query configuration information. The second preset keyword is represented by a second preset character and / or a second preset English and / or a second preset number without the database query configuration information.
[0112] Among them, the database query configuration information includes the IP address and port information of the database. Therefore, the IP address and port information of the target database are not included in the second preset keyword.
[0113] If the second preset keyword includes a second preset character, the second preset character may be the same as the first preset character in order to uniformly manage the database-related keywords in the executable code. In order to distinguish the preset keyword for database connection from the preset keyword for database query, the second preset English in the second preset keyword may be different from the first preset English and / or the second preset number may be different from the first preset number.
[0114] Exemplarily, the second preset keyword may be “%SQL”, where “%” is the first preset character and “SQL” is the second preset English character.
[0115] Specifically, in this embodiment, the server screens out executable code commands including database query requests by determining whether the executable code commands include a second preset keyword. Whether the executable code commands include a database query request is determined by determining whether the executable code commands include a second preset keyword. If it is determined that the second preset keyword is included, it means that the executable code command includes a database connection request, and a subsequent connection to the target database is required. If it is determined that the second preset keyword is not included, it means that the executable code command does not include a database query request, and the executable code in the executable code command is transmitted to the process corresponding to the target online editing project, and the executable code is run by the process corresponding to the target online editing project.
[0116] Step 404: if it is determined that the second preset keyword is included, then the SQL statement in the executable code command is obtained, and the SQL statement is transmitted to the process corresponding to the target online editing project, and the process corresponding to the target online editing project is used to execute the SQL statement on the target database.
[0117] In this embodiment, if it is determined that the second preset keyword is included, it means that the executable code command includes a data query request, so the executable code command includes an SQL statement for performing a database query. Therefore, the SQL statement is extracted from the executable code command. The SQL statement is transmitted to the process corresponding to the target online editing project. The process corresponding to the target online editing project queries the target database through the SQL statement and obtains the corresponding execution result.
[0118] Step 405: Process the execution result according to a preset display format.
[0119] In this embodiment, the process corresponding to the target online editing project transmits the execution result to the data decoration module, and the data decoration module processes the execution result according to a preset display format.
[0120] Among them, the preset display format can be pre-configured, such as a bar chart format, a curve chart format, a pie chart format, a table format, etc., which is not limited in this embodiment.
[0121] Step 406: Return the execution result of the SQL statement on the target database to the client, so that the client can display the execution result.
[0122] In this embodiment, the execution result processed in the preset display form is returned to the client. The client displays the execution result in the preset display form to meet the user's need to view the query data.
[0123] It should be noted that, when the client receives the execution result and displays the execution result, the execution state of the executable code including the second preset keyword is updated from the executing state to the idle state.
[0124] The PaaS-based database connection method provided in this embodiment returns the connection status to the client user operation interface; if the connection status is a successful connection status, the executable code command sent by the client is received; the executable code command is parsed to determine whether the executable code command includes a second preset keyword; the second preset keyword is represented by a second preset character and / or a second preset English and / or a second preset number without database query configuration information; if it is determined that the second preset keyword is included, the SQL statement in the executable code command is obtained, and the SQL statement is transmitted to the process corresponding to the target online editing project, and the SQL statement is executed on the target database using the process corresponding to the target online editing project; the execution result of the SQL statement on the target database is returned to the client, so that the client can display the execution result. When querying the data of the target database, the database query can be represented by the second preset keyword in the executable code, but the database query configuration information is not displayed, which effectively ensures the security of the data in the database.
[0125] Embodiment 4
[0126] Figure 5 Schematic diagram of the structure of an electronic device used to implement the database connection method based on PaaS in an embodiment of the present invention, such as Figure 5 As shown, the electronic device 50 provided in this embodiment includes: at least one processor 52, a memory 51 and a transceiver 53.
[0127] The processor 52, the memory 51 and the transceiver 53 are interconnected.
[0128] The memory 51 stores computer-executable instructions. The transceiver 53 is used for transmitting and receiving data.
[0129] At least one processor 52 executes the computer-executable instructions stored in the memory, so that the at least one processor performs the method provided in any one of the first to third embodiments.
[0130] Embodiment 6
[0131] Figure 6 is a block diagram of an electronic device for implementing the database connection method based on PaaS according to an embodiment of the present invention, such as Figure 6 As shown, the electronic device can be a computer, a messaging device, a tablet device, a server, a server cluster, etc.
[0132] The electronic device 600 may include one or more of the following components: a processing component 602 , a memory 604 , a power component 606 , an input / output (I / O) interface 612 , a sensor component 614 , and a communication component 616 .
[0133] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components.
[0134] The memory 604 is configured to store various types of data to support operations on the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, videos, etc. The memory 604 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.
[0135] The power supply component 606 provides power to the various components of the electronic device 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 600.
[0136] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0137] The sensor assembly 614 includes one or more sensors for providing various aspects of status assessment for the electronic device 600. For example, the sensor assembly 614 can detect the open / closed state of the electronic device 600, the relative positioning of components, such as the display and keypad of the electronic device 600, and the sensor assembly 614 can also detect the position change of the electronic device 600 or a component of the electronic device 600, the presence or absence of user contact with the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and the temperature change of the electronic device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 614 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0138] The communication component 616 is configured to facilitate wired or wireless communication between the electronic device 600 and other devices. The electronic device 600 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0139] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0140] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the above instructions can be executed by the processor 620 of the electronic device 600 to complete the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0141] A non-temporary computer-readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the method provided by any one of the above-mentioned embodiments 1 to 3.
[0142] In an exemplary embodiment, a computer program product is also provided, including a computer program, where a processor executes the method provided by any one of the above-mentioned embodiments 1 to 3.
[0143] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be regarded as exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0144] It should be understood that the present disclosure is not limited to the exact 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 disclosure is limited only by the appended claims.
Claims
1. A database connection method based on PaaS, characterized in that: include: Receiving an executable code command sent by a client, wherein the executable code command is sent after a user enters an executable code in a target online editing project of the client and triggers a running operation on the executable code; Determining whether the executable code command includes a first preset keyword; the first preset keyword is represented by a first preset character and / or a first preset English and / or a first preset number without database connection configuration information; If it is determined that the first preset keyword is included, determining the target database to be connected according to whether the identification information of the database is included after the first preset keyword, and obtaining the target database connection configuration information, wherein the target database connection configuration information is the configuration information after encryption; The target database connection configuration information is decrypted using a process corresponding to the target online editing project, and a connection operation of the target database is performed according to the decrypted target database connection configuration information.
2. The method according to claim 1, characterized in that The step of determining the target database to be connected according to whether the first preset keyword includes identification information of the database comprises: If it is determined that the first preset keyword does not include the identification information of the database, the default database is determined as the target database to be connected; If it is determined that the first preset keyword includes identification information of the database, the target database to be connected is determined according to the identification information of the database.
3. The method according to claim 1, characterized in that Before obtaining the corresponding target database connection configuration information, the method further includes: Extract user identification information from the user's corresponding cookies; Determining whether the user has connection authority to the target database according to the user identification information; The obtaining of the corresponding target database connection configuration information includes: If it is determined that the user has the connection permission to the target database, the corresponding target database connection configuration information is obtained.
4. The method according to claim 3, characterized in that The determining, based on the user identification information, whether the user has connection authority to the target database comprises: Encrypting the user identification information to obtain encrypted user identification information; Sending a permission verification request to the database permission verification interface, wherein the permission verification request includes the encrypted user identification information, so that the database permission verification interface queries whether the connection permission of the target database stored in the permission database includes the encrypted user identification information; Receive the permission verification result sent by the database permission verification interface; It is determined whether the user has the connection permission to the target database according to the permission verification result.
5. The method according to claim 3 or 4, characterized in that: The obtaining of the corresponding target database connection configuration information includes: If it is determined that the user has the connection authority to the target database, the corresponding target database connection configuration information is obtained from the authority verification result.
6. The method according to any one of claims 1 to 4, characterized in that: After executing the target database connection operation according to the decrypted target database connection configuration information, the method further includes: Return the connection status to the client user interface; If the connection status is a successful connection status, the executable code command sent by the client is received; Parsing the executable code command to determine whether the executable code command includes a second preset keyword; the second preset keyword is represented by a second preset character and / or a second preset English and / or a second preset number without database query configuration information; If it is determined that the second preset keyword is included, obtaining the SQL statement in the executable code command, and transmitting the SQL statement to the process corresponding to the target online editing project, and using the process corresponding to the target online editing project to execute the SQL statement on the target database; The execution result of the SQL statement executed on the target database is returned to the client, so that the client can display the execution result.
7. The method according to claim 6, characterized in that Before returning the execution result of the SQL statement executed on the target database to the client, the method further includes: Processing the execution result according to a preset display format; The step of returning the result of executing the SQL statement on the target database to the client includes: The execution result after processing in the preset display format is returned to the client.
8. The method according to any one of claims 1 to 4, characterized in that: Before receiving the executable code command sent by the client, the method further includes: Receiving a request for starting the target online editing project sent by a client; Creating a process corresponding to the target online editing project according to the start request; Feedback the creation success status to the client.
9. An electronic device, characterized in that: include: at least one processor, memory and transceiver; The processor, the memory and the transceiver circuit are interconnected; The memory stores computer-executable instructions; The transceiver is used for sending and receiving data; The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the method according to any one of claims 1 to 8.
10. 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 8 when executed by a processor.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Database connection method and device based on encryption algorithm and computer equipment
CN112434094A
Database connection configuration information management method, system and device and storage medium
CN112860705A
Proxy-Based Database Encryption
US20180248848A1
