# Postman and database

**URL:** <https://community.postman.com/t/postman-and-database/706>\
**Category:** Help Hub\
**Created:** [January 18, 2018, 7:16am UTC](https://community.postman.com/t/postman-and-database/706 "2018-01-18T07:16:54Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichalKotynski](https://avatars.discourse-cdn.com/v4/letter/m/9de0a6/32.png) [@MichalKotynski](https://community.postman.com/u/MichalKotynski)\
**Post date:** [January 18, 2018, 7:16am UTC](https://community.postman.com/t/postman-and-database/706/1 "2018-01-18T07:16:54Z")

</div>

Hello everyone,

I’m trying to do something unusual with testing my REST API. I want to test if the correct data is written to the database on PostgreSQL. For this I need to send Postman request but before that I need to somehow send standard SELECT to my database and put the response in global variable or environmental variable. I was searching in www if anyone has such idea but I didn’t found anything.  
Is this possible to do something like I want by using Pre-scripts in Postman?  
Sorry if this question is trivial but I’m curious if I can do something like that with Postman.

---

<div class="post-metadata">

**Author:** ![shamasis](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/shamasis/32/53_2.png) [@shamasis](https://community.postman.com/u/shamasis)\
**Post date:** [January 23, 2018, 6:49am UTC](https://community.postman.com/t/postman-and-database/706/2 "2018-01-23T06:49:40Z")

</div>

Ok. I can suggest this:

1. Use pREST to open api access to your database
2. Call pREST api from postman script using pm.sendRequest API

- [https://github.com/prest/prest](https://github.com/prest/prest)
- [https://gist.github.com/madebysid/b57985b0649d3407a7aa9de1bd327990](https://gist.github.com/madebysid/b57985b0649d3407a7aa9de1bd327990)

How does that sound? Try it and let me know if you have success!!

---

<div class="post-metadata">

**Author:** ![MichalKotynski](https://avatars.discourse-cdn.com/v4/letter/m/9de0a6/32.png) [@MichalKotynski](https://community.postman.com/u/MichalKotynski)\
**Post date:** [January 23, 2018, 8:12am UTC](https://community.postman.com/t/postman-and-database/706/3 "2018-01-23T08:12:22Z")

</div>

Theoretically it may works. The logic process goes like that:  
I’m checking some values in database by pREST api in pre-scripts, then I’m sending normal request by Postman and in assertions I’m checking again values using pREST.

But using this method I’m using two api’s. For now I’m using only one api because I made a temporary solution where I dont need two api’s. I created solution in my api where I’m sending specific parameters and this api is making request to db and serving values.

It is similar solution like using pREST, but I’m wondering if it is possible to write code in pre-scripts which will independently comunicate with database. Without using external api’s.

---

<div class="post-metadata">

**Author:** ![amruta.kale](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@amruta.kale](https://community.postman.com/u/amruta.kale)\
**Post date:** [January 30, 2018, 1:58am UTC](https://community.postman.com/t/postman-and-database/706/4 "2018-01-30T01:58:37Z")

</div>

I am also looking for this, were you able to get anything on this @MichalKotynski

---

<div class="post-metadata">

**Author:** ![MichalKotynski](https://avatars.discourse-cdn.com/v4/letter/m/9de0a6/32.png) [@MichalKotynski](https://community.postman.com/u/MichalKotynski)\
**Post date:** [February 6, 2018, 8:11am UTC](https://community.postman.com/t/postman-and-database/706/5 "2018-02-06T08:11:21Z")

</div>

I dropped this subject temporarily because I didn’t found way to directly connect Postman to database. For this few testcases where I was forced to check something on database I created method with specific parameters which is triggering pre-writen database queries on the database/API side.  
It is not the best solution but for now it satisfied my needs.

I’ll wait till someone find better way to do this or Postman Team add new features to the Postman.

---

<div class="post-metadata">

**Author:** ![alleshriniwas](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@alleshriniwas](https://community.postman.com/u/alleshriniwas)\
**Post date:** [December 26, 2018, 1:04pm UTC](https://community.postman.com/t/postman-and-database/706/6 "2018-12-26T13:04:25Z")

</div>

Hi @MichalKotynski

I’m looking for the same solution that you asked, have you had any chance to get the solution to connect to the database and verify the response?

Please help!

---

<div class="post-metadata">

**Author:** ![jason.armitage](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@jason.armitage](https://community.postman.com/u/jason.armitage)\
**Post date:** [January 15, 2019, 1:37am UTC](https://community.postman.com/t/postman-and-database/706/7 "2019-01-15T01:37:23Z")

</div>

Looking for this feature too.  
Not quite sure that it is as “unusual” a testing scenario that original poster claims.  
(Call API =\> Check DB is updated correctly)

---

<div class="post-metadata">

**Author:** ![MichalKotynski](https://avatars.discourse-cdn.com/v4/letter/m/9de0a6/32.png) [@MichalKotynski](https://community.postman.com/u/MichalKotynski)\
**Post date:** [January 15, 2019, 11:50am UTC](https://community.postman.com/t/postman-and-database/706/8 "2019-01-15T11:50:03Z")

</div>

For temporary solution that I’m using from time to time.

1. Create on your REST API new special method where you pass table name or watever parameters you need to your query. Your API must do the job and execute prepared queries.

2. create response for API asking database with queries, it must be easy for you to pass it to Postman variables for validation,

3. remember to limit acces to thim method due to potential harm that it may cause on your DB,

4. wait fot Postman to be fitted with DB communication in easy way.

---

<div class="post-metadata">

**Author:** ![matt](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/matt/32/2562_2.png) [@matt](https://community.postman.com/u/matt)\
**Post date:** [January 15, 2019, 11:22pm UTC](https://community.postman.com/t/postman-and-database/706/9 "2019-01-15T23:22:33Z")

</div>

I put together a collection/some documentation at the following link which shows how you can use some popular tooling for MySQL/PostgreSQL to get this going at a basic level:

[https://www.postman.com/postman/workspace/postman-team-collections/collection/5922408-41044117-22a7-4f36-869c-13f73310b7e9?ctx=documentation](https://www.postman.com/postman/workspace/postman-team-collections/collection/5922408-41044117-22a7-4f36-869c-13f73310b7e9?ctx=documentation)

There’s undoubtedly other libraries out there to make a REST API available for other database solutions if you aren’t using either of these two.

---

<div class="post-metadata">

**Author:** ![harishyamgawali](https://avatars.discourse-cdn.com/v4/letter/h/3bc359/32.png) [@harishyamgawali](https://community.postman.com/u/harishyamgawali)\
**Post date:** [May 6, 2019, 12:53pm UTC](https://community.postman.com/t/postman-and-database/706/10 "2019-05-06T12:53:17Z")

</div>

@matt , I am using oracleDB, Do you have any solution???

---

<div class="post-metadata">

**Author:** ![matt](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/matt/32/2562_2.png) [@matt](https://community.postman.com/u/matt)\
**Post date:** [May 6, 2019, 5:40pm UTC](https://community.postman.com/t/postman-and-database/706/11 "2019-05-06T17:40:52Z")

</div>

You could take a look at:  
[https://www.oracle.com/database/technologies/appdev/rest.html](https://www.oracle.com/database/technologies/appdev/rest.html)

---

<div class="post-metadata">

**Author:** ![tester20183450](https://avatars.discourse-cdn.com/v4/letter/t/71c47a/32.png) [@tester20183450](https://community.postman.com/u/tester20183450)\
**Post date:** [May 23, 2019, 7:13am UTC](https://community.postman.com/t/postman-and-database/706/12 "2019-05-23T07:13:31Z")

</div>

My solution is writing restful-api to return the data that I need.

---

<div class="post-metadata">

**Author:** ![esteban92136](https://avatars.discourse-cdn.com/v4/letter/e/7993a0/32.png) [@esteban92136](https://community.postman.com/u/esteban92136)\
**Post date:** [September 28, 2020, 2:50pm UTC](https://community.postman.com/t/postman-and-database/706/13 "2020-09-28T14:50:46Z")

</div>

good morning, I want to connect to a sybase base using postman, to consume your objects, please help me

---

<div class="post-metadata">

**Author:** ![andrei\_m](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@andrei\_m](https://community.postman.com/u/andrei_m)\
**Post date:** [January 18, 2021, 3:34pm UTC](https://community.postman.com/t/postman-and-database/706/14 "2021-01-18T15:34:50Z")

</div>

anything that will allow me to connect to Apache Cassandra, please?
