Database Connection
Configuring Database Connection
Open 
Project Settings
->Database Connections
.Click
+ New
at the top right corner to create a database connection.Select the database type from the available options, fill in the necessary connection information such as host, port, database name, user name, and password. It is recommended to use variables to fill in. Database connections filled entirely with variables can be saved in the cloud for collaboration.
📌
In addition to the local connection method using username and password, you can also establish a more secure connection through SSH tunnel to better protect data transmission.
Click
Save
, and this connection can be used in pre/post processors.Using Database Connection
In the
Run
tab (Design Mode) orRequest
tab (Request Mode), navigate to pre/post processors.Hover over 
Add PreProcessor
orAdd PostProcessor
and select Database Operation
.Name the database operation and configure the database connection. Ensure the selected "Database Connection" is correctly set up. Learn More.
Enter the SQL command. Variables such as
{{variables}}
are supported in commands.Enable
Extract Result To Variable
(supports JSONPath) and toggle Console Log
if needed.Click 
Send
to execute the endpoint request, and check the result in the console.Database Operation
in automated tests—either as a test step or in the pre/post-processors of endpoint requests—you can follow the same steps outlined above to set it up and use it.Important Notes
Current Value
field of the related variables. Alternatively, you can use the set variable method to configure these values dynamically.Project Settings
-> Database Connection
.Storage Mechanism and Data Security
Differences between Storage Mechanisms
Storage Mechanism | Storage Method | Advantages | Disadvantages |
---|---|---|---|
Cloud | Use variables in configuration | 1. Enables more convenient collaboration with team members. 2. When running test scenarios via CI, Runner, etc., you can use variables to set the database connection details instead of maintaining local files. | ⚠️ When plaintext is used in the initial values of variables, data such as database names and passwords will be transmitted in plaintext to Apidog's cloud servers, posing a data security risk (using current values for variables keeps the data stored locally, eliminating this risk). It is recommended to use vault variables to avoid data security risks. |
Local | Use fixed text in configuration | Locally stored with no security risk | 1. Poor collaboration; each team member must configure the database connection individually. 2. When running test scenarios through CI, Runner, or similar tools, you need to maintain a dedicated local file for database connections. |
💡
Modified at 2025-03-20 10:32:39