Re: [R-pkg-devel] Weird error message during R CMD Check

2018-03-15 Thread Michael Nelson
', pathtocsvloader, " ", connectionString, " ", sql_task, " ", 
real_pathtocsvfile, " ", "null", sep = "")

  # Call shell command

  oldw <- getOption("warn")

  options(warn = -1)

  sc <- shell(ss)

  if (file.exists(file_to_be_deleted)){

    out <- data.table::fread(file_to_be_deleted, stringsAsFactors = FALSE, sep 
= "~", fill = TRUE)

  } else{

options(warn = oldw)

stop('See the previous messages for more details.')

  }

  # Delete csv file

  if (file.exists(file_to_be_deleted)){

invisible(file.remove(file_to_be_deleted))

  } else{

options(warn = oldw)

stop('See the previous messages for more details.')

  }

  if( sc == 1 ) {

options(warn = oldw)

stop('See the previous messages for more details.')

  } else {

options(warn = oldw)

  }

  return(out)

}



-Původní zpráva-
Od: Duncan Murdoch mailto:murdoch.dun...@gmail.com>>
Odesláno: 13 March 2018 23:22
Komu: martiank...@gmail.com<mailto:martiank...@gmail.com>; 
r-package-devel-boun...@r-project.org<mailto:r-package-devel-boun...@r-project.org>
Kopie: r-package-devel@r-project.org<mailto:r-package-devel@r-project.org>
Předmět: Re: [R-pkg-devel] Weird error message during R CMD Check


On 13/03/2018 4:53 PM,  <mailto:martiank...@gmail.com> 
martiank...@gmail.com<mailto:martiank...@gmail.com> wrote:

Hello,
  I'm trying to submit my package to CRAN but receiving the following
error message.
  object 'connectionString' not found

Your example never defined a variable called connectionString, so you can't 
pass it to a function.


Duncan Murdoch


  even if it is parameter of get_DB_info(connectionString) function -
see the function definition below error message.
  Please, can you help me to understand what should be fixed in the code
so that I could successfully submit my package to CRAN?
  Thanks a lot for any of your help in advance.
  Best,
Martin
<https://win-builder.r-project.org/incoming_pretest/180313_212715_RSQLS> 
https://win-builder.r-project.org/incoming_pretest/180313_212715_RSQLS
_16/00
check.log
* checking examples ...
** running examples for arch 'i386' ... ERROR
Running examples in 'RSQLS-Ex.R' failed
The error most likely occurred in:

