From: tla Date: Tue, 4 Sep 2012 09:40:06 +0000 (+0200) Subject: allow for DB username/password passing X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2f3eb3e0ee207b331d4567562b98a66e57cc43e1;p=scpubgit%2Fstemmatology.git allow for DB username/password passing --- diff --git a/script/admin_users.pl b/script/admin_users.pl index a532f0d..ca5cd91 100755 --- a/script/admin_users.pl +++ b/script/admin_users.pl @@ -13,11 +13,13 @@ use lib 'lib'; use Text::Tradition::Directory; my ($dsn, $command) = ('dbi:SQLite:dbname=stemmaweb/db/traditions.db', 'add'); -my ($username, $password, $tradition_id, $rolename); +my ($username, $password, $tradition_id, $rolename, $dbuser, $dbpass); GetOptions( 'c|command:s' => \$command, 'dsn:s' => \$dsn, + 'dbuser=s' => \$dbuser, + 'dbpass=s' => \$dbpass, 'u|username=s' => \$username, 'p|password:s' => \$password, 't|tradition:s' => \$tradition_id, @@ -34,8 +36,11 @@ if(!$username) { usage(); } -# my $userstore = Text::Tradition::UserStore->new( dsn => $dsn); -my $userstore = Text::Tradition::Directory->new( dsn => $dsn); +my %connect_args = ( dsn => $dsn ); +if( $dbuser || $dbpass ) { + $connect_args{extra_args} = { user => $dbuser, password => $dbpass }; +} +my $userstore = Text::Tradition::Directory->new( %connect_args ); my $new_scope = $userstore->new_scope; given ($command) {