From: Tara L Andrews Date: Thu, 2 Feb 2012 20:05:11 +0000 (+0100) Subject: allow db user/pass specification X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7d99d254df992ea1684a983e0f2c68a7ba4ce9d5;p=scpubgit%2Fstemmatology.git allow db user/pass specification --- diff --git a/script/make_tradition.pl b/script/make_tradition.pl index 212edfc..1b184a4 100755 --- a/script/make_tradition.pl +++ b/script/make_tradition.pl @@ -12,9 +12,10 @@ binmode STDERR, ":utf8"; binmode STDOUT, ":utf8"; eval { no warnings; binmode $DB::OUT, ":utf8"; }; -my( $informat, $inbase, $outformat, $help, $linear, $name, $HACK, $sep, $stemmafile, $dsn ) +my( $informat, $inbase, $outformat, $help, $linear, $name, $HACK, $sep, $stemmafile, + $dsn, $dbuser, $dbpass ) = ( '', '', '', '', 1, 'Tradition', 0, "\t", '', - "dbi:SQLite:dbname=stemmaweb/db/traditions.db" ); + "dbi:SQLite:dbname=stemmaweb/db/traditions.db", undef, undef ); GetOptions( 'i|in=s' => \$informat, 'b|base=s' => \$inbase, @@ -23,6 +24,8 @@ GetOptions( 'i|in=s' => \$informat, 'n|name=s' => \$name, 'h|help' => \$help, 's|stemma=s' => \$stemmafile, + 'u|user=s' => \$dbuser, + 'p|pass=s' => \$dbpass, 'sep=s' => \$sep, 'hack' => \$HACK, 'dsn=s' => \$dsn, @@ -91,8 +94,11 @@ if( $outformat eq 'stemma' ) { print STDERR "Bad result: $tree"; } } elsif( $outformat eq 'db' ) { + my $extra_args = { 'create' => 1 }; + $extra_args->{'user'} = $dbuser if $dbuser; + $extra_args->{'password'} = $dbpass if $dbpass; my $dir = Text::Tradition::Directory->new( 'dsn' => $dsn, - 'extra_args' => { 'create' => 1 } ); + 'extra_args' => $extra_args ); my $scope = $dir->new_scope; my $uuid = $dir->store( $tradition ); print STDERR "Saved tradition to database with ID $uuid\n";