Going Off the Beaten DB Path (cont'd)

Taking Berkeley to Task

Let's take a look at how you can get started with Berkeley DB. I'm assuming you've already downloaded the package from the Sleepycat Web site and installed it on your preferred platform, and that you have Perl 5 installed. I'll provide code examples here using Perl, on the grounds that it's free, simple, and available for a variety of platforms. Access to Berkeley DB using Perl comes courtesy of one of two modules: BerkeleyDB, which is currently still in alpha stage, and DB_File, which is stable. DB_File comes with the standard Perl 5 distribution, so chances are you've already got it, but it never hurts to check.

The following code creates a Berkeley DB file and adds some data to it.

#!/usr/local/bin/perl

use strict;
use DB_File;

my %hash;

tie %hash, "DB_File", "myDB"
  or die "Could not create file 'myDB': $!\n";

$hash{'key1'} = 'value1';
$hash{'key2'} = 'value2';
$hash{'key3'} = 'value3';

untie %hash;


  
Next: T-I-E Function Does the Heavy Lifting

1 Introduction 2 Designed for Programmers, not DBAs 3 Taking Berkeley to Task
4 T-i-e Function Does the Heavy Lifting 5 Won't Break a Sweat Building a Hash 6 Assigning Multiple Values to a Single Key


Get Help - Search Tips
 

Sleepycat Software

DevX e-Learning: Relational Database Concepts

DevX's Open Source Zone

DevX's Open Source.General discussion group

 TALK BACK
Have you ever worked with an open-source database? Has it served your purpose well? How does it compare with conventional DBs? Go here to start or join the discussion.
Click here to Join


Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map
Jupiterweb networks

internet.comearthweb.comDevx.comClickZ

Search Jupiterweb:

Jupitermedia Corporation has four divisions:
JupiterWeb, JupiterResearch, JupiterEvents, and JupiterImages

Copyright 2004 Jupitermedia Corporation All Rights Reserved.
Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Jupitermedia Corporate Info | Newsletters | Tech Jobs | E-mail Offers