# How to Connect Yurbi to Supabase

Source: https://help.yurbi.com/integration-guide/how-to-connect-yurbi-to-supabase

```plaintext
Version: Yurbi v12
Role: Admin
Permission: Admin access
```

---

## Overview

This guide walks you through connecting Yurbi to a Supabase PostgreSQL database. Supabase is an open-source Firebase alternative that provides a hosted PostgreSQL database. By following these steps, you'll configure the connection in Supabase, create a read-only database user for security, and register the database as an application in Yurbi.

---

## Prerequisites

- An active Supabase project with a PostgreSQL database
- Admin access to your Yurbi instance
- Your Supabase database password (can be reset in Database Settings if unknown)

---

## Part 1: Gather Connection Details from Supabase

### Understanding Connection Options

Supabase offers multiple connection methods. For most Yurbi installations running on IPv4 networks, you'll use the **Session Pooler** connection. Here's a quick comparison:

| Connection Type | Port | IPv4 Support | Best For |
|---|---|---|---|
| Session Pooler | 5432 | ✓ Yes | Persistent connections (recommended for Yurbi) |
| Transaction Pooler | 6543 | ✓ Yes | Serverless/short-lived connections |
| Direct Connection | 5432 | ✗ IPv6 only | IPv6-enabled environments |

### Get Your Connection String

1. Log into your Supabase dashboard and select your project
2. Click the **Connect** button at the top of the page
3. Select **Session Pooler** (recommended for IPv4 environments)
4. You'll see a connection string similar to:

```plaintext
postgresql://postgres.abcdefghijklmnop:[YOUR-PASSWORD]@aws-0-us-east-1.pooler.supabase.com:5432/postgres

```

From this string, note the following components:

| Component | Example Value | Description |
|---|---|---|
| **Hostname** | `aws-0-us-east-1.pooler.supabase.com` | The Supabase pooler server address |
| **Port** | `5432` | Session pooler port (6543 for transaction pooler) |
| **Database User** | `postgres.abcdefghijklmnop` | Your username with project reference |
| **Database Name** | `postgres` | The database name (typically "postgres") |

---

## Part 2: Configure Network Access

Before connecting from Yurbi, ensure your Supabase project allows the connection.

### Option A: Remove Network Restrictions (Simpler)

In your Supabase dashboard, navigate to **Database Settings** and ensure there are no network restrictions blocking your Yurbi server.

### Option B: Add IP Allowlist (More Secure)

For enhanced security, add a network restriction that only allows connections from your Yurbi server's public IP address. This ensures only your Yurbi instance can access the database.

---

## Part 3: Create a Read-Only User (Recommended)

For security best practices, create a dedicated read-only user for Yurbi instead of using your primary database credentials. This limits Yurbi to SELECT operations only, protecting your data from accidental modifications.

Run the following SQL commands in the Supabase SQL Editor (adjust the username and password as needed):

```sql
-- Create a read-only user for Yurbi
CREATE USER yurbi_readonly WITH PASSWORD 'your-secure-password-here';

-- Grant connect to the database
GRANT CONNECT ON DATABASE postgres TO yurbi_readonly;

-- Grant usage on the public schema
GRANT USAGE ON SCHEMA public TO yurbi_readonly;

-- Grant SELECT on all existing tables
GRANT SELECT ON ALL TABLES IN SCHEMA public TO yurbi_readonly;

-- Grant SELECT on all future tables (so you don't have to do this again)
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO yurbi_readonly;

-- Grant SELECT on all existing sequences
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO yurbi_readonly;

```

> **Important:** Replace `your-secure-password-here` with a strong, unique password. Store this password securely—you'll need it when configuring the connection in Yurbi.

---

## Part 4: Register the Application in Yurbi

Now that your Supabase database is configured, register it as an application in Yurbi.

### 1. Navigate to Integrations

Log into Yurbi as an admin and click **Settings** from the sidebar.

**\[Screenshot: Yurbi sidebar with Settings highlighted\]**

### 2. Select the Integrations Tab

Click on the **Integrations** tab to view your active integrations.

**\[Screenshot: Settings page with Integrations tab selected\]**

### 3. Create a New App

Click the **Create App** button.

**\[Screenshot: Create App button in Integrations\]**

### 4. Select Database

From the Create App selection dialog, choose **Database**.

**\[Screenshot: Create App dialog with Database option\]**

### 5. Configure the Database Connection

Fill in the connection details:

| Field | Value |
|---|---|
| **App Database Name** | Enter a user-friendly name (e.g., "Supabase Production" or "Customer Data") |
| **Description** | Brief description of this database connection |
| **Database Platform** | Select **PostgreSQL** |
| **Database Server** | Your Supabase hostname (e.g., `aws-0-us-east-1.pooler.supabase.com`) |
| **Username** | Your read-only username with project reference (e.g., `yurbi_readonly.abcdefghijklmnop`) |
| **Password** | The password for your read-only user |
| **Database** | `postgres` (or the database name from your connection string) |

**\[Screenshot: Database connection form filled out\]**

> **Important:** When using a read-only user with the Session Pooler, you must append the project reference to your username. For example, if your read-only user is `yurbi_readonly` and your project reference is `abcdefghijklmnop`, enter: `yurbi_readonly.abcdefghijklmnop`

### 6. Test the Connection

Click **Test Connection**. You should see a green "Passed" message indicating a successful connection.

**\[Screenshot: Successful connection test message\]**

If the test fails, verify:

- The hostname, port, username, and password are correct
- Network restrictions in Supabase allow your Yurbi server's IP
- The read-only user was created successfully with proper permissions

### 7. Save the Application

Click **Save &amp; Apply** to complete the registration.

**\[Screenshot: Save &amp; Apply button\]**

---

## Additional Settings

Expand the **Additional Settings** accordion to access advanced configuration options:

- **Timeout Settings** — Adjust connection and query timeouts
- **Direct SQL** — Enable the ability to create reports using direct SQL queries
- **Additional Options** — Configure other database-specific settings

For detailed information on these options, refer to [How to Create an Application](https://help.yurbi.com/admin-guides/how-to-create-an-application).

---

## Next Steps

Your Supabase database is now connected to Yurbi. The next step is to configure your app in the **Architect** to define which database tables are available for reporting and how they relate to each other.

---

## Troubleshooting

### Connection Timeout or Refused

- Verify your Yurbi server can reach the Supabase hostname on port 5432
- Check that network restrictions in Supabase allow your server's IP address
- Ensure you're using the Session Pooler connection string for IPv4 environments

### Authentication Failed

- Confirm the username includes the project reference suffix (e.g., `user.projectref`)
- Verify the password is correct
- If using a read-only user, ensure the user was created successfully

### Permission Denied on Tables

- Run the GRANT statements again to ensure SELECT permissions are applied
- Verify the tables exist in the `public` schema
- Check that `ALTER DEFAULT PRIVILEGES` was run for future tables

---
