1 package SQL::Translator::Producer::Latex;
7 SQL::Translator::Producer::Latex -
8 Produces latex formatted tables ready for import from schema.
13 my $translator = SQL::Translator->new(
15 filename => 'foo_schema.sql',
18 print $translator->translate;
22 Currently you will get one class (with the a table
23 stereotype) generated per table in the schema. The fields are added as
24 attributes of the classes and their datatypes set. It doesn't currently set any
25 of the relationships. It doesn't do any layout, all the classses are in one big
26 stack. However it is still useful as you can use the layout tools in Dia to
27 automatically arrange them horizontally or vertically.
41 our $VERSION = '1.59';
43 use SQL::Translator::Utils 'debug';
46 my $translator = shift;
47 my $schema = $translator->schema;
49 for my $table ( $schema->get_tables ) {
50 my $table_name = $table->name or next;
51 my $n = latex($table_name);
61 \begin{tabular}{l l p{8cm}}
62 Column & Datatype & Description \\\\ \hline
64 $n, latex($table->comments), $n, $table_name;
66 foreach my $f ($table->get_fields) {
67 $o .= sprintf '%s & %s & %s \\\\', map {latex($_)} ($f->name, $f->data_type, $f->comments || '');
82 return '' unless defined $s;
83 $s =~ s/([\&\_\$\{\#])/\\$1/g;