Commit | Line | Data |
16dc9970 |
1 | #!/usr/bin/perl -w |
2 | |
3 | #----------------------------------------------------- |
4 | # $Id: sql_translator.pl,v 1.1.1.1 2002-03-01 02:26:25 kycl4rk Exp $ |
5 | # |
6 | # File : sql_translator.pl |
7 | # Programmer : Ken Y. Clark, kclark@logsoft.com |
8 | # Created : 2002/02/27 |
9 | # Purpose : invoke SQL::Translator |
10 | #----------------------------------------------------- |
11 | |
12 | use strict; |
13 | use Getopt::Long; |
14 | use Pod::Usage; |
15 | use SQL::Translator; |
16 | use vars qw( $VERSION ); |
17 | $VERSION = (qw$Revision: 1.1.1.1 $)[-1]; |
18 | |
19 | my $from; # the original database |
20 | my $to; # the destination database |
21 | my $help; # show POD and bail |
22 | my $stdin; # whether to read STDIN for create script |
23 | my $no_comments; # whether to put comments in out file |
24 | my $verbose; # whether to print progress/debug |
25 | |
26 | # |
27 | # Get options, explain how to use the script if necessary. |
28 | # |
29 | GetOptions( |
30 | 'f|from=s' => \$from, |
31 | 't|to=s' => \$to, |
32 | 'h|help' => \$help, |
33 | 'v|verbose' => \$verbose, |
34 | 'no_comments' => \$no_comments, |
35 | ) or pod2usage(2); |
36 | |
37 | my @files = @ARGV; # the create script for the original db |
38 | |
39 | pod2usage(1) if $help; |
40 | pod2usage(2) unless $from && $to && @files; |
41 | |
42 | # |
43 | # If everything is OK, translate file(s). |
44 | # |
45 | my $translator = SQL::Translator->new; |
46 | my $output = $translator->translate( |
47 | from => $from, |
48 | to => $to, |
49 | input => \@files, |
50 | verbose => $verbose, |
51 | no_comments => $no_comments, |
52 | ) or die "Error: " . $translator->error; |
53 | print "Output:\n", $output; |
54 | |
55 | #----------------------------------------------------- |
56 | # It is not all books that are as dull as their readers. |
57 | # Henry David Thoreau |
58 | #----------------------------------------------------- |
59 | |
60 | =head1 NAME |
61 | |
62 | sql_translator.pl - convert schema to Oracle syntax |
63 | |
64 | =head1 SYNOPSIS |
65 | |
66 | ./sql_translator.pl -h|--help |
67 | |
68 | ./sql_translator.pl -f|--from mysql -t|--to oracle [options] file |
69 | |
70 | Options: |
71 | |
72 | -v|--verbose Print debug info to STDERR |
73 | --no-comments Don't include comments in SQL output |
74 | |
75 | =head1 DESCRIPTION |
76 | |
77 | Part of the SQL Fairy project (sqlfairy.sourceforge.net), this script |
78 | will try to convert any database syntax for which it has a grammar |
79 | into some other format will accept. |
80 | |
81 | =head1 AUTHOR |
82 | |
83 | Ken Y. Clark, kclark@logsoft.com |
84 | |
85 | =head1 SEE ALSO |
86 | |
87 | perl(1), SQL::Transport. |
88 | |
89 | =cut |