manpagez: man pages & more
info gdbm
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12 Export and Import

Gdbm databases can be converted into a portable flat format. This format can be used, for example, to migrate between the different versions of gdbm databases. Generally speaking, flat files are safe to send over the network, and can be used to recreate the database on another machine. The recreated database is guaranteed to be a byte-to-byte equivalent of the database from which the flat file was created. This does not necessarily mean, however, that this file can be used in the same way as the original one. For example, if the original database contained non-ASCII data (e.g. C structures, integers etc.), the recreated database can be of any use only if the target machine has the same integer size and byte ordering as the source one and if its C compiler uses the same packing conventions as the one which generated C which populated the original database. In general, such binary databases are not portable between machines, unless you follow some stringent rules on what data is written to them and how it is interpreted.

gdbm interface: int gdbm_export (GDBM_FILE dbf, const char *exportfile, int flag, int mode)

Create a flat file from the gdbm database. The parameters are:

dbf

A pointer to the source database, returned by a call to gdbm_open. The database must be open in ‘GDBM_WRITER’ mode.

exportfile

The name of the output file.

flag

How to create the output file. If flag is ‘GDBM_WRCREAT’, the file will be created if it does not exist already. Otherwise, if it is ‘GDBM_NEWDB’, it will be created if it does not exist, and truncated otherwise.

mode

The permissions to use when creating the output file. See http://www.manpagez.com/man/2/open, for a detailed discussion.

gdbm interface: int gdbm_import (GDBM_FILE dbf, const char *importfile, int flag)

Populates the database from an existing flat file.

dbf

A pointer to the source database, returned by a call to gdbm_open. The database must be open in ‘GDBM_WRITER’ mode.

importfile

The name of the input flat file. The file must exist.

flag

The flag argument to be passed to gdbm_store function when adding new records. See section Inserting and replacing records in the database., for a description of its effect.

See also Export a database into a portable format., testgdbm export, and testgdbm import.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on December 2, 2011 using texi2html 5.0.

© manpagez.com 2000-2025
Individual documents may contain additional copyright information.