On Fri, Jun 17, 2011 at 18:43, Bruce Van Allen <b...@cruzio.com> wrote:
> Hey John (or anyone else),
>
> On 2011-06-17, John Delacour wrote:
>>
>> I'm afraid I can't advise since I can't stand MySQL and find life much
>> easier with SQLite.
>
> This aroused my curiosity because I have to switch some Perl programs
> written long ago with various flat-file data tables accessed via howe-brew
> parsing to something more transferable. None of my uses has more than a few
> hundred thousand records, and most have far fewer.
>
> Would you care to say a bit more about your preference? Do you use the Perl
> DBI with SQLite? If something that reflects your views can be read
> elsewhere, please point.
>
> CAUTION: I'm not interested in enflaming a huge debate about the merits and
> demerits of these and other database systems, their developers, companies
> that "own" them, etc. Just a bit of practical curiosity...
snip

SQLite is definitely more of a pleasure to work with than MySQL, but
it is not suitable for all applications.  This text from [SQLite's
site][1] sums it up nicely:

    There are advantages and disadvantages to being serverless. The main
    advantage is that there is no separate server process to install,
    setup, configure, initialize, manage, and troubleshoot. This is one
    reason why SQLite is a "zero-configuration" database engine. Programs
    that use SQLite require no administrative support for setting up the
    database engine before they are run. Any program that is able to
    access the disk is able to use an SQLite database.

    On the other hand, a database engine that uses a server can provide
    better protection from bugs in the client application - stray pointers
    in a client cannot corrupt memory on the server. And because a server
    is a single persistent process, it is able to control database access
    with more precision, allowing for finer grain locking and better
    concurrency.

You access SQLite DBs in Perl the same way as MySQL DBs, with a DBD
module using the DBI.  The primary difference is that the entire DB
engine is contained within the DBD::SQLite module.  There is no setup,
you just say

    #!/usr/bin/perl

    use strict;
    use warnings;
    use DBI;

    my $dbh = DBI->connect("dbi:SQLite:dbname=foo.db", "", "");

and if the file foo.db didn't exist already, it is created.  That is
it; you have a database now.

That said, it doesn't provide some things you might expect.  So far as
I know, it provides no security layer.  there is no username or
password to connect, no users own tables (and therefore there are no
privileges to grant).  The database does no type checking.  If you
declare a column as being an integer, there is nothing to stop you
from storing a string in it (this is a simplification of its dynamic
typing, but an integer column can contain "fred").

[1]: http://www.sqlite.org/serverless.html



-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

Reply via email to