Re: DBI modules for database representation in plain files
by perrin (Chancellor) on Feb 25, 2004 at 16:39 UTC
|
Did you consider DBD::SQLite? | [reply] |
|
| [reply] |
|
davido,
It is also happens to be a complete RDBMS database engine
That is a bit misleading since some people would argue that the omitted SQL Features make it incomplete. Since I have very limited db experience, I am not going to make that case. I like SQLite very much and have used it on at least 3 projects now. I also here there may be locking issues with too many concurrent updates. I guess someone deciding what to use knows their own requirements well enough to know if SQLite is right for the job.
Cheers - L~R
| [reply] |
|
|
|
|
|
Yes.
I've forgot two say that here i would prefer a PURE PERL that is no external code to compile.
so any DB file type that comes bundled with perl distrib. would be great.
Thanks
Filipe
| [reply] |
|
Well, by limiting yourself in this way you are basically stuck with either MLDBM (using GDBM or DB_File), or one of the text-based things you mentioned. If you really think performance is going to be a big issue, use MLDBM. If you can't live without SQL support and still need performance, you have to bite the bullet and get a real database.
| [reply] |
|
|
What is nice about compiling DBD::SQLite is that all the code is contained in the dist. A lot easier than installing mysql, postgresql, ...etc. I have installed on a variety of *nixes without any problems.
I'm sure you are aware of this, just my 2 cents.
sth
| [reply] |
Re: DBI modules for database representation in plain files
by xdg (Monsignor) on Feb 25, 2004 at 18:13 UTC
|
Check out DBD::SQLite -- it's relational, it uses plain files and it's fast. It's also typeless, so essentially you just have to use Storeable to freeze/thaw your data into a field in the table. Another option might be to try using Class::DBI which gives you a nice relational data abstraction layer with DBD::SQLite as the data storage mechanism.
-xdg
Code posted by xdg on PerlMonks is public domain. It has no warranties, express or implied. Posted code may not have been tested. Use at your own risk.
| [reply] |
Re: DBI modules for database representation in plain files
by jZed (Prior) on Feb 25, 2004 at 19:21 UTC
|
Have you actually tested the penalties in performance? Depending on the size and complexity of your data, they may not be relevant.
I second all the other recommendations of SQLite, it rocks. However it is not pure perl and it does not create cross-platform, human readable data files.
P.S. I will be releasing a pure perl DBD::DBM soon but it is too early to say how it will compare performance-wise with the others. Obviously its files won't be cross-platform or human readable, but it should work anywhere that perl works with SDBM that comes with perl or with other DBMs if they are available.
| [reply] |
|
That's sound wounderfull :=) Would it also interface with DB_files and MLDBM?
i've finally put the DBD::SQlite working.
i've created a few tables, a unique index but i got one concern how can i limit the data to fit in a standard SQl type:like info char(32) i've run a small test and i don't get a data limit.
#!/usr/bin/perl -w
use strict;
use warnings;
use DBI;
use DBD::SQLite;
my $dbh = DBI->connect("dbi:SQLite:dbname=foo", "", "", {AutoCommit =>
+ 1, RaiseError => 1});
$dbh->do("CREATE TABLE info (f1 char(3) primary KEY, f2 char(3), f3 ch
+ar(3))");
$dbh->do('create unique index info_idx on info (f1)');
my $sth = $dbh->prepare("INSERT INTO info VALUES (?, ?, ?)");
$sth->execute("Fred", "Bloggs", "fred\@bloggs.com");
$sth = $dbh->prepare("SELECT * FROM info");
$sth->execute();
while (my @row = $sth->fetchrow_array ) {
print "@row\n";
}
$dbh->disconnect;
this get Fred", "Bloggs", "fred\@bloggs.com".
So i must assume that DBD::SQLite don't test for type size?
sure i can count the data size each time i insert them into
the database but would prefer that SQLite ensures
that i don't forget about it... Any hint if i can get a free lunch here?
Thanks for all the help here and thanks in advance for all the forthcomming one.
Filipe | [reply] [d/l] |
|
| [reply] |