Storage
required
The storage option is used to configure how and where data is stored.
LightHouse uses SQL databases for data storage. SQLite, MySQL, and PostgreSQL are supported.
driver¶
enum
sqlite
required
LH_STORAGE_DRIVER
The driver option specifies which database driver to use.
Supported values:
sqlite- SQLite database (default, file-based)mysql- MySQL databasepostgres- PostgreSQL database
config.yaml (SQLite)
storage:
driver: sqlite
data_dir: /path/to/data
config.yaml (MySQL)
storage:
driver: mysql
dsn: "user:pass@tcp(127.0.0.1:3306)/lighthouse?charset=utf8mb4&parseTime=True&loc=Local"
config.yaml (PostgreSQL)
storage:
driver: postgres
dsn: "host=localhost user=postgres password=postgres dbname=lighthouse port=5432 sslmode=disable TimeZone=UTC"
data_dir¶
directory path
required for SQLite
LH_STORAGE_DATA_DIR
The data_dir option sets the directory where the SQLite database file (lighthouse.db) will be stored.
This option is only required when using the sqlite driver.
config.yaml
storage:
driver: sqlite
data_dir: /var/lib/lighthouse
dsn¶
string
required for MySQL and PostgreSQL
LH_STORAGE_DSN
The dsn option specifies the Data Source Name (connection string) for the database.
This option is required when using MySQL or PostgreSQL drivers.
MySQL DSN Format¶
user:password@tcp(host:port)/dbname?charset=utf8mb4&parseTime=True&loc=Local
config.yaml
storage:
driver: mysql
dsn: "lighthouse:secret@tcp(127.0.0.1:3306)/lighthouse?charset=utf8mb4&parseTime=True&loc=Local"
PostgreSQL DSN Format¶
host=hostname user=username password=password dbname=database port=5432 sslmode=disable TimeZone=UTC
config.yaml
storage:
driver: postgres
dsn: "host=localhost user=lighthouse password=secret dbname=lighthouse port=5432 sslmode=disable"
DSN Components (Alternative)¶
Instead of providing a full dsn string, you can specify individual connection components:
| Option | Description | Environment Variable |
|---|---|---|
user |
Database username | LH_STORAGE_USER |
password |
Database password | LH_STORAGE_PASSWORD |
host |
Database host (default: localhost) |
LH_STORAGE_HOST |
port |
Database port | LH_STORAGE_PORT |
db |
Database name (default: lighthouse) |
LH_STORAGE_DB |
Sensitive Data
Use LH_STORAGE_PASSWORD environment variable to avoid storing database passwords in config files.
config.yaml
storage:
driver: postgres
user: lighthouse
password: secret
host: db.example.com
port: 5432
db: lighthouse
debug¶
boolean
false
optional
LH_STORAGE_DEBUG
The debug option enables debug logging for database operations. This is useful for troubleshooting database issues.
config.yaml
storage:
driver: sqlite
data_dir: /var/lib/lighthouse
debug: true
Complete Examples¶
SQLite (Recommended for development)
storage:
driver: sqlite
data_dir: /var/lib/lighthouse
PostgreSQL (Recommended for production)
storage:
driver: postgres
dsn: "host=db.example.com user=lighthouse password=secret dbname=lighthouse port=5432 sslmode=require"
MySQL
storage:
driver: mysql
dsn: "lighthouse:secret@tcp(db.example.com:3306)/lighthouse?charset=utf8mb4&parseTime=True&loc=Local&tls=true"
Legacy Backends (Deprecated)¶
Deprecated
The backend option with values json and badger is deprecated and no longer supported.
If you are upgrading from an older version of LightHouse, use the lhmigrate db command to
migrate your data to the new SQL-based storage. See the Migration Guide for details.