Re: Storing Configuration settings for a database? - Mailing list pgsql-general

From Richard Huxton
Subject Re: Storing Configuration settings for a database?
Date
Msg-id 200401261548.11852.dev@archonet.com
Whole thread Raw
In response to Storing Configuration settings for a database?  ("D. Dante Lorenso" <dante@lorenso.com>)
List pgsql-general
On Monday 26 January 2004 11:47, D. Dante Lorenso wrote:
> I want to store config file keys and values in my PG database
> in order to 1) be able to INSERT/UPDATE/DELETE configuration settings
> without a flat file and 2) give access to the config settings with
> my web application.
>
> Right now, my java application uses a config file similar to an .INI
> file with the following format:
>
>     [section1]
>         key1 = value1
>         key2 = "Value Two"
>         multi word key3 = 12345
>     [section2]

> Who has built something similar to what I'm attempting, and what do you
> recommend?

I tend to have something like:

CREATE TABLE config_settings AS (
    section  varchar(64),
    item     varchar(64),
    type     varchar(16),
    value    text,
    PRIMARY KEY (section,item)
);

In general, two levels (section,item) seem enough, but it's trivial to add
another. I cast the value from text => my desired type in the app (or raise
an exception if there is a problem).

Oh - I frequently add a "notes" or "description" column to for instructions on
what value should go in.

--
  Richard Huxton
  Archonet Ltd

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: I can't upgrade to PostgreSQL 7.4 in RedHat 9.0
Next
From: Richard Huxton
Date:
Subject: Re: Casting varchar to interval.?