SQL::T...raphViz(3pm)
β¨ NAME β¨
okay so bestie, this is the manual page for SQL::Translator::Producer::GraphViz β it's the GraphViz producer for SQL::Translator, and it's literally the plug that turns your database schema into an actual picture π
πΈ SYNOPSIS πΈ
use SQL::Translator;
my $trans = SQL::Translator->new(
from => 'MySQL', # or your db of choice
to => 'GraphViz',
producer_args => {
out_file => 'schema.png',
bgcolor => 'lightgoldenrodyellow',
show_constraints => 1,
show_datatypes => 1,
show_sizes => 1
}
) or die SQL::Translator->error;
$trans->translate or die $trans->error;
π DESCRIPTION π
It creates a graph of a schema using the amazing graphviz application (peep it at http://www.graphviz.org/), and it does it via the GraphViz module π¦
It's nifty β you should try it! fr fr β¨
π PRODUCER ARGS π
Every single GraphViz constructor attribute is accepted and passed straight through to "new" in GraphViz. And for a few of those attributes, these defaults are just assumed:
layout => 'dot',
overlap => 'false',
node => {
shape => 'record',
style => 'filled',
fillcolor => 'white',
},
# in inches
width => 8.5,
height => 11,
Wanna know more about these and other attributes? Go read the docs for "new" in GraphViz π
And in addition, this producer also accepts the following arguments:
skip_tablesβ an arrayref or a comma-separated list of table names that should be skipped. β οΈ heads up though: a skipped table node may still show up if another table has foreign key constraints pointing at the skipped table. And if that happens, no table field/index information will be included. so like. keep that in mind bestie πskip_tables_likeβ an arrayref or a comma-separated list of regular expressions matching table names that should be skipped π§clusterβ clustering of tables lets you group and box tables according to function or domain or whatever criteria you choose π The syntax for clustering tables is:
cluster => 'cluster1=table1,table2;cluster2=table3,table4'
Or pass it as an arrayref like so:
cluster => [ 'cluster1=table1,table2', 'cluster2=table3,table4' ]
Or like so:
cluster => [
{ name => 'cluster1', tables => [ 'table1', 'table2' ] },
{ name => 'cluster2', tables => [ 'table3', 'table4' ] },
]
out_fileβ the name of the file where the resulting GraphViz output will be written βοΈ Alternatively an open filehandle can be supplied. If it's undefined (which is the default) β the result is returned as a string πoutput_type(DEFAULT: 'png') β this decides which output method gets invoked to generate the graph:"png"translates to"as_png","ps"to"as_ps"and so on πfontnameβ sets the global font name (or the full path to a font file) for node, edge, and graph labels π€fontsizeβ sets the global font size for node and edge labels (note that arbitrarily large sizes may be ignored due to page size or graph size constraints π)show_fields(DEFAULT: true) β if set to a true value, the names of the columns in a table will be displayed in each table's node π«show_fk_onlyβ if set to a true value, only columns which are foreign keys will be displayed in each table's node πshow_datatypesβ if set to a true value, the datatype of each column will be displayed next to each column's name; this option will have no effect if the value of"show_fields"is set to false π«friendly_intsβ if set to a true value, each integer type field will be displayed as atinyint,smallint,integerorbigintdepending on the field's associated size parameter. This only applies for the"integer"type (and not the"int"type, which is always assumed to be a 32-bit integer); this option will have no effect if the value of"show_fields"is set to false πfriendly_ints_extendedβ if set to a true value, the friendly ints displayed will take into account the non-standard types,'tinyint'and'mediumint'(which, as far as I am aware, is only implemented in MySQL) πshow_sizesβ if set to a true value, the size (in bytes) of eachCHARandVARCHARcolumn will be displayed in parentheses next to the column's name; this option will have no effect if the value of"show_fields"is set to false πshow_constraintsβ if set to a true value, a field's constraints (i.e., its primary-key-ness, its foreign-key-ness and/or its uniqueness) will appear as a comma-separated list in brackets next to the field's name; this option will have no effect if the value of"show_fields"is set to false π§·show_indexesβ if set to a true value, each record will also show the indexes set on each table. It describes the index types along with which columns are included in the index πshow_index_names(DEFAULT: true) β if"show_indexes"is set to a true value, then the value of this parameter determines whether or not to print names of indexes. if"show_index_names"is false, then a list of indexed columns will appear below the field list. Otherwise, it will be a list prefixed with the name of each index π·οΈnatural_joinβ if set to a true value,"make_natural_joins"inSQL::Translator::Schemawill be called before generating the graph πjoin_pk_onlyβ the value of this option will be passed as the value of the like-named argument to"make_natural_joins"inSQL::Translator::Schema; implies"natural_join => 1"πskip_fieldsβ the value of this option will be passed as the value of the like-named argument to"make_natural_joins"inSQL::Translator::Schema; implies"natural_join => 1"π
π DEPRECATED ARGS π
bestie these are giving old news β they still exist but like, use the new ones okay? π«Ά
node_shapeβ Deprecated, usenode => { shape => ... }instead πadd_colorβ Deprecated, usebgcolor => 'lightgoldenrodyellow'instead π
If set to a true value, the graphic will have a background color of 'lightgoldenrodyellow'; otherwise the default white background will be used π€
nodeattrsβ Deprecated, usenode => { ... }instead πedgeattrsβ Deprecated, useedge => { ... }instead πgraphattrsβ Deprecated, usegraph => { ... }instead π
π AUTHOR π
Ken Youens-Clark <kclark@cpan.org>
Jonathan Yu <frequency@cpan.org>
π¦ SEE ALSO π¦
SQL::Translator, GraphViz
and that's the whole page bestie, no cap π this was perl v5.40.0, dated 2024-11-23, and it served SQL::Translator::Producer::GraphViz(3pm) realness π periodt β¨
π¦ where this page comes from
- debian trixie: libsql-translator-perl 1.66-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libsql-translator-perl 1.66-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libsql-translator-perl 1.66-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms