From: tla Date: Wed, 2 May 2012 22:31:29 +0000 (+0200) Subject: allow dbuser/pass specification X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a7f70834da6b7ade42f3c356e436b31216eafa0e;p=scpubgit%2Fstemmatology.git allow dbuser/pass specification --- diff --git a/script/dblookup.pl b/script/dblookup.pl index a7a6c4d..bcf21d9 100755 --- a/script/dblookup.pl +++ b/script/dblookup.pl @@ -11,17 +11,22 @@ use Text::Tradition::Directory; binmode( STDOUT, ':utf8' ); binmode( STDERR, ':utf8' ); -my( $name, $delete, $list, $dsn ) = - ( undef, undef, 1, 'dbi:SQLite:dbname=db/traditions.db' ); +my( $name, $delete, $dbuser, $dbpass ); +my( $list, $dsn ) = ( 1, 'dbi:SQLite:dbname=db/traditions.db' ); GetOptions( 'r|rename=s' => \$name, 'd|delete' => \$delete, 'dsn=s' => \$dsn, + 'u|user=s' => \$dbuser, + 'p|pass=s' => \$dbpass, ); my @uuids = @ARGV; # UUID is whatever is left over -my $kdb = Text::Tradition::Directory->new( 'dsn' => $dsn ); +my %dbargs = ( 'dsn' => $dsn ); +$dbargs{'extra_args'} = { 'user' => $dbuser } if $dbuser; +$dbargs{'extra_args'}->{'password'} = $dbpass if $dbpass; +my $kdb = Text::Tradition::Directory->new( %dbargs ); $list = !$delete; if( $delete ) {