DBMEdit 1.1

A Simple Web-based DBM Database Editor

Home > Web Tools > DBMEdit


January 23, 2005-- Released version 1.1, which supports all five DBM formats, lets you display choices in a select menu, treats non-English text better, and fixes a couple bugs.

If you use DBM files, this program makes them easy to edit. Each value stored in a DBM file is treated as several "fields", delimited by a user-defined string-- in effect, supporting multiple columns within the one-column DBM format. This program displays a DBM database as a table, and provides auto-sized forms to add or edit records. You can edit your existing DBM files or create new ones. Multi-user access is safe. Requires Perl 5.

A demo is worth a thousand words. Username "dbmedit", password "demo". Do me a favor and delete garbage records (but leave entertaining ones). Here's the initial input screen, which in this demo will only work if the file name is demo. Don't be alarmed if you get warnings; it just means other people are trying it at the same time.

Download DBMEdit 1.1 (gzipp'ed)

[A DBM file is a simple Unix database. DBM files store key-value pairs in a way that allows fast retrieval, so they can be faster than using simple text data files. Perl supports DBM files through the NDBM_File module; other languages support them in other ways. DBM files are useful in Web development when you need a simple database and you can't (or don't want to) use a full database server. DBM files do not support any queries beyond a simple key lookup.]


  1. Place the script where you want it.

  2. Create a directory below the script called "data/" (the name is user-configurable).

  3. Put your existing DBM files in the data/ directory, or make symbolic links in there that point to the real DBM files.

  4. Figure out how you want to handle permissions. The Web server must be able to write the files in data/, and the data/ directory itself must be writable if you want to create new files in it via this script. Note that if data/ is writable by the Web server's user, then any local hacker with CGI can overwrite your data. If you work around this with setgid or setuid, see the security note in the USER CONFIGURATION section in the script.

  5. PASSWORD-PROTECT WEB ACCESS TO THIS SCRIPT! Otherwise, anyone can edit your DBM files-- probably not what you want. Also, set @ALLOWED_USERS in the USER CONFIGURATION section below. Security within the script is limited at best; it relies on the authentication of whoever's running the script.

Using it

It's pretty self-explanatory. Access the script with no parameters to see the initial entry screen, where you define a new or existing DBM database to edit.

A database is defined by the DBM file name, the column descriptions, and the delimiter between fields. After you define your database for the first time, copy the full URL into a bookmark or HTML link for easy access in the future. I keep an "admin" page with such links to all the DBM files I edit.

Other Random Issues

If you're using Perl 5.6.0 or before, some bugs in the DBM modules prevent multiple DBM types from being supported, so only NDBM_File is supported by default. If you want to use another DBM file type, set $DEFAULT_DBM_TYPE in the configuration section. If you're using Perl 5.6.1, newly created DBM files will be in GDBM format; otherwise, they'll be in NDBM format.

The script runs fast enough, but a DBM file with many records will mean a large table is displayed, which may take your browser a while to render. It's only annoying with big DBM files, but then, DBM's main advantage comes when you have many records... oh well. Maybe it should display large files differently, but columns won't line up without tables.

Many features could easily be added; see the source code for examples. I can add them if there is demand, or others can easily modify the code if they want to.

Return to Web Tools page

© 1998, 2005 James Marshall (comments encouraged)

Last Modified: January 23, 2005 http://www.jmarshall.com/tools/dbmedit/