# Database Options (/self-host/advanced/postgresql)

> Configure SQLite or PostgreSQL database for Pangolin



## Overview [#overview]

> Choose between SQLite (default) or PostgreSQL for your database

Pangolin supports two database options: SQLite for simplicity and PostgreSQL for production deployments.

<CardGroup cols="2">
  <Card title="SQLite (Default)" icon="database">
    * No configuration required
    * Easy to use and portable
    * Built into the main image
    * Perfect for development
  </Card>

  <Card title="PostgreSQL" icon="postgres">
    * Production-ready database
    * Better performance at scale
    * Requires separate image
    * Advanced configuration options
  </Card>
</CardGroup>

## SQLite [#sqlite]

By default, Pangolin uses SQLite for its ease of use and portability.

**Docker Image**: `fosrl/pangolin:<version>`

<Note>
  No configuration is required to use SQLite with Pangolin.
</Note>

## PostgreSQL [#postgresql]

You can optionally use PostgreSQL for production deployments.

**Docker Image**: `fosrl/pangolin:postgresql-<version>`

### Configuration [#configuration]

Add the following section to your Pangolin configuration file:

```yaml title="config.yml"
postgres:
  connection_string: postgresql://<user>:<password>@<host>:<port>/<database>
```

<Warning>
  Replace the placeholders with your actual PostgreSQL connection details.
</Warning>

### Docker Compose Example [#docker-compose-example]

This example sets up PostgreSQL with health checks to ensure the database is ready before Pangolin starts:

```yaml title="docker-compose.yml"
name: pangolin
services:
  pangolin:
    image: fosrl/pangolin:postgresql-latest
    container_name: pangolin
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    volumes:
      - ./config:/app/config
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3001/api/v1/"]
      interval: "10s"
      timeout: "10s"
      retries: 15

  postgres:
    image: postgres:17
    container_name: postgres
    restart: unless-stopped
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    volumes:
      - ./config/postgres:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 10s
      timeout: 5s
      retries: 5
```

<Warning>
  This example is not necessarily production-ready. Adjust the configuration according to your needs and security requirements.
</Warning>

<Note>
  Do not use `latest` tags in production. Use specific version tags for stability.
</Note>
