9

Is there any perl modules implementing function of database and easy to use. I do not need modules used to connect to some database products. I need simple database writing by perl.

Thanks.

GMB
  • 216,147
  • 25
  • 84
  • 135
user2799433
  • 171
  • 11
  • 2
    If what you want is to store data in your hdd, you can use `DBM::Deep`, it is easy to manage – Mobrine Hayde Nov 24 '19 at 22:29
  • Does this module support query like SQL? – user2799433 Nov 24 '19 at 22:34
  • 7
    [DBD::SQLite](https://metacpan.org/pod/DBD::SQLite) is a self-contained database management system fully compatible with the standard [DBI](https://metacpan.org/pod/DBI) module. – GMB Nov 24 '19 at 22:34
  • 4
    You might also like [DBD::CSV](http://p3rl.org/DBD::CSV) which provides a standard SQL interface to CSV files. – choroba Nov 24 '19 at 22:36
  • 1
    You can use JSON, XML, YAMS formats to store data. Depending on chosen structure of the database you can implement utility functions. Otherwise you can look at DBM - https://metacpan.org/pod/DBD::DBM. – Polar Bear Nov 25 '19 at 05:39

2 Answers2

18

I would suggest using DBD::SQLite. This is a self-contained database management system with no dependency to external binaries (unlike most others DBI drivers). It has nice options such as creating in-memory databases.

SQLite is an open-source RDBMS that implements a significant subset of the SQL ANSI Standard.

DBD::SQLite is a legitimate DBI driver, so it conforms to the API of the great DBI module, which is the de-facto Perl standard interface for databases.

From the documentation:

DBD::SQLite is a Perl DBI driver for SQLite, that includes the entire thing in the distribution. So in order to get a fast transaction capable RDBMS working for your perl project you simply have to install this module, and nothing else.

GMB
  • 216,147
  • 25
  • 84
  • 135
  • 1
    "_with no dependency to external binaries_" -- well, you need the actual sqlite library itself (C). While that gets installed by the package, the Perl thing (DBD::SQLite) is just a driver. I second the suggestion, but it sure has a "dependency." – zdim Nov 25 '19 at 03:56
  • 7
    @zdim it's not an external binary (it's linked in directly, not "installed" separately, and there's no server), and it's not a "dependency" in the sense of a prerequisite that you need to get beforehand or separately. So I think the answer gives a fair assessment. – hobbs Nov 25 '19 at 06:00
  • 2
    @hobbs Dunno ... it's an independent general C library that the Perl bit interfaces. Even if the package bundles an sqlite version for convenience that is still a separate pop of C code, no-relation-to-Perl. This is mostly semantics, and I support the answer (and upvoted it), but to my mind this is exactly a Perl driver for an external library. – zdim Nov 25 '19 at 08:49
3

If you can live without SQL and relations, give DBM::Deep a try. Easiest of all, I wouldn't use it in production environment for sure, but it is ideal for rapid prototyping.

DESCRIPTION

A unique flat-file database module, written in pure perl. True multi-level hash/array support (unlike MLDBM, which is faked), hybrid OO / tie() interface, cross-platform FTPable files, ACID transactions, and is quite fast. Can handle millions of keys and unlimited levels without significant slow-down. Written from the ground-up in pure perl -- this is NOT a wrapper around a C-based DBM. Out-of-the-box compatibility with Unix, Mac OS X and Windows.

s0me0ne
  • 504
  • 2
  • 9