Skip to content
Testsigma DOCS

Add-ons

Connect MongoDB & PostgreSQL Databases


Connecting MongoDB and PostgreSQL databases to Testsigma enhances your testing capabilities by allowing seamless interaction with these databases directly within your test cases. This integration enables you to execute queries, retrieve data, and validate results efficiently, thereby improving test accuracy and coverage while reducing manual effort in managing database interactions.


Prerequisites

Before you begin, ensure that you have referred to:


To set up a database connection to MongoDB in Testsigma, follow these steps:

  1. From the left navigation bar, go to Addons and click Add-ons. Addons
  2. Under the New & Updated Addons section, search for the MongoDB_NLPs addon and click Install. install mongodb addon
  3. Once you install the MongoDB_NLPs addon, you can find the predefined NLPs in Test Steps. use mongodb nlp
  4. The parameters available with NLPs and how to use them in Test Steps are shown below.
ParameterDescriptionExample Value
DBnameCollections are stored in a MongoDB databasee-commerce, blog, social-media
CollectionNameA group of MongoDB documentsusers, products, orders
MongoDB_ConnectionMongoDB connection connects to a MongoDB server or clusterMongoClient, Mongoose
MongoDB_ConnectionURLA URL-like string used to specify the address of a MongoDB server or cluster, as well as options for the connectionmongodb://localhost:27017/blog

To set up a database connection to PostgreSQL in Testsigma, follow these steps:

  1. From the left navigation bar, go to Addons and click Add-ons. Addons
  2. Under the New & Updated Addons section, search for the PostgreSQL_Queries addon and click Install. install postgresql addon
  3. Once you install the PostgreSQL_Queries addon, you can find the predefined NLPs in Test Steps. use postgresql in test steps
  4. The parameters available with NLPs and how to use them in Test Steps are shown below.
ParameterDescriptionExample Value
QueryExecutes a query on a PostgreSQL databaseSELECT * FROM table_name;
Row_CountReturns the number of rows in a result setSELECT COUNT(*) FROM table_name;
DB_ConnectionURLCreates a URL string for connecting to a PostgreSQL databasepostgresql://user:password@localhost:5432/database_name
PG_DBConnectionURLCreates a connection URL for connecting to a PostgreSQL databasepostgresql://username:password@host:port/database_name
Variable-NameAssigns a value to a variablevar_name = “some value”
Select-QueryExecutes a SELECT query and returns the result setSELECT column_name FROM table_name WHERE condition;
Expected-ValueCompares a result with an expected valueassert result == expected_value, f”Expected {expected_value}, but got {result}”