3 # -------------------------------------------------------------------
4 # Copyright (C) 2002-2009 SQLFairy Authors
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation; version 2.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 # -------------------------------------------------------------------
23 sqlt-dumper - create a dumper script from a schema
27 sqlt-dumper -d Oracle [options] schema.sql > dumper.pl
29 ./dumper.pl > data.sql
33 -h|--help Show help and exit
34 --skip=t1[,t2] Skip tables in comma-separated list
35 --skiplike=regex Skip tables matching the regular expression
36 -u|--user Database username
37 -p|--password Database password
42 This script uses SQL::Translator to parse the SQL schema and create a
43 Perl script that can connect to the database and dump the data as
44 INSERT statements (a la mysqldump) or MySQL's LOAD FILE syntax. You may
45 specify tables to "skip" (also using a "skiplike" regular expression)
46 and the generated dumper script will not have those tables. However,
47 these will also be options in the generated dumper, so you can wait to
48 specify these options when you dump your database. The database
49 username, password, and DSN can be hardcoded into the generated
50 script, or part of the DSN can be intuited from the "database"
55 # -------------------------------------------------------------------
62 use File::Basename qw(basename);
67 my ( $help, $db, $skip, $skiplike, $db_user, $db_pass, $dsn );
70 'd|f|from|db=s' => \$db,
72 'skiplike:s' => \$skiplike,
73 'u|user:s' => \$db_user,
74 'p|password:s' => \$db_pass,
78 pod2usage(0) if $help;
79 pod2usage( 'No database driver specified' ) unless $db;
80 $db_user ||= 'username';
81 $db_pass ||= 'password';
84 my $file = shift @ARGV or pod2usage( -msg => 'No input file' );
85 my $t = SQL::Translator->new(
90 skiplike => $skiplike,
92 db_password => $db_pass,
97 print $t->translate( $file );
101 # -------------------------------------------------------------------
107 Ken Youens-Clark E<lt>kclark@cpan.orgE<gt>.
111 perl, SQL::Translator, SQL::Translator::Producer::Dumper.