> ## Documentation Index
> Fetch the complete documentation index at: https://docs.drdroid.io/llms.txt
> Use this file to discover all available pages before exploring further.

# PostgreSQL Database

## Connection:

1. **Prerequisites**: Obtain the database host, port, and credentials (username and password) with read access to the databases you want to query.

2. **Adding the connection**: Go to Integrations > PostgreSQL in the Playbooks dashboard. Enter your database connection details. This includes your host, port, username and password.

3. **Testing the Integration**: Create a playbook that includes a step to run a simple SELECT query against your PostgreSQL database and verify the results are fetched correctly.

## Querying:

After adding postgreSQL as a connection, you can do the following:

* Run a query on PostgreSQL.

### PostgreSQL limited access

To restrict permissions to the users accessing PostgreSQL instance via Playbooks, we recommend creating a custom role with the minimal permissions to get the relevant data. Here are 3 queries that you can run in your pgSQL query console to create a new account:

#### Create a new user:

<CodeGroup>
  ```bash bash theme={null}
  CREATE USER demo_video WITH PASSWORD '%3v8923nv3yn5I';
  ```
</CodeGroup>

#### Give required permissions to the user:

<CodeGroup>
  ```bash bash theme={null}
  GRANT SELECT ON table_name TO demo_video;
  ```
</CodeGroup>

#### Verify permissions granted:

<CodeGroup>
  ```bash bash theme={null}
  SELECT *
    FROM information_schema.role_table_grants 
   WHERE grantee = 'demo_video';
  ```
</CodeGroup>
