Using SQLite with K3

I’m trying to use a database with Kirby 3, but I’m using Postgre on the server, so for Kirby I’m trying to use SQLite.

The problem is that docs are little light on usage with SQLite - I don’t even know what is the correct type configuration for sqlite :smiley: I hoped reference would help, but there is a missing reference page for Database - even the link in the infobox right above this doc section goes to nonexistent location

We have an example in the Kirby 2 docs. Because we didn’t make any setup or syntax changes from v2 to v3, those options should still work in v3 (although untested):

<?php

return [
  'db' => [
    'type'     => 'sqlite',
    'database' => '/var/data/mydb.sqlite'
  ]
];

Once connected, all the rest should be the same (we handle the differences between the database adapters internally).

1 Like

You’re the bestle

:smile:

Will try it out.

1 Like

You can also connect on the fly without config setting:

$params = [
    'type'     => 'sqlite',
    'database' => $kirby->root('index').'/db_name.db',

];
db::connect($params);
3 Likes