Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Matts (1087)

  (email not shown publicly)

I work for MessageLabs [] in Toronto, ON, Canada. I write spam filters, MTA software, high performance network software, string matching algorithms, and other cool stuff mostly in Perl and C.

Journal of Matts (1087)

Tuesday February 19, 2002
06:54 AM


[ #2954 ]

Perl has long been without a simple easily installed single-download database system for lightweight applications. Yeah we've got DBD::CSV, but it always struck me as a bit fragile, and doesn't support indexes or transactions. So the other day I came across sqlite, a complete RDBMS in a C library. And it struck me - why don't we just have a DBD driver that you can download, that contains all the code required for the database, including SQL engine and the whole lot, and use sqlite, so I don't have to write the RDBMS layer.

So I copied all the .c files into a new project, hacked together a DBD driver (following the excellent docs in DBI::DBD), and managed to get it working. It's about 20 times faster than DBD::CSV without indexes on tables, so it's probably a fair bit faster with indexes, and of course it supports transactions, which puts it a step ahead (perhaps even favourable over MySQL in some cases). Anyway, you can download it and play here, but there's no docs yet. Just use it as you would any other DBD module, and the connect string specifies the database file (single file):

my $dbh = DBI->connect("dbi:SQLite:/path/to/file","","",
    {AutoCommit => 0, RaiseError => 1}); ...

There's no isql or anything like that - I suggest you use dbish as a database shell. For SQL syntax help see the docs at the link above (one thing to remember is all columns are typeless, which is fine for Perl anyway).

Please let me know if you come across any bugs so I can fix them before sticking it on CPAN.

On another note, I'm listening to Dido quite a bit recently. I think she may be one of the best solo artists to hit the music scene in the UK for quite some time. But then I do like female solo artists who have their roots in more folky stuff (i.e. not Madonna or Britney).

Update: Now at 0.04 due to bugs with placeholders. Link above updated.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I've found that Dido is one of the better "gentle" female artists to play really loud.

    Great DB link, BTW. I'm going to have to play with this.

  • From looking through the docs, it seems like SQLite supports a 'by-default' incrementing field -- if you specify an integer primary key and don't insert a value for the field, the engine will create one for you. (Not sequential, monotonic, etc., but who cares.) Would this be available in the DB handle after the INSERT in something like $dbh->{sqlite_last_insert_rowid}?

  • You should listen to Faithless too then... :-)

    -- ask bjoern hansen [], !try; do();

  • MySQL supports transactions just fine if you use one of the table types for that kind of thing. (ie InnoDB or BDB).

    -- ask bjoern hansen [], !try; do();

    • Yes I know, but it still requires you to have MySQL installed to run it (unless of course you write a DBD that includes the MySQL client libraries).

      Sometimes you just want something simple. And while MySQL is simple, it's not the simplest. At least not any more ;-)

      Oh, and some may prefer the license on this (SQLite is public domain, DBD::SQLite is AL/GPL, MySQL is GPL only).
  • I just downloaded the source for sqlite and I can't find the licensing, except for this bit in main.c:

    ** The author disclaims copyright to this source code. In place of
    ** a legal notice, here is a blessing:
    ** May you do good and not evil.
    ** May you find forgiveness for yourself and forgive others.
    ** May you share freely, never taking more than you give.

    Call me old-fashioned, but I like real licenses like GPL, BSD or the Artistic. I really don't understand one "disclaims copyright" y

    • Well DBD::SQLite is AL/GPL combo (like Perl), and yes, the author means "public domain" that's what disclaiming copyright effectively means.
      • Public domain cannot be public domain without explicitly stating this and he'd better really mean it when he says it as it means he has no rights to it henceforth. CPAN got into a bit of a wicket over this sort of thing so I'm with JJ on this one...tell the guy to get real and either state it is public domain or get a real license. Implied public domain doesn't fly.

        • Public domain cannot be public domain without explicitly stating this

          Disclaiming copyright is explicitly stating that. There's nothing implied about that. I can't say whether or not it meets a certain legal requirement in its form -- and I am not sure if any of us can; if so, I'd like to know the source, because I am interested -- but it is quite explicit.

          • Disclaiming copyright is explicitly stating that.

            Pudge-daddy, there is a language we speak called English and using the rules of that language, your analysis of the denial of copyright seems cogent. However I raised the issue not because the author's intentions were unclear in English, but they are unclear in the strange Bizzaro language of legalese. In legalese, even the meaning of the word "is" can be argued.

            The author is being cute, but I think we'd all be happier with "THIS SOFTWARE IS PUBLIC DOMAIN"

            • I don't care about legalese, no. I am happier with *perhaps* legally vague things that clearly demonstrate intent. If the lawyers don't like it, but everyone knows what it means, that makes me all the happier.
            • OK, enough already. Try this link. [].
          • We went around on this with RMS and are welcome to talk to them about it but outside the US 'public domain' doesn't mean jack needs a license and disclaiming a copyright as stupidly as that guy did isn't enough from what I understand. I don't like such things nor am I a lawyer so take it up with the FSF if you care.

            • That's not the issue I was discussing. I was discussing whether or not "disclaming copyright" is the same as "public domain." Whether or not public domain is good or useful is a separate discussion.
              • Disclaiming copyright is not the same as 'public domain' and since 'public domain' has no meaning outside of the US it is probably not useful.

                • Yes, it is the same. Whether or not it has force of law, whether or not it is useful, is another matter, one that I personally don't care about. For all the time we put into trying to get our licenses to be legal, they never go to court. 'Tis a waste of time, mostly.
                  • Public domain must be explicity stated as 'no copyright' is not synonymous with public domain any more than the omission of copyright or license is. It is a legal term whether it interests you or not.

  • Would you mind if I posted this to the dbi-users mailing list? I think it would be appreciated. :)
  • You are already listening to the likes of Kate Rusby and Eliza Carthy aren't you?