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 a tinyint, smallint, integer or bigint depending 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 each CHAR and VARCHAR column 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" in SQL::Translator::Schema will 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" in SQL::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" in SQL::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, use node => { shape => ... } instead 😭
  • add_color β€” Deprecated, use bgcolor => '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, use node => { ... } instead 😭
  • edgeattrs β€” Deprecated, use edge => { ... } instead 😭
  • graphattrs β€” Deprecated, use graph => { ... } 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