The Lazy Programmer

March 2, 2010

Berkeley DB Viewer

Filed under: Database,Programming — ferruccio @ 11:27 am
Tags: , ,

I’m currently working on a project which uses Berkeley DB (BDB) as it’s data storage engine. I can’t say enough good things about BDB. It has proven to be a very fast and flexible way to store and retrieve data, it is very easy to use and the documentation is absolutely top notch.

One issue I ran into, though, is that there is no good way to examine the databases for debugging purposes. Initially, I used the provided db_dump command-line tool, which was fine for small databases. Db_dump dumps the entire contents of a database, which was OK when I was dealing with databases with only a few records. But now I am working with databases with thousands and soon millions of records. Db_dump just won’t do.

I did a bit of googling but there didn’t seem to be any viewers available for Berkeley DB, so I decided to write one. I was going to do it in C# and WPF because that’s what I’m currently using. But I decided that, since BDB is cross-platform, a viewer for it should also be cross-platform. So I decided to use Qt to build the viewer.

After a couple of nights of coding, here is the result:


The interface is pretty simple. There is a button for opening a BDB database file. Once a database is opened, the “Database” combo-box let’s you pick which sub-database to view (in BDB terms a database is a key/value table and a single file can contain multiple “databases”). The list view on the left shows all the keys in that database and the view on the right shows the contents at that key. Both keys and values are formatted the same as db_dump -p -k formats them.

I put the source code for Berkeley DB Viewer (bdbvu) on Google Code. You can grab it at:

To build it you need two things:

  1. Berkeley DB, installed and built with C++ support.
  2. Qt4.

Once you have those set up and you’ve downloaded the code, you will probably need to change the Qt project file to reflect your environment. I may enventually provide binary downloads, but I don’t have the time for that right now.

Finally, a few things to keep in mind:

  • I’ve only tested this with DB_RECNO and DB_BTREE databases, since that’s what I’m using at this time. But, there’s no reason it shouldn’t work with DB_HASH and DB_QUEUE databases as well. (Where have I heard that before?)
  • I’ve only tested it with databases with embedded databases, not with stand-alone databases. I know it won’t work with stand-alone databases because the code for that is a no-op.
  • I’ve only built and run this on OS X. Theoretically, it should work on Windows and Linux as well, but you never know until you try it.
  • When you open a database, it will load all it’s keys into memory. This seems to be pretty quick (a couple of seconds for a 3000+ record database on my laptop) but I may have to change it to use a more scalable method in the future.

That’s it for now. I hope you find this useful.



  1. Oh thank you!

    Comment by Tretaidenia — March 7, 2010 @ 12:43 am

  2. Hi,

    I am looking for such a GUI which can handle BDB files, the project looks great.
    However, it looks that the download permission is shut down on above link. Can I find it from somewhere else?

    Really thanks for your help!

    Comment by Devcon — July 26, 2010 @ 8:37 am

    • There is no download link, but you can checkout the source using Subversion (under the Source tab). It’s still very much an alpha stage project so there is no installer and although it builds on both Windows and OS X, the Windows build seems to be less stable at the moment.

      Comment by ferruccio — July 26, 2010 @ 9:02 am

  3. Downloaded the source code via svn. Thank you very much!

    Comment by Devcon — July 26, 2010 @ 9:58 am

RSS feed for comments on this post.

Create a free website or blog at

%d bloggers like this: