By configuring a database connection, you can create database queries in mabl and add them as test steps. This article explains how to…
Connect to a database
Only editors and owners can create and edit database connections. mabl supports connections to the following databases types:
- MySQL
- Microsoft SQL Server
- PostgreSQL
- MariaDB
- MongoDB
- Oracle
Microsoft SQL Server
If your database queries require mabl Link to connect to a Microsoft SQL Server hosted in Azure Cloud, make sure the Azure SQL Server connection is set to proxy.
Before adding a database connection, gather the properties required to connect to your database. Depending on the database type, connection properties may include the IP address of the host or server, port number, database name, username, and password.
In the mabl app, add the database connection:
- Go to Configuration > Database connections.
- Click on + Create database connection.
- Give your database connection a name.
- Select a database type.
- In the Connection properties section, enter the information required to connect to your database.
- Hostname/IP
- Port: mabl automatically populates the default port number for the selected database type, but you can update this value as needed.
- Database name
- Credential: for extra security, we recommend saving the username and password as cloud credentials.
- mabl Link Agent override: optional setting to configure a connection to an internal database
Creating a database connection
Advanced connection properties
For MongoDB databases, you may configure the following optional connection properties:
- Authentication source - specify an alternate authentication database to use when opening the connection.
- Authentication mechanism - specify the authentication mechanism method to use for connection to the server.
-
Use mongodb+srv connection protocol - use
mongodb+src://
instead of the defaultmongodb://
connection protocol - Use direct connection - force dispatch all operations to the host specified in the connection URI
Learn more about MongoDB connection options here.
Add an environment override
If your team manages similar or identically structured databases in different environments, you can configure connection properties for specific environments by adding environment overrides.
When a test containing a database query step is run in an environment that you have added as an override, the step will use the connection properties defined in the associated environment override. When that same step is run in an environment that is not configured as an environment override, it will use the default connection properties.
For example, you could configure your default connection properties to your dev database and add environment overrides for staging and production. If the test runs in your staging or production environment, it uses the connection properties defined in the associated environment overrides. If the test runs in any other environment besides staging or production, it defaults to your dev database.
To add an environment override, take the following steps:
- Select the environment that should use different connection properties.
- Click on + Add environment override.
- Enter the connection properties required to connect to the database in that environment.
- Click on Test connection to check the connection.
Database query steps that run in this environment use these connection properties instead of the default connection properties.
Configuring an environment override
Delete a database connection
Click on the trash icon to remove a database connection.
Use caution when deleting a database connection:
- Queries associated with a deleted database connection will not work.
- If you associate the orphaned queries with a new database connection, make sure the query is still valid for the new database connection.