SQLite is a SQL powered relational database that is implemented using a file on disk, rather than a client server. This means that, among other things, you don’t need a standalone process to run a database, and it also makes backups easier.

A few weeks ago, support for sqlite landed into Known.

I put together this patch primarily to scratch my own itch; I was having to set up a lot of Known based for testing as part of client projects, and I needed a way to quickly swap around configuration and data sets. I also figured it’d help out the number of folk out there who run their Known sites on devices like the Raspberry Pi.

Usage

Firstly, make sure you’ve got SQLite support built in to php:

Then, you need to modify your config.ini

The first two lines tell Known to use SQLite for the backend database, and where this database lives. Note, that this location needs to be writeable by your web server user (usually www-data) but, for obvious security reasons, should be somewhere outside of your Known docroot, so that it can’t be downloaded!

The last two lines tell Known to use a disk based file store for pictures and other uploads. This is important as the SQLite engine currently doesn’t support file storage in database like the Mongo engine does.

That’s it! Fire up your browser and visit your site. All being well, Known will automatically create the database and set up the schema.

Bug reports and patches to the usual place!

6 thoughts on “Sqlite3 support for Known

  1. The other week, I wrote about introducing SQLite support to Known.
    Seemingly, I was on a role, and because a client asked me to look in to Postgres support for a separate project, I thought I’d have a crack at implementing support for Known, which I’m glad has been merged in.
    This turns out to have been useful to a bunch of folk, for which I am glad.
    Installation
    Postgres support is still in Beta, and MySQL is still the recommended database engine, so currently installation is a bit of a manual process.
    First, you need to make sure you’ve got Postgres support built in to PHP:



    apt-get install php5-pgsql
    php5enmod pgsql


    12

    aptget install php5pgsqlphp5enmod pgsql


    Then, you need to modify your config.ini



    database = ‘Postgres’
    dbname = ‘dbname’
    dbpass = ‘password’
    dbuser = ‘username’
    dbhost = ‘hostname’

    filesystem = ‘local’
    uploadpath = ‘/path/to/upload_directory/


    12345678

    database = ‘Postgres’dbname = ‘dbname’dbpass = ‘password’dbuser = ‘username’dbhost = ‘hostname’ filesystem = ‘local’uploadpath = /path/to/upload_directory/


    Once you’ve done that, you need to install the schema, which currently needs to be done from the command line.



    psql -c ‘create database <dbname>;’ -U <dbuser>
    psql -U <dbuser> -d <dbname> -a -f schemas/postgres/postgres.sql


    12

    psql c ‘create database <dbname>;’ U <dbuser>psql U <dbuser> d <dbname> a f schemas/postgres/postgres.sql


    Assuming you got no errors, you should now be good to go!


    Thanks for visiting! If you’re new here you might like to read a bit about me.
    (Psst… I am also available to hire! Find out more…)


    Follow @mapkyca
    !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?’http’:’https’;if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+’://platform.twitter.com/widgets.js’;fjs.parentNode.insertBefore(js,fjs);}}(document, ‘script’, ‘twitter-wjs’);


    Share this:EmailLinkedInTwitterGoogleFacebookReddit

Leave a Reply