Blog

SQLite vs PostgreSQL vs MySQL for a self-hosted backend

SQLite vs PostgreSQL vs MySQL for a self-hosted backend? A short guide to which to pick, with the exact limits of each database in Kanesh.

For a self-hosted backend, start with SQLite when everything runs on one machine for a small team, choose PostgreSQL for production, several workspaces or when other services share the data, and use MySQL if you already run it. In Kanesh, SQLite is the default, and PostgreSQL and MySQL are both fully supported.

The three options at a glance

SQLitePostgreSQLMySQL
Kanesh supportDefault, fullFullFull
Runs asA file next to KaneshA separate database serverA separate database server
Extra servicesNoneA PostgreSQL service or managed hostA MySQL service or managed host
Good forOne machine, small teams, demosProduction, many workspacesExisting MySQL servers

When SQLite is the right choice

SQLite needs nothing to configure. Kanesh keeps the database at DATA_DIR/kanesh.db, or at SQLITE_PATH if you set it, so there is no second container and no connection string. Back up the kanesh-data volume and you have backed up the whole install.

docker run -p 127.0.0.1:8080:8080 -v kanesh-data:/data kanesh

Pick it for prototypes, demos, internal tools on a single server, and small projects where one machine is enough.

When PostgreSQL is the right choice

Choose PostgreSQL when the database should live on its own host, when you already back it up and monitor it, when other services or reports read the same tables, or when you host many workspaces. Two variables select it:

docker run -p 127.0.0.1:8080:8080 -v kanesh-data:/data \
  -e DATABASE_DRIVER=postgres \
  -e DATABASE_URL="postgres://kanesh:secret@db.internal:5432/kanesh?sslmode=require" \
  kanesh

When MySQL makes sense

Choose MySQL when your organisation already runs a MySQL server and you want Kanesh to use it. MySQL takes a go-sql-driver DSN, not a mysql:// URL:

docker run -p 127.0.0.1:8080:8080 -v kanesh-data:/data \
  -e DATABASE_DRIVER=mysql \
  -e DATABASE_URL="kanesh:secret@tcp(db.internal:3306)/kanesh" \
  kanesh

A short decision list

  • One machine and a small team? SQLite.
  • Production traffic, several workspaces or a separate database host? PostgreSQL.
  • An existing MySQL server? MySQL.
  • Unsure? Start on SQLite and move later.

What happens when the database is down

If you choose PostgreSQL or MySQL and Kanesh cannot reach it, Kanesh stops with an error. It does not fall back to SQLite, so you never write data to a local file by accident.

Moving later

You can start on SQLite and move to PostgreSQL by exporting and importing records. Kanesh handles CSV and JSON in bounded sizes. Recreate the collections and field types on the new install first, then import, and test with one small collection before you move the rest.

FAQ

Which database should I pick for Kanesh?

Use SQLite for one machine and small teams, and PostgreSQL for production or many workspaces. Use MySQL when you already run a MySQL server.

Is SQLite enough for production?

Kanesh’s database guide lists SQLite for one machine, small teams and demos, and PostgreSQL for production and many workspaces. If your project fits one machine and a small team, SQLite is a supported, full-featured choice. Otherwise use PostgreSQL.

Is MySQL as well supported as PostgreSQL?

The database guide lists both as fully supported. See database setup for the current details and connection formats.

Next steps

Follow Getting started and pick your database with the install flags. For how other backends handle databases, read Kanesh vs PocketBase, which uses embedded SQLite, or Kanesh vs Strapi, which supports SQLite, PostgreSQL, MySQL and MariaDB.

Buy me a coffee