|→||1.7 Simple database tools|
Some of the DK tools programs - i.e. printqd - need to save data in a hash table. Data is stored in key/value pairs, keys are unique within a hash table. Both key and value are arrays of bytes.
In simple text databases as a special case we use text strings as key and value. When storing strings the terminating 0 character is stored with the string. The key string must not contain spaces, the value string can contain spaces.
The following main operations are available in the dk4dbi library:
Several backends (external or internal libraries) can be used to implement the functionality, i.e.:
Some of the libraries provide much more functionality than
described above, but to provide an abstraction layer we use the
subset specified above only.
The dk4dbi and dk4dbia library provides an abstraction layer so application code does not need to care about the individual databases.
Use backend::filename to specify databases (backend and file name are separated by two colons). The following backend names can be used:
uses the external Berkeley DB library.
uses the NDBM routines provided by the C runtime library.
implemented in the dk4dbi library (included in DK tools).
There are different pros and cons for each backend type: