dbm

How do I efficiently empty a Perl DBM file?

I've inherited a piece of code with a snippet which empties the database as follows: dbmopen (%db,"file.db",0666); foreach $key (keys %db) { delete $db{$key}; } dbmclose (%db); This is usually okay but sometimes the database grows very large before this cleanup code is called and it's usually when a user wants to do something import...

Alternative to BerkeleyDB?

I'm looking for a dbm-like library that I can use in place of Berkeley DB, which I'm currently using. My main reason for switching is the licensing fees for BDB are pretty high (free for open source apps, but my employer does not want to open source this particular app for various reasons). I've looked briefly at qdbm but it doesn't loo...

How can I store a timestamp in a DBM database?

I am implemening simple file-sharing service. Currently I use a file-based database (as it suits my needs). # somewhere in my cgi script sub first_run { my $dbh = DBI->connect('dbi:DBM:'); $dbh = DBI->connect("dbi:DBM:", "", "",{ AutoCommit => 1, RaiseError => 1, f_dir=>$DATABASE_DIR} ); unless ($dbh) {...

Ideal string length for DBM database?

When using a DBM database (e.g. Berkeley or GDBM), is it better to store data using fewer long strings or more short strings? I can easily structure my data either way. I'm looking for 'better' in the performance sense, but I'm interested in other implications as well. ...

DBM or SQLite in PHP 5.x

We have a client whose site is hosted on a server (I don't want to disclose hosting company name) which does not provide DB functionality. We have developed a very simple CMS based site but out implementation uses MySQL. I read somewhere that there are DB like functionality built-in in PHP. I have never used them. What are these and ...

dbm.error: db type is dbm.bsd, but the module is not available (Python 3.0)

I'm trying to open a shelve file that I created in 2.5, but I get the error I listed in the question title. The data aren't essential, but I really want them. Looking at the lib\dbm\__init__.py file it recognizes 4 types of dbm modules but only finds dbm.dumb on my system. Does anyone know how I can open this? Is there a bsd.p...

moving a perl script/dbm to a new server, and shifting out of dbm??

I've been tasked with mirroring a site onto a new server. The old site has a few Perl scripts that, as far as I can see internally (i know nothing about Perl, though I have a pretty good understanding of coding generally, and specifically PHP/js/etc) aren't reliant on the old server. That said, when I try to run this script, which looks ...

Must the keys and values in a Berkeley DB on Ruby be strings, not int, float, or any other type?

It seems that if I use Berkeley DB (DBM) on Ruby, the hash's keys and values must be strings? Can they be other data type? require 'dbm' d = DBM.open('test1') d[1] = 2 d[123] = 456 d[2] = 2.34 d['wa'] = Time.now.to_f p d.keys p d.values Result: C:\>ruby test_dbm.rb ["wa", "2", "1", "123"] ["1259229787.686", "2.34", "2", "456"] ...

Why when using DBM with Ruby, db[1] = 2 is ok, but print db[1] will give error?

On Ruby, when using DBM require "dbm" db = DBM.open("somedata") db[1] = 2 # ok p db[1] # gives error does anyone know db[1] = 2 is ok, but printing out db[1] will give error? If it requires db["1"] to be valid, then how come it doesn't apply to both cases but to one case only? ...

How do I access random element in a Perl DBM hash?

I have a Perl DBM hash containing a list of URLs that I want to pick randomly from to load balance spidering sites. As a result I want to pick a key at random, or select the nth element (so I can randomise n). I'm aware this goes against the concept of a hash, but is this possible? NOTE: missed a valuable point that hash size will be ...

Does Python's shelve module use memory-mapped IO?

Does anyone know if Python's shelve module uses memory-mapped IO? Maybe that question is a bit misleading. I realize that shelve uses an underlying dbm-style module to do its dirty work. What are the chances that the underlying module uses mmap? I'm prototyping a datastore, and while I realize premature optimization is generally fro...

Can I use a filehandle instead of a filename for creating DBM files?

I'm using MLDBM to persist some Perl data structures and I'm wondering if there's an alternative to the following: tie %hash, "MLDBM", $dbm_file, O_CREAT | O_RDWR, 0644; Primarily, I'd like to be able to use STDOUT, rather than a known file name. This could then be redirected to a file on the shell-side. I've been searching with keyw...

Python DBM Module for Windows?

Hello, I would like to use the dbm module on my Windows machine, but it is currently only supported on Unix. http://docs.python.org/library/dbm.html Does anyone know of a similar module with similar syntax or a workaround to get dmb functional on windows? Being able to access a database written to the hard drive much like how I code to ...

kyoto cabinet DirDB

hi, someone here ever used kyotocabinet DirDB http://fallabs.com/kyotocabinet/command.html#kcdirmgr ? i'm thinking to use it to store huge xml (~200M each) on filesystem. but i'm not able to understand the way to load the file from the shell command $ kcdirmgr set path key value $ kcdirmgr set storage.kcd `uuid` `cat file.xml` do...

C Custom Database writing errors

I have an assignment for class that I have to write a program to read and write key, value pairs to disk. I am using a linked list to store the keys, and read in values whenever I need to from disk. However, I am having trouble changing and deleting values. I am using this to test it: http://gaming.jhu.edu/~phf/2010/fall/cs120/src/sdbm-e...