[CDBI] ERD's

Andrew O'Brien andrewo at oriel.com.au
Thu Nov 16 04:14:07 GMT 2006


Hi Daniel,

> Does anyone know of scripts/module that can create pretty 
> ERD's based on
> my Class::DBI.

Have a look at:

GraphViz
GraphViz::DBI
Class::DBI::Loader::GraphViz

If you've got a supported DB with detectable/programmable foreign keys
then they work reasonably well. The output isn't the prettiest thing
you've ever seen but it works.

I have the extra problem that relationships in my particular case (mysql
w/o foreign key constraints and some strangely inconsistent fk naming on
columns) need to come from Class::DBI modules rather than from the DB. I
whipped up a quick wrapper script then generates & executes another perl
script with the has_a relationships hard coded.

There are probably better ways to do this but it worked for me :)

Comes with command line help but a sample execution:

./db_diagram.pl --module_base Oriel::Something --path
~/src/lib/Oriel/Something --dsn 'dbi:mysql:something' --user andrewo
--pass password --outfile diagram.ps

It can also optionally munge the (occasionally large-scale) [e]ps output
file to force it to A3 as we have an A3 printer here. Works well enough
but assumes you're in a unix environment with the psnup command.

If this is something that people find useful I can probably fix it
up/extend it further.

Hope it helps!


Andrew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: db_diagram.pl
Type: application/octet-stream
Size: 4223 bytes
Desc: db_diagram.pl
Url : http://lists.digitalcraftsmen.net/pipermail/classdbi/attachments/20061116/20d81063/db_diagram.obj


More information about the ClassDBI mailing list