# Dbm library

**URL:** <https://www.ruby-forum.com/t/dbm-library/74748>\
**Category:** Ruby\
**Created:** [November 7, 2006, 10:55am UTC](https://www.ruby-forum.com/t/dbm-library/74748 "2006-11-07T10:55:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PWR](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/977dab/32.png) [@PWR](https://www.ruby-forum.com/u/PWR)\
**Post date:** [November 7, 2006, 10:55am UTC](https://www.ruby-forum.com/t/dbm-library/74748/1 "2006-11-07T10:55:05Z")

</div>

I am using Ruby 1.8.2 on Windows and am wanting to use the dbm library  
but cannot seem to find it anywhere. Can anyone please tell me where I  
can find this package?

---

<div class="post-metadata">

**Author:** ![PWR](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/977dab/32.png) [@PWR](https://www.ruby-forum.com/u/PWR)\
**Post date:** [November 7, 2006, 10:55am UTC](https://www.ruby-forum.com/t/dbm-library/74748/2 "2006-11-07T10:55:16Z")

</div>

On Fri, 3 Nov 2006, PWR wrote:

> I am using Ruby 1.8.2 on Windows and am wanting to use the dbm library  
> but cannot seem to find it anywhere. Can anyone please tell me where I  
> can find this package?

it comes with ruby.

harp:~ \> ruby -r dbm -e’ p DBM ’  
DBM

-a

---

<div class="post-metadata">

**Author:** ![PWR](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/977dab/32.png) [@PWR](https://www.ruby-forum.com/u/PWR)\
**Post date:** [November 7, 2006, 10:55am UTC](https://www.ruby-forum.com/t/dbm-library/74748/3 "2006-11-07T10:55:35Z")

</div>

On 11/2/06, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Fri, 3 Nov 2006, PWR wrote:
> 
> > I am using Ruby 1.8.2 on Windows and am wanting to use the dbm library  
> > but cannot seem to find it anywhere. Can anyone please tell me where I  
> > can find this package?
> 
> it comes with ruby.
> 
> harp:~ \> ruby -r dbm -e’ p DBM ’  
> DBM

With ruby 1.8.5, there is no DBM on windows, it’s SDBM or GDBM.

---

<div class="post-metadata">

**Author:** ![PWR](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/977dab/32.png) [@PWR](https://www.ruby-forum.com/u/PWR)\
**Post date:** [November 7, 2006, 10:58am UTC](https://www.ruby-forum.com/t/dbm-library/74748/4 "2006-11-07T10:58:12Z")

</div>

snacktime wrote:

> > DBM
> 
> With ruby 1.8.5, there is no DBM on windows, it’s SDBM or GDBM.

Thanks, that’s solved it. I am now using SDBM.

---

<div class="post-metadata">

**Author:** ![PWR](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/977dab/32.png) [@PWR](https://www.ruby-forum.com/u/PWR)\
**Post date:** [November 7, 2006, 10:58am UTC](https://www.ruby-forum.com/t/dbm-library/74748/5 "2006-11-07T10:58:20Z")

</div>

From: “PWR” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> > > harp:~ \> ruby -r dbm -e’ p DBM ’  
> > > DBM
> > 
> > With ruby 1.8.5, there is no DBM on windows, it’s SDBM or GDBM.
> 
> Thanks, that’s solved it. I am now using SDBM.

Warning, unless something’s changed since I last tried SDBM  
on Windows a few years ago… It has some severe limitations.

(It wasn’t a Ruby problem, Perl uses the same SDBM library and  
exhibits the same issues.)

For ex… This test program tries to write a million key/values  
to an SDBM store, where the key length is 8 bytes, and the  
value ranges from 1…512 bytes:

require ‘sdbm’

k = 12345678

SDBM.open(“test.dbm”) do |dbm|  
1000.times {|iter|  
1000.times {  
dbm[k.to\_s] = “v” \* (rand(511) + 1)  
k += 1  
}  
print "#{iter} "  
}  
end

On my system (win xp pro, NTFS) it only makes it to around  
40,000 to 50,000 keys before blowing up with:  
dbmtest.rb:9:in `[]=': sdbm\_store failed (SDBMError)

And the .pag file size has bloated up to 1.7 to 2.1 gigs at  
the point it dies.

Anyway, just FYI… if you program needs to store a lot of  
key/values, SDBM may not be able to handle it…

Regards,

Bill
