From 8a906bfe5632baa263dedcfed2c32c4834890d65 Mon Sep 17 00:00:00 2001 From: elserj Date: Wed, 25 Jan 2012 00:20:51 +0000 Subject: [PATCH] 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 --- interactome_scripts/DbiFloret.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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; -- 2.34.1