[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Data Dictionary and Configuration Files with Guile Scheme
From: |
Thien-Thi Nguyen |
Subject: |
Re: Data Dictionary and Configuration Files with Guile Scheme |
Date: |
Wed, 18 Aug 2010 20:20:40 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
() Romel Sandoval <address@hidden>
() Thu, 05 Aug 2010 12:15:44 -0500
What do you think?
I use Guile-PG (several modules) and a homegrown metainfo table
accessible via ‘(ttn-do zzz various-db) personal-pgtable-defs’ et al:
http://www.gnuvola.org/software/ttn-do/ttn-do.html.gz#zzz-various_002ddb
Here is ~/.pgtable-defs, omitting some parts:
;;; ~/.pgtable-defs --- database descriptions -*- scheme -*-
;; Keyword Expansions
;; ------------------
((#:pk "PRIMARY KEY")
(#:u "UNIQUE")
(#:nn "NOT NULL")
(#:mf "MATCH FULL")
(#:dc "ON DELETE CASCADE")
(#:uc "ON UPDATE CASCADE")
(#:r "REFERENCES")
(#:tz "WITH TIME ZONE"))
;; Database Table Definitions
;; --------------------------
;;
;; ((DB-1 (TABLE DEF ...) (TABLE DEF ...) ...)
;; (DB-2 (TABLE DEF ...) (TABLE DEF ...) ...) ...)
;;
;; Some day `infer-defs' will be able to round-trip these...
(("ttn"
("sw_maint"
(v bool #:nn)
(url text #:nn)
(mon text #:nn)
(name text #:pk)
(orig text)
(mtim timestamp[]))) ; 0: mon
("gnuvola"
("updbad"
(time timestamp #:pk)
(cause text)
(errmsg text))
("updok"
(time timestamp #:pk)
(wrote int4)
(read int4)
(rate float4)
(total int4)
(speedup float4))
("updfiles"
(file text)
(move char)
(time timestamp #:r "updok" #:dc #:uc))))
;;; ~/.pgtable-defs ends here
This file consists of two forms. The first is (hopefully)
self-explanatory. The second describes two databases:
db tables
------- -----------------------
ttn sw_maint
gnuvola updbad, updok, updfiles
Each table's columns are further described in a way that really ought to
be queryable from the backend, so that is a Code Enhancement Opportunity
for the Guile-PG reflection module alluded to by the "Some day" comment.
Although i think SQL is ugly (and thus concur in jest, i believe,
with Andy Wingo's admonition :-), Guile-PG makes it livable. E.g.:
http://www.gnuvola.org/software/guile-pg/qcons-notes.txt
So, to answer your question: yes, sexps work fine as a Data Dictionary.