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.
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}?
Re:DB note
Matts on 2002-02-19T13:03:34
It's in the C API, but I haven't written the access to it yet. It'll probably be via $dbh->func().
Re:MySQL & transactions
Matts on 2002-02-19T13:58:59
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).Re:MySQL & transactions
miyagawa on 2002-02-19T22:19:09
MySQL is GPL/FPL, while FPL costs $200 or so.
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" yet puts this mumbo-jumbo in the header of one's source code. If the author means public domain, he should say so.
Re:License?
Matts on 2002-02-19T14:16:58
Well DBD::SQLite is AL/GPL combo (like Perl), and yes, the author means "public domain" that's what disclaiming copyright effectively means.Re:License?
hfb on 2002-02-19T15:44:35
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.
Re:License?
pudge on 2002-02-19T16:13:12
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.
Re:License?
jjohn on 2002-02-19T16:53:13
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" or "I 0W3NZ THE COPYRIGTH" or even "THIS SOFTWARE IS COPYLEFTED." I totally hate licensing issues, so I prefer licenses that I'm already familiar with. Aren't you?
Re:License?
pudge on 2002-02-19T17:06:02
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.Re:License?
Matts on 2002-02-19T17:11:35
OK, enough already. Try this link..Re:License?
hfb on 2002-02-19T17:38:11
We went around on this with RMS and Brad...you are welcome to talk to them about it but outside the US 'public domain' doesn't mean jack shit...it 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.
Re:License?
pudge on 2002-02-19T18:25:42
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.Re:License?
hfb on 2002-02-19T18:32:20
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.
Re:License?
pudge on 2002-02-19T18:45:36
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.Re:License?
hfb on 2002-02-19T18:59:11
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.
Re:dbi users mailing list
Matts on 2002-02-19T14:14:53
I'll post it when I consider it stable enough and upload it to CPAN. Please don't kill my server with dbi-users downloads;-)