5 sqlt-dumper - create a dumper script from a schema
9 sqlt-dumper -d Oracle [options] schema.sql > dumper.pl
11 ./dumper.pl > data.sql
15 -h|--help Show help and exit
16 --skip=t1[,t2] Skip tables in comma-separated list
17 --skiplike=regex Skip tables matching the regular expression
18 -u|--user Database username
19 -p|--password Database password
24 This script uses SQL::Translator to parse the SQL schema and create a
25 Perl script that can connect to the database and dump the data as
26 INSERT statements (a la mysqldump) or MySQL's LOAD FILE syntax. You may
27 specify tables to "skip" (also using a "skiplike" regular expression)
28 and the generated dumper script will not have those tables. However,
29 these will also be options in the generated dumper, so you can wait to
30 specify these options when you dump your database. The database
31 username, password, and DSN can be hardcoded into the generated
32 script, or part of the DSN can be intuited from the "database"
37 # -------------------------------------------------------------------
44 use File::Basename qw(basename);
49 my ( $help, $db, $skip, $skiplike, $db_user, $db_pass, $dsn );
52 'd|f|from|db=s' => \$db,
54 'skiplike:s' => \$skiplike,
55 'u|user:s' => \$db_user,
56 'p|password:s' => \$db_pass,
60 pod2usage(0) if $help;
61 pod2usage( 'No database driver specified' ) unless $db;
62 $db_user ||= 'username';
63 $db_pass ||= 'password';
66 my $file = shift @ARGV or pod2usage( -msg => 'No input file' );
67 my $t = SQL::Translator->new(
72 skiplike => $skiplike,
74 db_password => $db_pass,
79 print $t->translate( $file );
83 # -------------------------------------------------------------------
89 Ken Youens-Clark E<lt>kclark@cpan.orgE<gt>.
93 perl, SQL::Translator, SQL::Translator::Producer::Dumper.