From: Ken Youens-Clark Date: Tue, 26 Aug 2003 03:54:59 +0000 (+0000) Subject: Moved POD around, added all options for all parsers and non-graphical X-Git-Tag: v0.04~225 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=44598b940b2d9621068f10d11e422de8c22288fe;p=dbsrgits%2FSQL-Translator.git Moved POD around, added all options for all parsers and non-graphical producers. --- diff --git a/bin/sqlt b/bin/sqlt index 8038ac0..6b001f1 100755 --- a/bin/sqlt +++ b/bin/sqlt @@ -1,9 +1,9 @@ #!/usr/bin/perl -w # ------------------------------------------------------------------- -# $Id: sqlt,v 1.1 2003-08-26 02:29:12 kycl4rk Exp $ +# $Id: sqlt,v 1.2 2003-08-26 03:54:59 kycl4rk Exp $ # ------------------------------------------------------------------- -# Copyright (C) 2002 Ken Y. Clark , +# Copyright (C) 2002 Ken Y. Clark , # darren chamberlain # # This program is free software; you can redistribute it and/or @@ -21,15 +21,92 @@ # 02111-1307 USA # ------------------------------------------------------------------- +=head1 NAME + +sqlt - convert SQL schema using SQL::Translator + +=head1 SYNOPSIS + +For help: + + sqlt -h|--help + +For a list of all parsers and producers: + + sqlt -l|--list + +To translate a schema: + + sqlt -f|--from|--parser MySQL + -t|--to|--producer Oracle + [options] + file [file2 ...] + + General Options: + + -d|--debug Print debug info + -v|--validate Validate the schema + --trace Print parser trace info + --show-warnings Print warnings to STDERR + + xSV Parser Options: + + --fs The field separator + --rs The record separator + --no-trim Don't trim whitespace on fields + --no-scan Don't scan fields for data types and sizes + + DB Producer Options: + + --add-drop-table Add 'DROP TABLE' statements before creates + --no-comments Don't include comments in SQL output + + Diagram Producer Options: + + --imap-file Filename to put image map data + --imap-url URL to use for image map + + HTML/POD Producer Options: + + --pretty Use CGI::Pretty for the outpu + --title Title of schema + + TTSchema Producer Options: + + --template The path to the template + + XML-SQLFairy Producer Options: + + --emit-empty-tags Print empty tags for attributes + --attrib-values Use attributes instead of tags for + values of the schema objects + +=head1 DESCRIPTION + +This script is part of the SQL Fairy project. It will try to convert +any source file for which it has a grammar into any format for which +it has a producer. + +If using "show-warnings," be sure to redirect STDERR to a separate file. +In bash, you could do this: + + $ sql_translator.pl -f MySQL -t PostgreSQL --show-warnings \ + file.sql 1>out 2>err + +You can specify a parser or producer located in any module that Perl +knows about, allowing you to easily substitute your own. + +=cut + +# ------------------------------------------------------------------- + use strict; use Getopt::Long; use Pod::Usage; use SQL::Translator; -use Data::Dumper; - use vars qw( $VERSION ); -$VERSION = sprintf "%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/; my $from; # the original database my $to; # the destination database @@ -50,46 +127,46 @@ my $imap_file; # filename where to place image map coords my $imap_url; # URL to use in making image map my $pretty; # use CGI::Pretty instead of CGI (HTML producer) my $template; # template to pass to TTSchema producer +my $title; # title for HTML/POD producer +my $emit_empty_tags; # show empty XML tags +my $attrib_values; # use XML attributes instead of tags -# -# Get options, explain how to use the script if necessary. -# GetOptions( + 'add-drop-table' => \$add_drop_table, + 'attrib-values' => \$attrib_values, + 'd|debug' => \$debug, + 'emit_empty_tags' => \$emit_empty_tags, 'f|from|parser:s' => \$from, - 't|to|producer:s' => \$to, + 'fs:s' => \$field_separator, 'h|help' => \$help, + 'imap-file:s' => \$imap_file, + 'imap-url:s' => \$imap_url, + 't|to|producer:s' => \$to, 'l|list' => \$list, - 'd|debug' => \$debug, - 'trace' => \$trace, + 'pretty!' => \$pretty, 'no-comments' => \$no_comments, - 'show-warnings' => \$show_warnings, - 'add-drop-table' => \$add_drop_table, - 'v|validate' => \$validate, - 'no-trim' => \$no_trim, 'no-scan' => \$no_scan, - 'fs:s' => \$field_separator, + 'no-trim' => \$no_trim, 'rs:s' => \$record_separator, - 'imap-file:s' => \$imap_file, - 'imap-url:s' => \$imap_url, - 'pretty!' => \$pretty, + 'show-warnings' => \$show_warnings, 'template:s' => \$template, + 'title:s' => \$title, + 'trace' => \$trace, + 'v|validate' => \$validate, ) or pod2usage(2); -my @files = @ARGV; # the create script(s) for the original db +my @files = @ARGV; # source files pod2usage(1) if $help; -# -# If everything is OK, translate file(s). -# -my $translator = SQL::Translator->new( - debug => $debug || 0, - trace => $trace || 0, - no_comments => $no_comments || 0, - show_warnings => $show_warnings || 0, - add_drop_table => $add_drop_table || 0, - validate => $validate || 0, - parser_args => { +my $translator = SQL::Translator->new( + debug => $debug || 0, + trace => $trace || 0, + no_comments => $no_comments || 0, + show_warnings => $show_warnings || 0, + add_drop_table => $add_drop_table || 0, + validate => $validate || 0, + parser_args => { trim_fields => $no_trim ? 0 : 1, scan_fields => $no_scan ? 0 : 1, field_separator => $field_separator, @@ -100,6 +177,9 @@ my $translator = SQL::Translator->new( imap_url => $imap_url, pretty => $pretty, ttfile => $template, + title => $title, + emit_empty_tags => $emit_empty_tags, + attrib_values => $attrib_values, }, ); @@ -135,79 +215,15 @@ for my $file (@files) { # Henry David Thoreau # ---------------------------------------------------- -=head1 NAME - -sql_translator.pl - convert an SQL database schema - -=head1 SYNOPSIS - -For help: - - ./sql_translator.pl -h|--help - -For a list of all parsers and producers: - - ./sql_translator.pl -l|--list - -To translate a schema: - - ./sql_translator.pl - -f|--from|--parser MySQL - -t|--to|--producer Oracle - [options] - file - - Options: - - -d|--debug Print debug info - -v|--validate Validate the schema - --trace Print parser trace info - --no-comments Don't include comments in SQL output - --show-warnings Print to STDERR warnings of conflicts, etc. - --add-drop-table Add 'drop table' statements before creates - - xSV Options: - - --fs The field separator - --rs The record separator - --no-trim Don't trim whitespace on fields - --no-scan Don't scan fields for data types and sizes - - Diagram Options: - - --imap-file Filename to put image map data - --imap-url URL to use for image map - - HTML Options: - - --pretty Use CGI::Pretty for the outpu - - TTSchema Options: - - --template The path to the template - -=head1 DESCRIPTION - -This script is part of the SQL Fairy project -(http://sqlfairy.sourceforge.net/). It will try to convert any -database syntax for which it has a grammar into some other format it -knows about. - -If using "show-warnings," be sure to redirect STDERR to a separate file. -In bash, you could do this: - - $ sql_translator.pl -f MySQL -t PostgreSQL --show-warnings \ - file.sql 1>out 2>err - -You can specify a parser or producer located in any module that Perl -knows about, allowing you to easily substitute your own. +=pod =head1 AUTHOR -Ken Y. Clark Ekclark@cpan.orgE +Ken Y. Clark Ekclark@cpan.orgE. =head1 SEE ALSO -SQL::Translator. +perl, SQL::Translator, Parse::RecDescent, +L. =cut