Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Generic Database Help

by skerr1 (Sexton)
on Mar 18, 2002 at 16:37 UTC ( [id://152510] : perlquestion . print w/replies, xml ) Need Help??

skerr1 has asked for the wisdom of the Perl Monks concerning the following question:


I need to setup a simple and generic database for use with an everyday tool to store and retrieve simple information. I don't need complex or expensive and I don't want to waste a lot of space on this.

Any ideas on a speedy, simple and easily implemented db? Is there anything like this included with perl 5?

Thanks for all help!


Replies are listed 'Best First'.
(jeffa) Re: Generic Database Help
by jeffa (Bishop) on Mar 18, 2002 at 16:45 UTC
Re: Generic Database Help
by broquaint (Abbot) on Mar 18, 2002 at 16:48 UTC
    There isn't a database bundled with perl, but there's a bunch on CPAN that don't require any external software (I assume you don't want to install the likes of MySQL etc). The most commonly recommended modules seem to be DBD::AnyData and DBD::CSV. There's also the likes of DBD::File, DBD::RAM, DBD::Sprite and possibly DBD::SQLite if you've got a C compiler handy.


    Update: there is in fact a database that comes with perl - SDBM_File. /me runs off to get better acquainted with the core modules ...

      It might also be worth adding DBD::XBase in that list too. Not only does it give a pure Perl DBD driver but it also provides an alternative non-DBI interface to xBase format files with one file ...


Re: Generic Database Help
by tachyon (Chancellor) on Mar 18, 2002 at 16:52 UTC
Re: Generic Database Help
by derby (Abbot) on Mar 18, 2002 at 16:56 UTC

    Besides all the excellent DBI and DBD suggestions, if you're needs are really simple, check out the DBM modules.


    update: That is GDBM, NDBM, ODBM or SDBM

Re: Generic Database Help
by gellyfish (Monsignor) on Mar 18, 2002 at 16:55 UTC

    You might want to look at the documentation for AnyDBM_File in the first instance as this will give you an idea of the 'database' facilities that ship with Perl. If your data storage requirements are truly as simple as you suggest then these might be sufficient for you.


Re: Generic Database Help
by JojoLinkyBob (Scribe) on Mar 18, 2002 at 17:51 UTC
    If don't mind your data stored in hashes, look at using the tie command =~Desertcoder
Re: Generic Database Help
by screamingeagle (Curate) on Mar 18, 2002 at 21:44 UTC
Re: Generic Database Help
by webadept (Pilgrim) on Mar 19, 2002 at 00:22 UTC
    If you aren't going to be doing linking and relational stuff you may wish to look at the DBD::CSV module on CPAN.

    The description is as follows:

    DESCRIPTION The DBD::CSV module is yet another driver for the DBI (Database independent interface for Perl). This one is based on the SQL "engine" SQL::Statement and the abstract DBI driver DBD::File and implements access to so-called CSV files (Comma separated values). Such files are mostly used for exporting MS Access and MS Excel data. See the DBI(3) manpage for details on DBI, the SQL::Statement(3) manpage for details on SQL::Statement and the DBD::File(3) manpage for details on the base class DBD::File.

    Anything thing beyond this I would begin looking at MySQL or something of that nature, though the setup of MySQL takes some effort, the rewards are great and spell casting abilities increase dramatically.

    Good luck to you

    Glenn H.