Skip to content

Database Configuration ​

Corresponds to the database section of the configuration file.

FieldTypeDefaultDescription
driverstring"sqlite3"Database driver; supports sqlite3, mysql and postgres.
data_sourcestringSQLite file DSNData source connection string. Its format depends on the driver; see below.
max_open_connsint4Maximum number of open connections. When <= 0, the driver's default is used.
max_idle_connsint4Maximum number of idle connections. When <= 0, the driver's default is used.
conn_max_life_timeint640Maximum lifetime of a single connection, in seconds. When <= 0, the driver's default is used.
conn_max_idle_timeint640Maximum idle time of a single connection, in seconds. When <= 0, the driver's default is used.

Values used automatically when max_open_conns / max_idle_conns / conn_max_life_time / conn_max_idle_time are set to 0:

drivermax_open_connsmax_idle_connsconn_max_life_timeconn_max_idle_time
sqlite344unlimitedunlimited
mysql101030 minutes5 minutes
postgres101030 minutes5 minutes

SQLite (Default, Zero Dependencies) ​

file:<data directory>/neokikoeru.db?mode=rwc&_busy_timeout=5000&_txlock=immediate&_journal_mode=WAL&_foreign_keys=true

What each parameter means:

  • mode=rwc: create the file if it does not exist
  • _busy_timeout=5000: wait up to 5 seconds for a lock
  • _txlock=immediate: take the write lock when the transaction begins, avoiding deadlocks during lock upgrades
  • _journal_mode=WAL: WAL mode for better read/write concurrency
  • _foreign_keys=true: enforce foreign key constraints

Never put the SQLite database on a network file system (NFS / SMB / Synology WebDAV mounts). WAL relies on reliable shared memory and file locks, and placing it on a network drive can easily corrupt the database. Media files can live on a network drive, but the database must be on a local disk.

MySQL ​

Example:

json
{
  "driver": "mysql",
  "data_source": "user:password@tcp(127.0.0.1:3306)/neokikoeru?charset=utf8mb4&parseTime=true&loc=Local"
}

PostgreSQL ​

Example:

json
{
  "driver": "postgres",
  "data_source": "postgres://postgres:[email protected]:5432/neokikoeru?sslmode=disable"
}

Notes ​

  • When using MySQL or PostgreSQL, the database must be created beforehand. Neokikoeru only creates tables and indexes and migrates the schema automatically; it does not create databases.