Skip to content

Commit

Permalink
Merge pull request #4 from jozef/master
Browse files Browse the repository at this point in the history
#! && --help
  • Loading branch information
happy-barney committed Jun 22, 2012
2 parents 4883ab1 + 28cbb5a commit 3c5a36c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
30 changes: 29 additions & 1 deletion bin/sql-admin.pl
@@ -1,3 +1,4 @@
#!/usr/bin/env perl

use strict;
use warnings;
Expand Down Expand Up @@ -29,6 +30,8 @@

sub main { # ;
my $action = shift @ARGV;
pod2usage('Unknown action '.$action)
unless $action && exists $action_map{$action};
my $factory = SQL::Admin->new;

my $key_alias = {
Expand All @@ -41,15 +44,20 @@ sub main { # ;
GetOptions (
my $params = {},

'help|h',
'source|src|s=s',
'destination|dest|dst|d=s',
'output|out|o=s',
'schema_only|schema-only|schema=s@',
);
pod2usage if $params->{help};

my @def = ();
for my $key (grep $params->{$_}, keys %$key_alias) {
for my $option ($factory->get_driver ($params->{$key})->options) {
my $driver = $factory->get_driver ($params->{$key});
pod2usage('No such driver '.$params->{$key}) unless $driver;

for my $option ($driver->options) {
my ($names, $def) = split /(?=[=])/, $option, 2;

my @names;
Expand Down Expand Up @@ -160,3 +168,23 @@ =head1 SYNOPSIS
sql-admin <action> --source <source driver> <source driver parameters>
--destination <destination driver> <destination driver parameters>
--output <output driver> <output driver parameters>
<action> - dump or compare
<* driver> - Pg or DB2
when connecting to the database Pg::DBI or DB2::DBI
Examples:
sql-admin.pl dump --source Pg::DBI \
'--source-dbdsn=dbi:Pg:dbname=some_name;host=localhost' \
--source-dbusr username \
--source-dbpwd password \
--output Pg
sql-admin.pl compare
--source Pg::DBI \
'--source-dbdsn=dbi:Pg:dbname=some_name;host=localhost' \
--source-dbusr username \
--source-dbpwd password \
--destination Pg \
--source-file create.sql \
--output Pg
2 changes: 1 addition & 1 deletion lib/SQL/Admin/Driver/Base/DBI.pm
Expand Up @@ -25,7 +25,7 @@ sub new { # ;
######################################################################
sub options { # ;
(
'dbdns=s',
'dbdsn=s',
'dbusr=s',
'dbpwd=s',
);
Expand Down
3 changes: 3 additions & 0 deletions lib/SQL/Admin/Driver/Pg/DBI.pm
Expand Up @@ -27,6 +27,9 @@ our %TYPE_MAP = (
date => 'date',
time => 'time',
timestamp => 'timestamp',
timestamptz => 'timestamptz',
text => 'text',
bool => 'bool',
);

our %TYPE_WITH_SIZE = (
Expand Down
2 changes: 1 addition & 1 deletion lib/SQL/Admin/Driver/Pg/Grammar.pm
Expand Up @@ -40,7 +40,7 @@ sql_command :
| create_table
| statement_insert
# | connect_to
# | create_sequence
| create_sequence
# | create_view
# | comment_on
# | COMMIT WORK { +{ commit_work => 1 } }
Expand Down

0 comments on commit 3c5a36c

Please sign in to comment.