Rakudo Perl 6 gets into databases
Database access for Rakudo Perl 6 has improved markedly in the past month. Here are the main points:
The MiniDBI project formerly known as FakeDBI is destined for inclusion in Rakudo * and is now 'usable' and 'useful'. Commit permission to the repo is freely available via hugme in #perl6. Porting simple database client software from Perl 5 to Perl 6 requires only minimal editing.
So, why MiniDBI and not just DBI? Because Perl 6 will have a DBI v2, based on JDBC, read more about that below. The Perl 5 DBI (v1) is very widely used, but enhancing it is far less important than maintaining its stability. Mini means a short term port of a v1 subset, leaving the DBI name free for v2 to use in future.
The mysql DBD has been working for several weeks now, most enjoyably inside http://pivo.jnthn.net (source). Su-Shee++ contributed various fetch* methods and tests in the new database independent test suite.
Several people on #perl6 independently decided to write a Postgresql driver. They chose various implementation methods, and discussed on IRC.
kaare++ blogged about his first perl6 code after a long lurk. Yay! It uses the Pg.pir driver included with Parrot, and confirms that everything works. It is at a similar proof of concept level to this Zavolaj example without requiring Zavolaj.
moritz_++ chimed in with an untested snippet which is based on the same Parrot library. It works similarly, yet is built with DBD style classes.
cxreg++ made a fork of the MiniDBI github repository and added MiniDBD::Pg which uses Zavolaj instead of the Pg.pir from Parrot. It's the most complete Perl 6 Postgresql driver so far.
Each of the above makes a certain kind of progress. What MiniDBD::Pg should ideally get is a combination of elements from them all. Whether to use Zavolaj or the Parrot Pg.pir is still undecided, both approaches have merit. Well done everyone for the work done so far!
DBI v2 is also progressing, timbunce++ appears regularly in #perl6, working on his project. The idea is to automatically translate the Java JDBC API into Perl 6 stub classes and roles. Then Someone(tm) can fill the stubs out with implementation. Fortunately DBI v2 does not overlap or clash with MiniDBI, so all the code might in future merge into a single nice architecture.
Leave a comment