PostgreSQL driver

I’m in the process to move over to PostgreSQL in my applications, and I’m planning to let the website access data stored in the database, so it’d be awesome if there’d be a PostgreSQL driver in the toolkit

The database classes have been refactored in Kirby 2.3 and it is now possible to extend the Sql class with code for other database drivers. You can now extend Kirby’s database support from a plugin.

You would need the following:

  • A database driver for PostgreSQL

    database::$connectors['pgsql'] = function($params) {...};
    
  • A PostgreSQL-specific implementation of the SQL methods. You can find the existing ones for MySQL and SQLite in the Sql class file

    sql::registerMethod('createTable', function($sql, $params...) {}, 'pgsql');
    

It would be great if someone created this as a plugin and we might merge that into Kirby at some point if desired. :slight_smile:

I think you have done a great job and also had in mind to connect to other databases by a plugin. :slight_smile:

I would personally not use a PostgreSQL plugin, but I still think it would be nice if it existed. :slight_smile:

However I really hope that such a plugin is not merged into the Toolkit. I personally don’t want the Toolkit to include every kind of database in the world.

If there is still thoughts about a more official way to have PostgreSQL in the Toolkit, maybe add official plugins for the most common databases? Then it would be more of a plug and play and connect the databas type you want. :slight_smile:

The logic behind my idea is this:

  • Don’t add too much connections to external stuff.
  • Don’t add too much stuff that are not used by very many people.

But whatever you do, it’s probably for the best. :slight_smile:

Yes, that’s what I think as well and is why I proposed to create a plugin in the first place. If it turns out that many users use that plugin, we could at some point merge it, but for now it should be separate.

Creating an official plugin is not really an option at this point, because no one in the team regularly uses PostgreSQL, so we wouldn’t really be able to maintain it.

2 Likes

Yes, that’s what I think as well and is why I proposed to create a plugin in the first place.

Agree! :slight_smile:

If it turns out that many users use that plugin, we could at some point merge it, […] no one in the team regularly uses PostgreSQL, so we wouldn’t really be able to maintain it.

Maybe be very careful with a possible merge then? :confused:

But we are probably talking about things far far away now. We have not even seen a plugin yet. Anyone up to make PostgreSQL plugin?:slight_smile: I’m 100% sure that I will not publish such a plugin. My quota is full. :wink:

I totally agree with both of you. I see no sense in including it in the toolkit.
But a plugin would be nice if not made by the Kirby team; someone might make it and the Kirby team lists it as an “officially” supported plugin

2 Likes

My PostgreSQL is not up to par with the level I’d think would be necessary to make a “good” plugin, but I’m not excluding the idea that I at one point will take on the task :hourglass_flowing_sand:

Before including it in the Toolkit, we will of course test it and work with it for a while. We won’t merge something that we can’t maintain and don’t understand. :slight_smile:

1 Like

We won’t merge something that we can’t maintain and don’t understand.

That sounds great! :smiley: