How to configure SQLite in Kohana 3? How to configure SQLite in Kohana 3? sqlite sqlite

How to configure SQLite in Kohana 3?


You can use PDO through Database module. The proper way of configuring it looks like this:

'exportedDatabase' => array(    'type'       => 'pdo',    'connection' => array(        'dsn'        => 'sqlite:/path/to/file.sqlite',        'persistent' => FALSE,    ),    'table_prefix' => '',    'charset'      => NULL, /* IMPORTANT- charset 'utf8' breaks sqlite(?) */     'caching'      => FALSE,    'profiling'    => TRUE,),

One disadvantage of using PDO in Kohana is that in ORM you have to specify all fields by hand in your model (you should do it anyway for performance reasons) because of how different database systems handle listing of table fields.

There is also real database module created by banditron. You have to remember that's it is NOT a drop-in replacement for Database module and therefore Kohana's ORM will not work with it. Other than that it's pretty neat and has wide support for database systems other than SQLite.


As I found out, Kohana 3.x doesn't actually support SQLite. There's an unsupported module for it and, as far as I can tell, it's not working.

It's easy enough to use PDO though and the syntax is pretty much the same as Kohana's ORM:

$db = new PDO('sqlite:' . $dbFilePath);$query = $db->prepare('CREATE TABLE example (id INTEGER PRIMARY KEY, something TEXT)');$query->execute();$query = $db->prepare("INSERT INTO example (id, something) VALUES (:id, :something)");$query->bindParam(':id', $id);$query->bindParam(':something', $something);$query->execute();


I don't use Kohana, but this should work:

'hostname' => /path/to/your/sql/lite/file.sqlite'database' => '''username' => '''password' => ''