Re: Cross-platform DB
by monkey_boy (Priest) on Feb 21, 2007 at 14:20 UTC
|
| [reply] |
Re: Cross-platform DB
by dragonchild (Archbishop) on Feb 21, 2007 at 14:09 UTC
|
You're looking for DBM::Deep. It automatically marshals Perl datastructures and can act as a DBM without a problem. 1.0000 will also have transactions. :-)
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
| [reply] |
Re: Cross-platform DB
by philcrow (Priest) on Feb 21, 2007 at 14:20 UTC
|
You might also like http://www.sqlite.org. Their unix version works fine on Mac and there is a windows version. It's light and fast and the easiest install I have ever done (I did it manually on Linux).
Phil | [reply] |
Re: Cross-platform DB
by derby (Abbot) on Feb 21, 2007 at 14:29 UTC
|
DBD::SQLite would be a good start -- as easy to install as dbm and the power of an RDBMS.
update: Wow! two other sqlite suggestions. The great thing about DBD::SQLite is that it has sqlite as part of it's distribution - no need to install sqlite first and then install the perl mod.
| [reply] |
|
J:\BSACamps.tst\CGI\DBM-Deep-0.99_04>perl makefile.pl
Checking if your kit is complete...
Looks good
Warning: prerequisite Clone 0.01 not found.
Warning: prerequisite FileHandle::Fmode 0.05 not found.
Warning: prerequisite Test::Deep 0.095 not found.
Warning: prerequisite Test::Exception 0.21 not found.
Writing Makefile for DBM::Deep
I created their test program:
#!/usr/bin/perl
use DBM::Deep;
my $db = new DBM::Deep "foo.db";
$db->{mykey} = "myvalue";
but received the following when I went to run it:
Can't locate DBM/Deep.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/s
+ite/lib .) at test.cgi line 2.
BEGIN failed--compilation aborted at test.cgi line 2.
| [reply] [d/l] [select] |
|
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
# what's your data look like?
my %monks = (
'8930' => 'derby',
'581658' => 'wpahiker',
'961' => 'Anonymous Coward',
'104919' => 'perrin'
);
# create the database handle
my $dbh = DBI->connect( "dbi:SQLite:monastery.dat" );
# create a table
$dbh->do( "CREATE TABLE monks (id INTEGER PRIMARY KEY, name)" );
# insert values
foreach my $monkid ( keys %monks ) {
$dbh->do( "INSERT INTO monks VALUES ($monkid, '$monks{$monkid}')" );
}
# fetch data
my $sql = "select * from monks";
my $res = $dbh->selectall_arrayref( $sql );
foreach my $rec (@$res) {
print "$rec->[1] is $rec->[0]\n";
}
$dbh->disconnect;
| [reply] [d/l] |
|
|
|
|
| [reply] |
|
Are you using ActivePerl? If so, why not just install DBM::Deep from the PPM? (As DBM-Deep) Recent ActivePerl releases include PPM v4, which is GUI based :)
| [reply] |
|
|
I think you may have skipped a step or two on the module install... Usually it's:
perl makefile.pl
make
make install
See if that helps?
| [reply] |
|
I agree with this. SQLite is very easy to use. Each database is stored in its own easy to find (and backup) file.
Helps too when there is a useful tool like the SQLite Database Browser (sourceforge.net). Note on using this tool though is that when you modify the database, you have to save it to remove the lock it puts in place.
| [reply] |
Re: Cross-platform DB
by marto (Cardinal) on Feb 21, 2007 at 14:16 UTC
|
Regards installing Oracle/Berkeley BD, I did this only yesterday on Solaris. I unpacked the tar file and did the following:
cd build_unix
sh -c "CC=gcc ../dist/configure --prefix=/you/install/path/here"
make
make install
Oracle have documentation for building on Win32 and OS X platforms also. dragonchild has advised you of an alternative if you do not have your heart set on Berkeley DB.
Hope this helps.
Martin | [reply] [d/l] |
Re: Cross-platform DB
by perrin (Chancellor) on Feb 21, 2007 at 15:28 UTC
|
There's probably a PPM for BerkeleyDB or DB_File on Windows. | [reply] |