You can view and edit your data in Prisma Postgres using either [Prisma Studio](/orm/tools/prisma-studio) or 3rd party database editors.

## Viewing and editing data in Prisma Studio

With Prisma Postgres, a hosted version of [Prisma Studio](/orm/tools/prisma-studio) is available for you in of your project. In your project environment in the [Platform Console](https://console.prisma.io/), select the **Studio** tab in the left-hand navigation to view and edit your data:

![View of Prisma Studio open in the console.](/img/ppg-studio.png)

You can also run Prisma Studio locally by running:

```terminal
npx prisma studio
```

This should start a live server in `http://localhost:5555` where you can visit and interact with your database.

## Connecting to Prisma Postgres instance with 3rd party database editors

You can connect to your Prisma Postgres instance using third party database editors like pgAdmin, TablePlus, Postico etc using [`@prisma/ppg-tunnel` package](https://www.npmjs.com/package/@prisma/ppg-tunnel). See the example below to connect using TablePlus.

### 1. Create a TCP tunnel to access Prisma Postgres directly

If you already have a `.env` file in your current directory with `DATABASE_URL` set, the tunnel CLI will automatically pick it up, no need to manually export it. However, if you haven't set up a `.env` file, you'll need to set the `DATABASE_URL` environment variable explicitly.

In your terminal, to set the environment variable `DATABASE_URL` referring to your Prisma Postgres instance which you want to connect to (be sure to replace the `API_KEY` placeholder with the API key value of your Prisma Postgres instance):

<TabbedContent code>

<TabItem value="macOS">
```terminal
export DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=API_KEY"
```
</TabItem>

<TabItem value="Linux">
```terminal
export DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=API_KEY"
```
</TabItem>

<TabItem value="Windows">

```cmd
set DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=API_KEY"
```
</TabItem>

</TabbedContent>

:::note
If you explicitly set `DATABASE_URL` in your terminal, that value will take precedence over the one in your `.env` file.
:::

Run the following command to connect to your Prisma Postgres instance via `@prisma/ppg-tunnel` package:

<CodeWithResult outputResultText="" expanded={true}>

<cmd>

```terminal
npx @prisma/ppg-tunnel --host 127.0.0.1 --port 52604
```

</cmd>

<cmdResult>

```no-copy wrap
Prisma Postgres auth proxy listening on 127.0.0.1:52604 🚀

Your connection is authenticated using your Prisma Postgres API key.
...

==============================
hostname:  127.0.0.1
port:      52604
username:  <anything>
password:  <none>
==============================
```

</cmdResult>

</CodeWithResult>

Copy the **`port`** from the output above, you will need it in the next step.

Keep this tunnel process running while you are using the database editor to maintain the connection. 

### 2a. Connect to Prisma Postgres using TablePlus

Based on the database editor you are using, you can connect to your Prisma Postgres instance using the details you obtained from the output of the `@prisma/ppg-tunnel` package. To add the connection string in TablePlus:

1. Open TablePlus and click on the **+** icon to add a new connection.
2. Select **PostgreSQL** as the database type.
3. Enter the following details:
    - **Name**: Any name you want to give to your connection.
    - **Host**: `127.0.0.1` in this case. 
    - **Port**: The **`port`** number you obtained from the output of the `@prisma/ppg-tunnel` package.
    - **User**: This will be ignored due to the tunnel, you can provide any value here.
    - **Password**:  This will be ignored due to the tunnel, you can provide any value here.
4. Click on **Connect** to connect to your Prisma Postgres instance.

![View of TablePlus connected to Prisma Postgres via tunnel](/img/ppg-tableplus.png)

### 2b. Connect to Prisma Postgres using DataGrip

Based on the database editor you are using, you can connect to your Prisma Postgres instance using the details you obtained from the output of the `@prisma/ppg-tunnel` package. To add the connection string in DataGrip:

1. Open DataGrip and click on the **+** icon and select "Datasource".
2. Select **PostgreSQL** as the database type.
3. Enter the following details:
    - **Name**: Any name you want to give to your connection.
    - **Host**: `127.0.0.1` in this case. 
    - **Port**: The **`port`** number you obtained from the output of the `@prisma/ppg-tunnel` package.
    - **User**: This will be ignored due to the tunnel, you can keep this field empty.
    - **Password**:  This will be ignored due to the tunnel, you can keep this field empty.
    - **URL**: In the URL append the following query parameter `?sslmode=disable` to the end of the URL.
4. Click on **Test Connection** to ensure that DataGrip can connect to your Prisma Postgres instance. Once successful, click **OK** to save the connection.

![View of DataGrip connected to Prisma Postgres via tunnel](/img/ppg-datagrip.png)

### 2c. Connect to Prisma Postgres using DBeaver

Based on the database editor you are using, you can connect to your Prisma Postgres instance using the details you obtained from the output of the `@prisma/ppg-tunnel` package. To add the connection string in DBeaver:

1. Open DBeaver and click on the **New Database Connection** button or **File** > **New** to add a new connection.
2. Select **PostgreSQL** as the database type.
3. Select **URL** option in Connect by section.
4. Enter the URL in this format:
    - **URL**: Your URL should be in this format: `jdbc:postgresql://localhost:52604/postgres?sslmode=disable`. Here make sure that you enter the port number you obtained from the output of the `@prisma/ppg-tunnel` package. In this case, the port number is `52604`. There is no need to enter Username or Password as authentication is manged by Tunnel. 
5. Click on **Test Connection** to ensure that DBeaver can connect to your Prisma Postgres instance. If successful, click **Finish**.

![View of DBeaver connected to Prisma Postgres via tunnel](/img/ppg-dbeaver.png)

### 2d. Connect to Prisma Postgres using Postico

Based on the database editor you are using, you can connect to your Prisma Postgres instance using the details you obtained from the output of the `@prisma/ppg-tunnel` package. To add the connection string in Postico:

1. Open Postico and click on the **New Server** button to add a new connection.
2. Enter the following details:
    - **Name**: Any name you want to give to your connection.
    - **Host**: `127.0.0.1` in this case. 
    - **Port**: The **`port`** number you obtained from the output of the `@prisma/ppg-tunnel` package.
    - **User**: This will be ignored due to the tunnel, you can keep this field empty.
    - **Password**:  This will be ignored due to the tunnel, you can keep this field empty.
3. Check "Pre-Connect Shell Script" and enter:
    ```sh
    cat <<eof
    {
    "sslmode":"disable",
    }
    eof
    ```
4. Click on **Test Connection** to ensure that Postico can connect to your Prisma Postgres instance. If successful, click **Connect**.

![View of Postico connected to Prisma Postgres via tunnel](/img/ppg-postico.png)

---

# Fly.io