SQL::Translator::Producer::GraphViz(3p)

NAME
SQL::Translator::Producer::GraphViz - GraphViz producer for SQL::Translator

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
Creates a graph of a schema using the amazing graphviz (see http://www.graphviz.org/) application (via the GraphViz module). It's nifty--you should try it!

PRODUCER ARGS
All GraphViz constructor attributes are accepted and passed through to "new" in GraphViz. The following defaults are assumed for some attributes:

  layout => 'dot',
  overlap => 'false',

  node => {
    shape => 'record',
    style => 'filled',
    fillcolor => 'white',
  },

  # in inches
  width => 8.5,
  height => 11,

See the documentation of "new" in GraphViz for more info on these and other attributes.

In addition this producer accepts the following arguments:

•   skip_tables

    An arrayref or a comma-separated list of table names that should be skipped. Note that a skipped table node may still appear if another table has foreign key constraints pointing to the skipped table. If this happens no table field/index information will be included.

•   skip_tables_like

    An arrayref or a comma-separated list of regular expressions matching table names that should be skipped.

•   cluster

    Clustering of tables allows you to 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 undefined (the default) - the result is returned as a string.

•   output_type (DEFAULT: 'png')

    This determines which output method will be invoked to generate the graph: "png" translates to "as_png", "ps" to "as_ps" and so on.

•   fontname

    This sets the global font name (or full path to font file) for node, edge, and graph labels

•   fontsize

    This 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

•   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