On Nov 1,  4:57pm, Louis-David Mitterrand wrote:
> I need a tool to interactively visualize DB tables from a web interface.
> Ideally this tool would let me:
>
> - rename column headers,
> - set cell alignments, widths, background colors,
> - reorder columns,
> - save all these visualisation settings in a DB,
> - it would be written in perl (even better: mod_perl),

Have a look at the Template Toolkit, and in particular the DBI and Table
plugins.

The DBI plugin does pretty much what you would expect.  The Table plugin
takes some data (including the data iterator returned by the DBI plugin)
and allows you to format it in a virtual table.  How you present the
data is then entirely up to you, and is controlled by templates.

Here's an example adapted from the manpage for the Table plugin.

    [% USE DBI(dsn,user,pass) -%]

    # query() returns an iterator
    [% results = DBI.query('SELECT * FROM alphabet ORDER BY letter') %]

    # pass result set into Table plugin
    [% USE table(results, rows=8, overlap=1, pad=0) -%]

    <table>
    [% FOREACH row = table.rows -%]
    <tr>
      <td>[% row.first.letter %] - [% row.last.letter %]</td>
      [% FOREACH item = row %]
      <td>[% item %]</td>
      [% END %]
    </tr>
    [% END %]
    </table>

The key concept is that the Table plugin does nothing more than order
your data into virtual rows and/or columns.  You can then iterate through
the data by row, column, or any combination of the two, and present it
any way you wish, by use of templates (*real* templates, not the embedded
Perl variety).  In other words, it gives you a clear separation between
data, logic and presentation.

For different presentation styles, you can simply create different
template components to display the data, e.g.

    [% USE DBI(dsn,user,pass) -%]

    [% results = DBI.query('SELECT * FROM alphabet ORDER BY letter') %]

    [% INCLUDE fancy_table  %]
    [% INCLUDE plain_table  %]
    [% INCLUDE boring_table %]

See http://www.template-toolkit.org/
 or http://www.cpan.org/modules/by-module/Template/

HTH
A




-- 
Andy Wardley <[EMAIL PROTECTED]>   Signature regenerating.  Please remain seated.
     <[EMAIL PROTECTED]>   For a good time: http://www.kfs.org/~abw/

Reply via email to