Search code examples
pythondatabasebsddb

bsddb in Python and Unix


I haven't heard of bsddb till recently.

http://www.oracle.com/us/products/database/berkeley-db/index.html http://en.wikipedia.org/wiki/Berkeley_DB

I haven't been able to figure out what exactly it is. bsddb seems to be installed on my Mac but I definitely didn't install it. Is that because bsddb comes installed by default? Is that true on all Unix machines? Is the library on my machine Oracle's distribution? (I tried which bsddb but that didn't work).

Could anyone just generally explain bsddb both in the the context of why it's in my machine and also in terms of the Python libraries provided (anydbm and bsddb).


Solution

  • BDB is a database system available on Unix machines for probably two or more decades. It originally provided single-process database services (not at all like MySQL or PostgreSQL database daemons that provide services for other processes) so that applications could focus on their code and save everyone the hassle of writing and debugging hashed-access database code.

    It was originally very simple system intended for a single-process-at-a-time key/value store, and intended to drastically speed up some operations that might have been done in simple plain text otherwise: the /etc/master.passwd that is probably on your OS X system (common to most? all? of the BSD systems) is a BDB version of the /etc/passwd and /etc/shadow files so that login(1) and sshd(8) and similar tools don't need to perform a linear search but instead use a hashed lookup to find the user account very quickly.

    Newer versions of BDB integrate process-awareness, with full transactional support, and even SQL query support -- presumably to compete against SQLite3, which has mostly supplanted BDB in new applications.

    You can expect some form of BDB on nearly every Unix machine, but the versions available vary widely, so the features available may not be consistent. (On my Ubuntu system, I have BDB versions 4.7, 4.8, and 5.1 installed. Go figure.)