records in text files or configuration

Ulf Wiger <>
Sun Aug 8 13:23:23 CEST 2004


On Thu, 5 Aug 2004 22:38:27 +0200, Fredrik Thulin <> wrote:

> I guess I'll have to invent myself some kind of plain text format that
> is reasonably easy to modify and still easily parseable. Too bad, I'll
> have to deal with quoting and stuff which would otherwise have been
> handled for me.

As an alternative to Richard's suggestions, 'rdbms' has an import function
that uses a text format similar to mail-merge -- basically, tab-delimited
text with a header line denoting the field name for each column, like so:

person.name\t     person.age\t      person.sex\n
kalle\t           25\t              male\n
lisa\t            22\t              female\n

The data ends up in corresponding mnesia tables, after data conversion
if needed.

You can specify data types using the rdbms data dictionary. The available
definitions include basic type, bounds default value and referential
constraints.

By specifying more than one field per column (separated by comma), you
can also accomplish a simple join in your import:

employee.name\t    employee.company, company.id\t    company.name\n
kalle\t            eab\t                             Ericsson AB\n
lisa\t             eab\n

In the above example, you can leave the last column blank once initialized.

A few other nifties are supported, such as support for erlang-style 
comments
in the data file and multiple blocks of data (with different headers) in 
the
same file.

/Uffe
-- 
Ulf Wiger




More information about the erlang-questions mailing list