Class Gdbm.DB

Method create

Gdbm.DB Gdbm.DB(void|string file, void|string(99..119) mode)


Without arguments, this function does nothing. With one argument it opens the given file as a gdbm database, if this fails for some reason, an error will be generated. If a second argument is present, it specifies how to open the database using one or more of the follow flags in a string:


Open database for reading


Open database for writing


Create database if it does not exist


Overwrite existing database


Fast mode


Synchronous mode


Locking mode

The fast mode prevents the database from syncronizing each change in the database immediately. This is dangerous because the database can be left in an unusable state if Pike is terminated abnormally.

The default mode is "rwc".


The gdbm manual states that it is important that the database is closed properly. Unfortunately this will not be the case if Pike calls exit() or returns from main(). You should therefore make sure you call close or destruct your gdbm objects when exiting your program.

atexit might be useful.

This is very important if the database is used with the 'l' flag.