base::assign(".ptime", proc.time(), pos = "CheckExEnv")
### Name: get_DB_info
### Title: Get database info
### Aliases: get_DB_info
### ** Examples
get_DB_info(connectionString)
Error in paste("", pathtocsvloader, " ", connectionString, " ", sql_task,  :
   object 'connectionString' not found
Calls: get_DB_info -> paste
Execution halted
** running examples for arch 'x64' ... ERROR
Running examples in 'RSQLS-Ex.R' failed
The error most likely occurred in:

base::assign(".ptime", proc.time(), pos = "CheckExEnv")
### Name: get_DB_info
### Title: Get database info
### Aliases: get_DB_info
### ** Examples
get_DB_info(connectionString)
Error in paste("", pathtocsvloader, " ", connectionString, " ", sql_task,  :
   object 'connectionString' not found
Calls: get_DB_info -> paste
Execution halted
* checking PDF version of manual ... OK
* DONE
Status: 2 ERRORs, 3 WARNINGs, 4 NOTEs
   get_DB_info(connectionString)

  #' Get database info
#'
#' This function retrieves basic info about database defined
#' in SQL Server connection string.
#' @param connectionString Connection string to SQL server
#' @return Returns data.frame and data.table
#' @export
#' @examples
#' get_DB_info(connectionString)
#' @note How to set up SQL Server connection string see
\link{set_connString}. Be also sure you have a permissions for access
to
sys.dm_db_index_usage_stats:
#' check it with SELECT * FROM sys.dm_db_index_usage_stats. If not,
contact your SQL Server admin.
get_DB_info <- function(connectionString) {
   options(scipen=999)
   if (missing(connectionString)) {
 print("Connection string is missing!")
 return("Try it again")
   }
   pathtocsvloader <- gsub("/","",paste(system.file(package =
"RSQLS")[1],"/Loader/csv_to_sql_loader.exe", sep = ""))
   pathtocsvloader <- replace_spaced_words(pathtocsvloader)
   pathtocsvloader <- gsub('.{1}$', '', pathtocsvloader)
   # logic for pathtocsvfiles variable
   pathtocsvfiles <- gsub("/","",paste(system.file(package =
"RSQLS")[1],"/Data/", sep = ""))
   if (!endsWith(pathtocsvfiles, "\\")) {
 pathtocsvfiles <- paste(pathtocsvfiles,"\\", sep = "

Re: [R-pkg-devel] Weird error message during R CMD Check

2018-03-15 Thread martiankabe
Thank you very much Michael, this perfectly works.

Martin

 

Od: Michael Nelson  
Odesláno: 15 March 2018 07:43
Komu: martiank...@gmail.com; r-package-devel@r-project.org
Předmět: Re: [R-pkg-devel] Weird error message during R CMD Check

 

I don’t think the suggestion below will work as it would need to be a 
connection string to a database that the winbuilder computer (and whatever 
account) that is running would have access to. 

 

It would be better to use \dontrun{} so that the examples aren’t run. 

 

This is what is done in RODBC 
https://cran.r-project.org/web/packages/RODBC/index.html 

 

More fundamentally, given   the cran repository policy on windows only 
packages, CRAN may not be the appropriate place to publish. 

 

Michael. 


On 15 Mar 2018, at 8:41 am, Marcelino de la Cruz Rot 
mailto:marcelino.delac...@urjc.es> > wrote:

It is very easy. You should define your variable connectionString before 
passing it to get_DB_info().

I.e.:

### ** Examples

connectionString <- WHATEVER_IS_CONNECTIONSTRING

get_DB_info(connectionString)


This would remove your error.

Cheers,

Marcelino.




El 14/03/2018 a las 22:15, martiank...@gmail.com <mailto:martiank...@gmail.com> 
 escribió:



Hi Duncan,

 

 

could you help me fix this issue, please?

 

 

Below is function which creates connection string.

 

 

#' Create connection string from function parameters

 

#'

 

#' This function defines SQL Server connection string

 

#' from function parameters.

 

#' @param datasource Server name

 

#' @param database Database name

 

#' @param usr Username

 

#' @param pwd Password

 

#' @note If username and password missing or empty \strong{Integrated 
Security=True} is used in connection string instead.

 

#' @return Connection string

 

#' @export

 

#' @examples

 

#' set_connString("LAPTOP-USER\\SQLEXPRESS", "Database_Name")

 

set_connString <- function(datasource, database, usr, pwd) {

 

  ds <- paste("Data Source=", datasource, ";", sep = "")

 

  db <- paste("Initial Catalog=", database, ";", sep = "")

 

  if ((missing(usr) & missing(pwd)) || (usr=="" & pwd=="")) {

 

last_param <- "Integrated Security=True;MultipleActiveResultSets=True;"

 

  } else {

 

last_param <- paste("Integrated Security=False;", "User Id=", usr, ";", 
"Password=", pwd, ";", "MultipleActiveResultSets=True;", sep = "")

 

  }

 

  return(paste('"', ds, db, last_param, '"', sep = ""))

 

}

 

 

This connection string is then passed to get_DB_info function – see below.

 

 

How can I fix object ‘connectionString’ not found issue?

 

 

Thank you for any of your advice.

 

Martin

 

 

#' Get database info

 

#'

 

#' This function retrieves basic info about database defined

 

#' in SQL Server connection string.

 

#' @param connectionString Connection string to SQL server

 

#' @return Returns data.frame and data.table

 

#' @export

 

#' @examples

 

#' get_DB_info(connectionString)

 

#' @note How to set up SQL Server connection string see \link{set_connString}. 
Be also sure you have a permissions for access to sys.dm_db_index_usage_stats:

 

#' check it with SELECT * FROM sys.dm_db_index_usage_stats. If not, contact 
your SQL Server admin.

 

 

get_DB_info <- function(connectionString) {

 

  options(scipen=999)

 

  if (missing(connectionString)) {

 

print("Connection string is missing!")

 

return("Try it again")

 

  }

 

  # connectionString <- connectionString

 

  pathtocsvloader <- gsub("/","",paste(system.file(package = 
"RSQLS")[1],"/Loader/csv_to_sql_loader.exe", sep = ""))

 

  pathtocsvloader <- replace_spaced_words(pathtocsvloader)

 

  pathtocsvloader <- gsub('.{1}$', '', pathtocsvloader)

 

  # logic for pathtocsvfiles variable

 

  pathtocsvfiles <- gsub("/","",paste(system.file(package = 
"RSQLS")[1],"/Data/", sep = ""))

 

  if (!endsWith(pathtocsvfiles, "\\")) {

 

pathtocsvfiles <- paste(pathtocsvfiles,"\\", sep = "")

 

  }

 

  sqltabname <- "tempDBInfo"

 

  sqltabname <- gsub("\\[|\\]", "", sqltabname)

 

  if (length(strsplit(sqltabname,"\\.  ")[[1]]) > 1) {

 

sqltabname_prev <- gsub("^[^.]*.", "", sqltabname)

 

  } else {

 

sqltabname_prev <- sqltabname

 

  }

 

  sql_tab_name <- paste('"', sqltabname, '"', sep = "

Re: [R-pkg-devel] Weird error message during R CMD Check

2018-03-14 Thread Marcelino de la Cruz Rot
It is very easy. You should define your variable connectionString before 
passing it to get_DB_info().


I.e.:

### ** Examples

connectionString <- WHATEVER_IS_CONNECTIONSTRING

get_DB_info(connectionString)


This would remove your error.

Cheers,

Marcelino.




El 14/03/2018 a las 22:15, martiank...@gmail.com escribió:

Hi Duncan,

  


could you help me fix this issue, please?

  


Below is function which creates connection string.

  


#' Create connection string from function parameters

#'

#' This function defines SQL Server connection string

#' from function parameters.

#' @param datasource Server name

#' @param database Database name

#' @param usr Username

#' @param pwd Password

#' @note If username and password missing or empty \strong{Integrated 
Security=True} is used in connection string instead.

#' @return Connection string

#' @export

#' @examples

#' set_connString("LAPTOP-USER\\SQLEXPRESS", "Database_Name")

set_connString <- function(datasource, database, usr, pwd) {

   ds <- paste("Data Source=", datasource, ";", sep = "")

   db <- paste("Initial Catalog=", database, ";", sep = "")

   if ((missing(usr) & missing(pwd)) || (usr=="" & pwd=="")) {

 last_param <- "Integrated Security=True;MultipleActiveResultSets=True;"

   } else {

 last_param <- paste("Integrated Security=False;", "User Id=", usr, ";", "Password=", pwd, ";", 
"MultipleActiveResultSets=True;", sep = "")

   }

   return(paste('"', ds, db, last_param, '"', sep = ""))

}

  


This connection string is then passed to get_DB_info function – see below.

  


How can I fix object ‘connectionString’ not found issue?

  


Thank you for any of your advice.

Martin

  


#' Get database info

#'

#' This function retrieves basic info about database defined

#' in SQL Server connection string.

#' @param connectionString Connection string to SQL server

#' @return Returns data.frame and data.table

#' @export

#' @examples

#' get_DB_info(connectionString)

#' @note How to set up SQL Server connection string see \link{set_connString}. 
Be also sure you have a permissions for access to sys.dm_db_index_usage_stats:

#' check it with SELECT * FROM sys.dm_db_index_usage_stats. If not, contact 
your SQL Server admin.

  


get_DB_info <- function(connectionString) {

   options(scipen=999)

   if (missing(connectionString)) {

 print("Connection string is missing!")

 return("Try it again")

   }

   # connectionString <- connectionString

   pathtocsvloader <- gsub("/","",paste(system.file(package = 
"RSQLS")[1],"/Loader/csv_to_sql_loader.exe", sep = ""))

   pathtocsvloader <- replace_spaced_words(pathtocsvloader)

   pathtocsvloader <- gsub('.{1}$', '', pathtocsvloader)

   # logic for pathtocsvfiles variable

   pathtocsvfiles <- gsub("/","",paste(system.file(package = "RSQLS")[1],"/Data/", 
sep = ""))

   if (!endsWith(pathtocsvfiles, "\\")) {

 pathtocsvfiles <- paste(pathtocsvfiles,"\\", sep = "")

   }

   sqltabname <- "tempDBInfo"

   sqltabname <- gsub("\\[|\\]", "", sqltabname)

   if (length(strsplit(sqltabname,"\\.")[[1]]) > 1) {

 sqltabname_prev <- gsub("^[^.]*.", "", sqltabname)

   } else {

 sqltabname_prev <- sqltabname

   }

   sql_tab_name <- paste('"', sqltabname, '"', sep = "") # 
'"dbo.CFTC_Disaggregated_Raw_test"'

   sql_task <- paste('"dbinfo"', sep = "")

   real_pathtocsvfile <- paste('"', pathtocsvfiles, paste(sqltabname_prev, ".csv", sep = 
""),'"', sep = "")

   file_to_be_deleted <- paste(pathtocsvfiles, paste(sqltabname_prev, ".csv", sep = ""), 
sep = "")

   ss <- paste('', pathtocsvloader, " ", connectionString, " ", sql_task, " ", real_pathtocsvfile, " 
", "null", sep = "")

   # Call shell command

   oldw <- getOption("warn")

   options(warn = -1)

   sc <- shell(ss)

   if (file.exists(file_to_be_deleted)){

 out <- data.table::fread(file_to_be_deleted, stringsAsFactors = FALSE, sep = 
"~", fill = TRUE)

   } else{

 options(warn = oldw)

 stop('See the previous messages for more details.')

   }

   # Delete 

Re: [R-pkg-devel] Weird error message during R CMD Check

2018-03-14 Thread martiankabe
Hi Duncan,

 

could you help me fix this issue, please?

 

Below is function which creates connection string.

 

#' Create connection string from function parameters

#'

#' This function defines SQL Server connection string

#' from function parameters.

#' @param datasource Server name

#' @param database Database name

#' @param usr Username

#' @param pwd Password

#' @note If username and password missing or empty \strong{Integrated 
Security=True} is used in connection string instead.

#' @return Connection string

#' @export

#' @examples

#' set_connString("LAPTOP-USER\\SQLEXPRESS", "Database_Name")

set_connString <- function(datasource, database, usr, pwd) {

  ds <- paste("Data Source=", datasource, ";", sep = "")

  db <- paste("Initial Catalog=", database, ";", sep = "")

  if ((missing(usr) & missing(pwd)) || (usr=="" & pwd=="")) {

last_param <- "Integrated Security=True;MultipleActiveResultSets=True;"

  } else {

last_param <- paste("Integrated Security=False;", "User Id=", usr, ";", 
"Password=", pwd, ";", "MultipleActiveResultSets=True;", sep = "")

  }

  return(paste('"', ds, db, last_param, '"', sep = ""))

}

 

This connection string is then passed to get_DB_info function – see below.

 

How can I fix object ‘connectionString’ not found issue?

 

Thank you for any of your advice.

Martin

 

#' Get database info

#'

#' This function retrieves basic info about database defined

#' in SQL Server connection string.

#' @param connectionString Connection string to SQL server

#' @return Returns data.frame and data.table

#' @export

#' @examples

#' get_DB_info(connectionString)

#' @note How to set up SQL Server connection string see \link{set_connString}. 
Be also sure you have a permissions for access to sys.dm_db_index_usage_stats:

#' check it with SELECT * FROM sys.dm_db_index_usage_stats. If not, contact 
your SQL Server admin.

 

get_DB_info <- function(connectionString) {

  options(scipen=999)

  if (missing(connectionString)) {

print("Connection string is missing!")

return("Try it again")

  }

  # connectionString <- connectionString

  pathtocsvloader <- gsub("/","",paste(system.file(package = 
"RSQLS")[1],"/Loader/csv_to_sql_loader.exe", sep = ""))

  pathtocsvloader <- replace_spaced_words(pathtocsvloader)

  pathtocsvloader <- gsub('.{1}$', '', pathtocsvloader)

  # logic for pathtocsvfiles variable

  pathtocsvfiles <- gsub("/","",paste(system.file(package = 
"RSQLS")[1],"/Data/", sep = ""))

  if (!endsWith(pathtocsvfiles, "\\")) {

pathtocsvfiles <- paste(pathtocsvfiles,"\\", sep = "")

  }

  sqltabname <- "tempDBInfo"

  sqltabname <- gsub("\\[|\\]", "", sqltabname)

  if (length(strsplit(sqltabname,"\\.")[[1]]) > 1) {

sqltabname_prev <- gsub("^[^.]*.", "", sqltabname)

  } else {

sqltabname_prev <- sqltabname

  }

  sql_tab_name <- paste('"', sqltabname, '"', sep = "") # 
'"dbo.CFTC_Disaggregated_Raw_test"'

  sql_task <- paste('"dbinfo"', sep = "")

  real_pathtocsvfile <- paste('"', pathtocsvfiles, paste(sqltabname_prev, 
".csv", sep = ""),'"', sep = "")

  file_to_be_deleted <- paste(pathtocsvfiles, paste(sqltabname_prev, ".csv", 
sep = ""), sep = "")

  ss <- paste('', pathtocsvloader, " ", connectionString, " ", sql_task, " ", 
real_pathtocsvfile, " ", "null", sep = "")

  # Call shell command

  oldw <- getOption("warn")

  options(warn = -1)

  sc <- shell(ss)

  if (file.exists(file_to_be_deleted)){

out <- data.table::fread(file_to_be_deleted, stringsAsFactors = FALSE, sep 
= "~", fill = TRUE)

  } else{

options(warn = oldw)

stop('See the previous messages for more details.')

  }

  # Delete csv file

  if (file.exists(file_to_be_deleted)){

invisible(file.remove(file_to_be_deleted))

  } else{

options(warn = oldw)

stop('See the previous messages for more details.')

  }

  if( sc == 1 ) {

options(warn = oldw)

stop('See the previous messages for more details.')

  } else {

options(warn = oldw)

  }

  return(out)

}

 

 

-P

Re: [R-pkg-devel] Weird error message during R CMD Check

2018-03-13 Thread Duncan Murdoch

On 13/03/2018 4:53 PM, martiank...@gmail.com wrote:

Hello,

  


I'm trying to submit my package to CRAN but receiving the following error
message.

  


object 'connectionString' not found


Your example never defined a variable called connectionString, so you 
can't pass it to a function.


Duncan Murdoch



  


even if it is parameter of get_DB_info(connectionString) function - see the
function definition below error message.

  


Please, can you help me to understand what should be fixed in the code so
that I could successfully submit my package to CRAN?

  


Thanks a lot for any of your help in advance.

  


Best,

Martin

  


https://win-builder.r-project.org/incoming_pretest/180313_212715_RSQLS_16/00
check.log

* checking examples ...

** running examples for arch 'i386' ... ERROR

Running examples in 'RSQLS-Ex.R' failed

The error most likely occurred in:

  


base::assign(".ptime", proc.time(), pos = "CheckExEnv")



### Name: get_DB_info



### Title: Get database info



### Aliases: get_DB_info







### ** Examples







get_DB_info(connectionString)


Error in paste("", pathtocsvloader, " ", connectionString, " ", sql_task,  :


   object 'connectionString' not found

Calls: get_DB_info -> paste

Execution halted

** running examples for arch 'x64' ... ERROR

Running examples in 'RSQLS-Ex.R' failed

The error most likely occurred in:

  


base::assign(".ptime", proc.time(), pos = "CheckExEnv")



### Name: get_DB_info



### Title: Get database info



### Aliases: get_DB_info







### ** Examples







get_DB_info(connectionString)


Error in paste("", pathtocsvloader, " ", connectionString, " ", sql_task,  :


   object 'connectionString' not found

Calls: get_DB_info -> paste

Execution halted

* checking PDF version of manual ... OK

* DONE

Status: 2 ERRORs, 3 WARNINGs, 4 NOTEs

  


 get_DB_info(connectionString)


  


#' Get database info

#'

#' This function retrieves basic info about database defined

#' in SQL Server connection string.

#' @param connectionString Connection string to SQL server

#' @return Returns data.frame and data.table

#' @export

#' @examples

#' get_DB_info(connectionString)

#' @note How to set up SQL Server connection string see
\link{set_connString}. Be also sure you have a permissions for access to
sys.dm_db_index_usage_stats:

#' check it with SELECT * FROM sys.dm_db_index_usage_stats. If not, contact
your SQL Server admin.

get_DB_info <- function(connectionString) {

   options(scipen=999)

   if (missing(connectionString)) {

 print("Connection string is missing!")

 return("Try it again")

   }

   pathtocsvloader <- gsub("/","",paste(system.file(package =
"RSQLS")[1],"/Loader/csv_to_sql_loader.exe", sep = ""))

   pathtocsvloader <- replace_spaced_words(pathtocsvloader)

   pathtocsvloader <- gsub('.{1}$', '', pathtocsvloader)

   # logic for pathtocsvfiles variable

   pathtocsvfiles <- gsub("/","",paste(system.file(package =
"RSQLS")[1],"/Data/", sep = ""))

   if (!endsWith(pathtocsvfiles, "\\")) {

 pathtocsvfiles <- paste(pathtocsvfiles,"\\", sep = "")

   }

   sqltabname <- "tempDBInfo"

   sqltabname <- gsub("\\[|\\]", "", sqltabname)

   if (length(strsplit(sqltabname,"\\.")[[1]]) > 1) {

 sqltabname_prev <- gsub("^[^.]*.", "", sqltabname)

   } else {

 sqltabname_prev <- sqltabname

   }

   sql_tab_name <- paste('"', sqltabname, '"', sep = "") #
'"dbo.CFTC_Disaggregated_Raw_test"'

   sql_task <- paste('"dbinfo"', sep = "")

   real_pathtocsvfile <- paste('"', pathtocsvfiles, paste(sqltabname_prev,
".csv", sep = ""),'"', sep = "")

   file_to_be_deleted <- paste(pathtocsvfiles, paste(sqltabname_prev, ".csv",
sep = ""), sep = "")

   ss <- paste('', pathtocsvloader, " ", connectionString, " ", sql_task, "
", real_pathtocsvfile, " ", "null", sep = "")

   # Call shell command

   oldw <- getOption("warn")

   options(warn = -1)

   sc <- shell(ss)

   if (file.exists(file_to_be_deleted)){

 out <- data.table::fread(file_to_be_deleted, stringsAsFactors = FALSE,
sep = "~", fill = TRUE)

   } else{

 options(warn = oldw)

 stop('See the previous messages for more details.')

   }

   # Delete csv file

   if (file.exists(file_to_be_deleted)){

 invisible(file.remove(file_to_be_deleted))

   } else{

 options(warn = oldw)

 stop('See the previous messages for more details.')

   }

   if( sc == 1 ) {

 options(warn = oldw)

 stop('See the previous messages for more details.')

   } else {

 options(warn = oldw)

   }

   return(out)

}

  




---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel



__

[R-pkg-devel] Weird error message during R CMD Check

2018-03-13 Thread martiankabe
Hello,

 

I'm trying to submit my package to CRAN but receiving the following error
message.

 

object 'connectionString' not found

 

even if it is parameter of get_DB_info(connectionString) function - see the
function definition below error message.

 

Please, can you help me to understand what should be fixed in the code so
that I could successfully submit my package to CRAN?

 

Thanks a lot for any of your help in advance.

 

Best,

Martin

 

https://win-builder.r-project.org/incoming_pretest/180313_212715_RSQLS_16/00
check.log

* checking examples ...

** running examples for arch 'i386' ... ERROR

Running examples in 'RSQLS-Ex.R' failed

The error most likely occurred in:

 

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")

> ### Name: get_DB_info

> ### Title: Get database info

> ### Aliases: get_DB_info

> 

> ### ** Examples

> 

> get_DB_info(connectionString)

Error in paste("", pathtocsvloader, " ", connectionString, " ", sql_task,  :


  object 'connectionString' not found

Calls: get_DB_info -> paste

Execution halted

** running examples for arch 'x64' ... ERROR

Running examples in 'RSQLS-Ex.R' failed

The error most likely occurred in:

 

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")

> ### Name: get_DB_info

> ### Title: Get database info

> ### Aliases: get_DB_info

> 

> ### ** Examples

> 

> get_DB_info(connectionString)

Error in paste("", pathtocsvloader, " ", connectionString, " ", sql_task,  :


  object 'connectionString' not found

Calls: get_DB_info -> paste

Execution halted

* checking PDF version of manual ... OK

* DONE

Status: 2 ERRORs, 3 WARNINGs, 4 NOTEs

 

 get_DB_info(connectionString)


 

#' Get database info

#'

#' This function retrieves basic info about database defined

#' in SQL Server connection string.

#' @param connectionString Connection string to SQL server

#' @return Returns data.frame and data.table

#' @export

#' @examples

#' get_DB_info(connectionString)

#' @note How to set up SQL Server connection string see
\link{set_connString}. Be also sure you have a permissions for access to
sys.dm_db_index_usage_stats:

#' check it with SELECT * FROM sys.dm_db_index_usage_stats. If not, contact
your SQL Server admin.

get_DB_info <- function(connectionString) {

  options(scipen=999)

  if (missing(connectionString)) {

print("Connection string is missing!")

return("Try it again")

  }

  pathtocsvloader <- gsub("/","",paste(system.file(package =
"RSQLS")[1],"/Loader/csv_to_sql_loader.exe", sep = ""))

  pathtocsvloader <- replace_spaced_words(pathtocsvloader)

  pathtocsvloader <- gsub('.{1}$', '', pathtocsvloader)

  # logic for pathtocsvfiles variable

  pathtocsvfiles <- gsub("/","",paste(system.file(package =
"RSQLS")[1],"/Data/", sep = ""))

  if (!endsWith(pathtocsvfiles, "\\")) {

pathtocsvfiles <- paste(pathtocsvfiles,"\\", sep = "")

  }

  sqltabname <- "tempDBInfo"

  sqltabname <- gsub("\\[|\\]", "", sqltabname)

  if (length(strsplit(sqltabname,"\\.")[[1]]) > 1) {

sqltabname_prev <- gsub("^[^.]*.", "", sqltabname)

  } else {

sqltabname_prev <- sqltabname

  }

  sql_tab_name <- paste('"', sqltabname, '"', sep = "") #
'"dbo.CFTC_Disaggregated_Raw_test"'

  sql_task <- paste('"dbinfo"', sep = "")

  real_pathtocsvfile <- paste('"', pathtocsvfiles, paste(sqltabname_prev,
".csv", sep = ""),'"', sep = "")

  file_to_be_deleted <- paste(pathtocsvfiles, paste(sqltabname_prev, ".csv",
sep = ""), sep = "")

  ss <- paste('', pathtocsvloader, " ", connectionString, " ", sql_task, "
", real_pathtocsvfile, " ", "null", sep = "")

  # Call shell command

  oldw <- getOption("warn")

  options(warn = -1)

  sc <- shell(ss)

  if (file.exists(file_to_be_deleted)){

out <- data.table::fread(file_to_be_deleted, stringsAsFactors = FALSE,
sep = "~", fill = TRUE)

  } else{

options(warn = oldw)

stop('See the previous messages for more details.')

  }

  # Delete csv file

  if (file.exists(file_to_be_deleted)){

invisible(file.remove(file_to_be_deleted))

  } else{

options(warn = oldw)

stop('See the previous messages for more details.')

  }

  if( sc == 1 ) {

options(warn = oldw)

stop('See the previous messages for more details.')

  } else {

options(warn = oldw)

  }

  return(out)

}

 



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel