From: elserj Date: Wed, 25 Jan 2012 00:20:51 +0000 (+0000) Subject: Added dbconnect_auto subroutine to allow for db connection with supplied credentials... X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=8a906bfe5632baa263dedcfed2c32c4834890d65;p=old-jaiswallab-svn%2F.git Added dbconnect_auto subroutine to allow for db connection with supplied credentials, instead of asking for them. Take care to only use in case of pulling credentials from external file (not in svn) svn path=/; revision=276 --- diff --git a/interactome_scripts/DbiFloret.pm b/interactome_scripts/DbiFloret.pm index b99a56b..a4dc781 100755 --- a/interactome_scripts/DbiFloret.pm +++ b/interactome_scripts/DbiFloret.pm @@ -24,6 +24,21 @@ sub dbconnect { return $dbh; } + +sub dbconnect_auto { + my $self =@_; + + my $username = $_[0]; + my $password = $_[1]; + my $database = $_[2]; + + my $dbh = DBI->connect("DBI:mysql:$database;host=floret.cgrb.oregonstate.edu", $username, $password, + { RaiseError=> 1, AutoCommit=>1 } + ) or die "Failed to connect to database: $DBI::errstr"; + + + return $dbh; +} return 1;