Search code examples
databasedbiparrot

Does Parrot have a database interface or API?


A quick search gave me this announcement of Parrot DBDI from January 2004 and a dbdi-dev mailing list which appears to be long dead. Is Parrot DBDI still being developed? Is anyone working on a different database API or interface for Parrot?


Solution

  • DBDI was an effort to create a database driver interface like the current DBI and DBD modules. It died, so developers are now using an existing interface instead - the Java JDBI. Two such developers are Tim Bunce (who worked on DBI 1, but hasn't had much time to work on its sequel) and Simon Cozens:

    http://perlbuzz.com/2008/12/database-access-in-perl-6-is-coming-along-nicely.html

    use DBDI;
    my $conn = DBDI::DriverManager.getConnection(
        "dbdi:SQLite3:test.db", "", "");
    my $stm = $conn.createStatement();
    my $rs = $stm.executeUpdate("CREATE TABLE foo (bar, baz)");
    my $stm = $conn.prepareStatement(
        "    INSERT INTO foo (bar, baz) VALUES (?, ?)");
    $stm.setColumn(1, 123);
    $stm.setColumn(2, "Thingy");
    $stm.executeUpdate();
    

    This module should be available to all Parrot languages, not just Perl 6.


    Actually for Perl 6 we'll probably see an SQL quote operator so you can do stuff like this:

    $conn.prepareStatement( Q:sql<INSERT INTO foo (bar, baz) VALUES($bar, $baz)> );
    

    And of course in Perl 6 quote modifiers like Q:sql can be abbreviated, e.g. to qs<> or sql<>