[Rodbcext-commits] r10 - in pkg/rodbcExt: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Mar 12 10:17:25 CET 2009
Author: jaunario
Date: 2009-03-12 10:17:25 +0100 (Thu, 12 Mar 2009)
New Revision: 10
Modified:
pkg/rodbcExt/R/connectExt.R
pkg/rodbcExt/man/connectExt.Rd
Log:
Added interval option to set a time before the function retries to connect to the database.
Modified: pkg/rodbcExt/R/connectExt.R
===================================================================
--- pkg/rodbcExt/R/connectExt.R 2009-03-03 03:51:51 UTC (rev 9)
+++ pkg/rodbcExt/R/connectExt.R 2009-03-12 09:17:25 UTC (rev 10)
@@ -3,7 +3,7 @@
# Version 0.1.1
# License GPL3
-dsnConnect <- function(dsn, retries=3, ...){
+dsnConnect <- function(dsn, retries=3, interval=60, ...){
cnt <- 0
repeat {
cnt<-cnt+1
@@ -16,13 +16,15 @@
cat("Unable to connect to database on ",dsn,". \n", sep="")
return(NULL)
stop();
- }
+ } else{
+ Sys.sleep(interval*cnt)
+ }
rm(con)
cat("Retrying to connect. (retries=",retries,") \n", sep="")
}
}
-drvConnect <- function(drvname, server, db, usr, pwd, opt=27, retries=3, ...){
+drvConnect <- function(drvname, server, db, usr, pwd, opt=27, retries=3, interval=60, ...){
cstring <- paste("DRIVER={",drvname,"};SERVER=",server,";DATABASE=",db,";USER=",usr,";PASSWORD=",pwd,";OPTION=",opt,";", sep="")
cnt <- 0
repeat {
@@ -36,7 +38,9 @@
cat("Unable to connect to database on ",server,". \n", sep="")
return(NULL)
stop();
- }
+ } else{
+ Sys.sleep(interval*cnt)
+ }
rm(con)
cat("Retrying to connect. (retries=",retries,") \n", sep="")
}
Modified: pkg/rodbcExt/man/connectExt.Rd
===================================================================
--- pkg/rodbcExt/man/connectExt.Rd 2009-03-03 03:51:51 UTC (rev 9)
+++ pkg/rodbcExt/man/connectExt.Rd 2009-03-12 09:17:25 UTC (rev 10)
@@ -7,8 +7,8 @@
Functions for connecting to databases with automatic retry capability
}
\usage{
-dsnConnect(dsn, retries=3, ...)
-drvConnect(drvname, server, db, usr, pwd, opt=27, retries=3, ...)
+dsnConnect(dsn, retries=3, interval=60, ...)
+drvConnect(drvname, server, db, usr, pwd, opt=27, retries=3, interval=60, ...)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
@@ -20,6 +20,7 @@
\item{pwd}{ ~~Describe \code{fact} here~~ }
\item{opt}{ ~~Describe \code{fact} here~~ }
\item{retries}{ ~~Describe \code{fact} here~~ }
+ \item{interval}{ ~~Describe \code{fact} here~~ }
\item{...}{ ~~Describe \code{fact} here~~ }
}
More information about the Rodbcext-commits
mailing list