The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

SYNOPSIS

  use SQL::Translator;

  my $trans = new SQL::Translator(
      from => 'MySQL',            # or your db of choice
      to => 'GraphViz',
      producer_args => {
          out_file => 'schema.png',
          add_color => 1,
          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

  • 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.

  • layout (DEFAULT: 'dot')

    determines which layout algorithm GraphViz will use; possible values are 'dot' (the default GraphViz layout for directed graph layouts), 'neato' (for undirected graph layouts - spring model) or 'twopi' (for undirected graph layouts - circular)

  • node_shape (DEFAULT: 'record')

    sets the node shape of each table in the graph; this can be one of 'record', 'plaintext', 'ellipse', 'circle', 'egg', 'triangle', 'box', 'diamond', 'trapezium', 'parallelogram', 'house', 'hexagon', or 'octagon'

  • output_type (DEFAULT: 'png')

    sets the file type of the output graphic; possible values are 'ps', 'hpgl', 'pcl', 'mif', 'pic', 'gd', 'gd2', 'gif', 'jpeg', 'png', 'wbmp', 'cmap', 'ismap', 'imap', 'vrml', 'vtx', 'mp', 'fig', 'svg', 'canon', 'plain' or 'text' (see GraphViz for details on each of these)

  • width (DEFAULT: 8.5)

    width (in inches) of the output graphic

  • height (DEFAULT: 11)

    height (in inches) of the output grahic

  • fontsize

    custom font size for node and edge labels (note that arbitrarily large sizes may be ignored due to page size or graph size constraints)

  • fontname

    custom font name (or full path to font file) for node, edge, and graph labels

  • nodeattrs

    reference to a hash of node attribute names and their values; these may override general fontname or fontsize parameter

  • edgeattrs

    reference to a hash of edge attribute names and their values; these may override general fontname or fontsize parameter

  • graphattrs

    reference to a hash of graph attribute names and their values; these may override the general fontname parameter

  • show_fields (DEFAULT: true)

    if set to a true value, the names of the colums 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

  • 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

  • add_color

    if set to a true value, the graphic will have a background color of 'lightgoldenrodyellow'; otherwise the background color will be white

  • natural_join

    if set to a true value, the make_natural_join method of SQL::Translator::Schema will be called before generating the graph; a true value for join_pk_only (see below) implies a true value for this option

  • join_pk_only

    the value of this option will be passed as the value of the like-named argument in the make_natural_join method (see natural_join above) of SQL::Translator::Schema, if either the value of this option or the natural_join option is set to true

  • skip_fields

    the value of this option will be passed as the value of the like-named argument in the make_natural_join method (see natural_join above) of SQL::Translator::Schema, if either the natural_join or join_pk_only options has a true value

  • 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. this option requires that show_fields is a true value as well

  • show_index_names

    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. it defaults to true.

  • friendly_ints

    if set to a true value, each integer type field will be displayed as a smallint, integer or bigint depending on the field's associated size parameter. this only applies for the 'integer' type (and not the lowercase 'int' type, which is assumed to be a 32-bit integer).

  • 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)

AUTHOR

Ken Y. Clark <kclark@cpan.org>

CONTRIBUTORS

Jonathan Yu <frequency@cpan.org>

SEE ALSO

SQL::Translator, GraphViz