danielw at staff.iinet.net.au
Thu Nov 16 07:21:30 GMT 2006
It's definitely close to what I'm looking for.
I tinkered a whole with the script and unfortunately I have multiple
primary keys in some circumstances in mysql which means the primary keys
are set wrong with loader which in turn confuses has_a. Infact the
database I'm forced to work with is very poor. I think I will just
re-write Class::DBI::Loader::Graphiz to be Class::DBI::Graphiz.
I'll post the finished product to cpan or similar.
From: Andrew O'Brien [mailto:andrewo at oriel.com.au]
Sent: Thursday, 16 November 2006 12:14 PM
To: classdbi at lists.digitalcraftsmen.net
Subject: RE: [CDBI] ERD's
> Does anyone know of scripts/module that can create pretty
> ERD's based on
> my Class::DBI.
Have a look at:
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!
More information about the ClassDBI