Wednesday, January 21, 2015

NBSQLite3 for Pharo, accessing RDBMS via Glorp and more Pharo persistence options

There is a new way/project to work with the SQLite3 embeddable database. While in the past there was already a SQLite wrapper project for Pharo based on FFI this new one is based on NativeBoost and also has some support for Glorp.

The project is called "NBSQLite3 for Pharo". Read more in my original announcement to get all the details.

Original binding for NativeBoost was written by Pierce Ng. After that I refactored the bits and pieces a little bit, repackages for better loading and added a ConfigurationOfNBSQLite3 to it (one can load the core independent from Glorp support, etc).
Additionally as the old version was hosted on SqueakSource3 it was also moved over to SmalltalkHub: http://smalltalkhub.com/#!/~PharoExtras/NBSQLite3

The STHub project page includes some docu. Meanwhile I also fixed encoding issues between SQLite3 (UTF-8 storage format) and Pharo (Multibyte characters). The nice thing is that with SQLite as small embeddable database you just need a shared library (sqlite3.dll for Windows for example) and you can have a full relational database(s) in single files.

If you are already using Pharo 4 then you can directly install it right from the config browser. Guillermo Polito additionally now created a CI job for it on the DBXTalk CI Server.

You can use the NBSQLite3 package to directly access the relational database and send SQL commands to it. But this is very cumbersome. A better way is to use an object relational mapping framework and Smalltalk has the Glorp ORM framework for that.

If you want to use NBSQLite3 together with Glorp on Pharo4 then you should have a look at this short tutorial I wrote. Also have a look at Svens excellent article on how to use Glorp in Pharo with PostgreSQL and the various descriptions on the Glorp website.

As of today Debris (a company who also joined the Pharo consortium) made a project and code available to use different backends while still working with the Glorp interface. This project is called DebrisDB and is also hosted on SmalltalkHub. If you use it right, you can back your application by Fuel files, SIXX files, any serializer, Gemstone, or Glorp/SQL, without modifying your application code.

For sure database support for Pharo will move on in 2015 and open much more possibilities.

Side note: if you dislike relational databases you can even have a small embeddable NoSQL database with Pharo that also only requires a simple shared library to package with your app. It is called "UnQLite" and I already posted about the PUnQlite binding for Pharo. You can even use Mongo or others with Pharo. If this is an option for you do not forget to have a look at Voyage which makes persistency very easy. There is also SandstoneDB, Magma and SimplePersistence.

And not to forget that there is Gemstone allowing you to work with persistent object as if they were in the Smalltalk image.


No comments: