postgresql_autodoc is a nice tool for generating documentation for a postgresql database schema. It sends database metadata to an HTML::Template-template and can generate html, dot, dia, and docbook xml. I wanted to use it to generate Pod -- one page per table or view.

Here's the technique I came up with :
mkdir pod perl -MIO::File -lpe ' s/^_CUT: (.*)$// and do { *STDOUT = IO::File->new(">pod/$1"); }; s/^_DB: (.*)$// and do { $_ = qx[psql -c "$1"]; s/^/ /gm; }; ' mydb.pod
(A prerequisite is to have comments on tables and columns stored inside the database using the comment features of postgres).

Here's the template :
<tmpl_loop schemas><tmpl_loop tables> _CUT: <tmpl_if view_definition>view<tmpl_else>table</tmpl_if>_<tmpl_va +r table>.pod =head1 NAME <tmpl_var table> =head1 DESCRIPTION <tmpl_var table_comment> =head1 COLUMNS <tmpl_loop columns> <tmpl_var column> (<tmpl_var column_type>) - <tmpl +_var column_comment> </tmpl_loop> =head1 SCHEMA _DB: \d+ <tmpl_var table> =cut </tmpl_loop> </tmpl_loop>