Skip to content

Database Configuration

Anthony Bible edited this page Aug 25, 2025 · 1 revision

Database Configuration

Keys

  • database.host (string, default localhost)
  • database.port (int, default 5432, must be 1..65535)
  • database.user (string, required)
  • database.password (string, required for most setups)
  • database.name (string, required)
  • database.sslmode (string, default disable; e.g. disable|require)
  • database.max_connections (int, default 25)
  • database.max_idle_connections (int, default 5)

Computed

  • DSN: host=%s port=%d user=%s password=%s dbname=%s sslmode=%s

Environment variables

  • CODECHUNK_DATABASE_HOST
  • CODECHUNK_DATABASE_PORT
  • CODECHUNK_DATABASE_USER
  • CODECHUNK_DATABASE_PASSWORD
  • CODECHUNK_DATABASE_NAME
  • CODECHUNK_DATABASE_SSLMODE
  • CODECHUNK_DATABASE_MAX_CONNECTIONS
  • CODECHUNK_DATABASE_MAX_IDLE_CONNECTIONS

Validation

  • database.user and database.name are required
  • database.port must be 1..65535

Example (YAML)

database:
  host: localhost
  port: 5432
  user: dev
  password: dev
  name: codechunking
  sslmode: disable
  max_connections: 25
  max_idle_connections: 5

Example (ENV)

export CODECHUNK_DATABASE_USER=myuser
export CODECHUNK_DATABASE_PASSWORD=mypass
export CODECHUNK_DATABASE_HOST=localhost
export CODECHUNK_DATABASE_NAME=codechunking

See also

Source files

  • internal/config/config.go (DatabaseConfig, DSN method, validation)
  • cmd/api.go (database pool creation/memoization)

Clone this wiki locally