# vim: set ft=perl:
# -------------------------------------------------------------------
-# $Id: sqlt,v 1.20 2006-02-22 17:03:57 kycl4rk Exp $
+# $Id$
# -------------------------------------------------------------------
-# Copyright (C) 2002-4 SQLFairy Authors
+# Copyright (C) 2002-2009 SQLFairy Authors
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
--trace Print parser trace info
--show-warnings Print warnings to STDERR
+ General Parser Options:
+
+ --skip Comma-separated list of tables to skip (only implemented in some parsers)
+ --ignore_opts Comma-separated list of table options to ignore
+
DBI Parser Options:
--dsn DSN for connecting to database
--no-trim Don't trim whitespace on fields
--no-scan Don't scan fields for data types and sizes
+ MySQL Parser Options:
+
+ --mysql-parser-version Target MySQL parser version for dealing with
+ /*! comments; default = 30000
+
+ MySQL Producer Options:
+
+ --mysql-version MySQL server version
+
General Producer Options
--producer-db-user Database user for producer
DB Producer Options:
--add-drop-table Add 'DROP TABLE' statements before creates
+ --quote-table-names Quote all table names in statements
+ --quote-field-names Qjuote all field names in statements
--no-comments Don't include comments in SQL output
+ PostgreSQL Producer Options:
+
+ --postgres-version PostgreSQL server version
+
Diagram Producer Options:
--imap-file Filename to put image map data
use SQL::Translator;
use vars qw( $VERSION );
-$VERSION = sprintf "%d.%02d", q$Revision: 1.20 $ =~ /(\d+)\.(\d+)/;
+$VERSION = '1.99';
my $from; # the original database
my $to; # the destination database
my $stdin; # whether to read STDIN for create script
my $no_comments; # whether to put comments in out file
my $show_warnings; # whether to show warnings from SQL::Translator
-my $add_drop_table; # whether to show warnings from SQL::Translator
+my $add_drop_table; # whether to add "DROP table" statements
+my $quote_table_names; # whether to quote table names
+my $quote_field_names; # whether to quote field names
my $debug; # whether to print debug info
my $trace; # whether to print parser trace
my $list; # list all parsers and producers
my $show_version; # Show version and exit script
my $skip;
my $skiplike;
+my $ignore_opts;
my $producer_db_user; # DSN for producer (e.g. Dumper, ClassDBI)
my $producer_db_password; # db_pass "
my $producer_dsn; # db_user "
my $add_truncate;
+my $mysql_parser_version; # MySQL parser arg for /*! comments
+my $postgres_version; # PostgreSQL version
+my $mysql_version; # MySQL version
GetOptions(
'add-drop-table' => \$add_drop_table,
+ 'quote_table_names' => \$quote_table_names,
+ 'quote_field_names' => \$quote_field_names,
'd|debug' => \$debug,
'f|from|parser:s' => \$from,
'fs:s' => \$field_separator,
'producer-db-pass:s'=> \$producer_db_password,
'skip:s' => \$skip,
'skiplike:s' => \$skiplike,
+ 'ignore_opts:s' => \$ignore_opts,
'add_truncate' => \$add_truncate,
'add-prefix' => \$add_prefix,
'prefix:s' => \$prefix,
'package=s' => \$package_name,
'use-same-auth' => \$use_same_auth,
'version' => \$show_version,
+ 'mysql-parser-version=i' => \$mysql_parser_version,
+ 'postgres-version=f' => \$postgres_version,
+ 'mysql-version=f' => \$mysql_version,
) or pod2usage(2);
if ($use_same_auth) {
no_comments => $no_comments || 0,
show_warnings => $show_warnings || 0,
add_drop_table => $add_drop_table || 0,
+ quote_table_names => $quote_table_names || 1,
+ quote_field_names => $quote_field_names || 1,
validate => $validate || 0,
parser_args => {
trim_fields => $no_trim ? 0 : 1,
dsn => $dsn,
db_user => $db_user,
db_password => $db_password,
+ mysql_parser_version => $mysql_parser_version,
+ skip => $skip,
+ ignore_opts => $ignore_opts,
},
producer_args => {
imap_file => $imap_file,
prefix => $prefix,
indent => $indent,
newlines => $newlines,
+ postgres_version => $postgres_version,
+ mysql_version => $mysql_version,
package_name => $package_name,
},
);