How to connect Data base using postman

Hello,

Can some one help how to connect Database using Post man API to compare the DB values. Thanks in advance.

Hi bharath,

This is not possible directly from Postman without the introduction of a REST/GRAPH GL API you can use to check the DB.

So you could use something like Express with NodeJS or depending on where your database is hosted you may be able to use alternative tools. For instance, In the past, I have used Mongo Stitch it basically gives you the ability to create your own API endpoint to check/update/delete the DB via an API call.

Hope this helps.

Just adding to this conversation.

It depends on the database.
Some have their own API’s that allow you to connect and run direct SQL queries.

For example, we are working more and more with Microsoft CosmoDB.

Microsoft has a Postman fork that has the basic elements already included.

It has all of the code for generating the headers and including the db key for authentication. (It took me two minutes to get it up and running from the fork).

List database, Get database, Query collection, and various deletes.

With query collection (which is a post request), I can write any select statement I want to validate the information.

Although there is a basic delete command, deletes can be complicated with relational databases, so going forward, we will be asking the developer to write specific queries for all of the API calls that we want to test, and we will use the same queries in Postman. This means that we should be able to create data, query the data, then clean up after ourselves and delete any test data we create using the same calls that the UI front end developer is going to use rather than create our own select statements.

Obviously helps with you have a closer relationship with your developers.

Our team tried a few solutions for using Postman then checking a database. We wrote a small solution for this that can hit an API, validate the response, then validate against a database (postgreSQL or mySQL). Light-weight and easy to use. Open source, hopefully this is helpful to everyone! Can run locally just using npx.
Take a look here: https://github.com/getjoystick/witcher

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.