

GDBM_NEWDB Creates a new database regardless of whether another one with the same name exists (i.e., it will overwrite old databases) otherwise, it's the same as GDBM_WRITER.int mode - This sets the file permissions of the database, just as you would with chmod. GDBM_WRCREAT Creates a new database if none previously exists otherwise the same as GDBM_WRITER. Only one program can access the database in GDBM_WRITER mode. GDBM_WRITER Allows both reading and writing. Multiple programs can access the database while in GDBM_READER mode. Once the database is created, the block size cannot be changed.int flags - GDBM_READER Opens the database in read-only mode. In this case, 512 is both the minimum and the default. This will be the name of the binary data file that's written to disk.int block_size - A block is a group of bits that's transferred as a single unit. Here, then, are the arguments and explanations: char *name - The name of your database. The “flags” argument is what differentiates between creating a new database and opening an old one. Here’s how it works: GDBM_FILE dbf dbf = gdbm_open(name, block_size, flags, mode, fatal_func) As with other libraries, you link with a simple command line flag - in this case, -lgdbm.Ĭreating a new database and opening an existing one are both accomplished with the same function: gdbm_open(). You access the gdbm library by creating C programs that use functions found in the gdbm.h header file. Now that you have the gdbm library, we’ll jump right in and do some coding. If not, then all you have to do is make a quick trip to Simply download, compile, and install, as you would with any other package. (e.g., libgdbm.so.1.7.3), you’re in good shape. If you see something along the lines of libgdbm.so. Most Linux distributions include it, but you can make a quick check by looking in your /lib directory. The first step is to make sure that you have gdbm. Your data is simply stored as a regular file on disk. But, for small to mid-sized data collections, the time differential is negligible.īest of all, you don’t need to worry about mounting and unmounting anything created with gdbm.

Databases created with gdbm aren’t indexed, meaning that you certainly don’t want to use it for a multi-terabyte data warehouse. On the downside, the speed isn’t as great as it might be with other systems.

Yet, you can still use gdbm-powered databases for customer files, back ends to Websites, and anywhere else that an RDBMS would be appropriate. Tuning is not an issue, and you don’t need sophisticated algorithms to get the most out of your data store. There aren’t 1,001 features and procedures to memorize, making for a gentle learning curve. Gdbm, or the GNU Database Manager, is a fully-capable, yet simple means of storing and retrieving data. Isn’t there an intermediate data storage solution, somewhere between clunky text files and full-blown relational databases? You may have outgrown plain-text “flatfiles,” but you might not be quite ready for the planning and maintenance that goes along with a full-fledged RDBMS.įurther, as you likely run Linux or some version of BSD, Microsoft Access isn’t aviable option, either. Indeed, MySQL and PostgreSQL have been touted as capable alternatives to Oracle and Sybase, the traditional heavyweights of the commercial RDBMS world.īut let’s say you, the programmer, need something simpler. Lately, a number of open source relational databases have received favorable press.
