By configuring a database connection, you can create database queries and add them as steps in your mabl tests. This article explains how to:
Supported database types
mabl supports connections to the following database types:
- MySQL
- Microsoft SQL Server
- PostgreSQL
- MariaDB
- MongoDB
- Oracle
If your team has a use case that requires connecting to a different database type, let us know in the mabl Product Portal.
Connect to a database
Before adding a connection, gather the properties required to connect to your database. Typically, this information takes the form of a connection string, also known as a URI or URL, that contains the connection properties, including the IP address of the host or server, the port number, database name, username, and password.
Only editors and owners can create and edit database connections.
To add a new database connection, go to Configuration > Database connections in the mabl app. Click on + Create database connection to get started.
Sample database connection
Give your database connection a name, and select the database type. In the Connection properties section, enter the information from your database’s connection string in the corresponding field:
-
Hostname/IP: for Microsoft SQL server, this may include an instance name, such as
hostnameSQLEXPRESS - Port: mabl automatically populates the default port number for the selected database type, but you can update this value as needed.
- Database name: this may be referred to as the “Service Name” or “SID” in Oracle, or the “authentication database” in MongoDB
- 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
Private databases
All database queries execute in the mabl cloud, regardless of whether they occur in the Trainer or during local or cloud execution. If your database is not accessible from the public internet, use one of our recommended options for configuring private database access.
Advanced connection properties
MongoDB databases
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 default mongodb:// connection protocol
- Use direct connection - force dispatch all operations to the host specified in the connection URI
Learn more about MongoDB connection options here.
Microsoft SQL Server databases
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.
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, select the environment that should use different connection properties and click on + Add environment override.
Configuring an environment override
Enter the connection properties required for the database. If it is a private database, make sure to use mabl Link or allowlist IPs to ensure mabl can access the database.
Click on Test connection to check the connection.
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.