R DBI新netezza接口
我正在尝试使用较新的odbc接口为Netezza实现符合DBI的接口 在我尝试之后:R DBI新netezza接口,r,R,我正在尝试使用较新的odbc接口为Netezza实现符合DBI的接口 在我尝试之后: #' Driver for Netezza Db #' @keywords internal #' @export #' @import DBI #' @import methods setClass('NetezzaDriver', contains = 'DBIDriver') #### ------------------------------------------------------------
#' Driver for Netezza Db
#' @keywords internal
#' @export
#' @import DBI
#' @import methods
setClass('NetezzaDriver', contains = 'DBIDriver')
#### -------------------------------------------------------------
#' @export
Netezza <- function() {
new("NetezzaDriver")
}
#### -------------------------------------------------------------
#' Netezza connection class
#' @export
#' @keywords internal
setClass("NetezzaConnection",
contains = "DBIConnection",
slots = list(server = 'character',
database = 'character',
uid = 'character',
pwd = 'character',
port = 'numeric')
)
#### -------------------------------------------------------------
#' dbConnect method for NetezzaDriver
#' @param drv An object created by \code{Netezza()}
#' @rdname Netezza
#' @importFrom odbc dbConnect
#' @export
setMethod("dbConnect", "NetezzaDriver",
function(drv, server ,database ,uid ,pwd ,port = 5480, ...) {
con <- dbConnect(odbc::odbc(),
driver = drv,
server = server,
database = database,
uid = uid,
pwd = pwd,
port = port, ...)
new("NetezzaConnection",
server = server,
database = database,
uid = uid,
pwd = pwd,
port = port,
ptr = ptr)
})
请注意:
db <- dbConnect(odbc::odbc(),
driver = 'Simba',
server = '192.168.69.212',
database = 'NYCFLIGHTS',
uid = 'userR',
pwd = 'userR',
port = 5480)
db
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘dbConnect’ for signature ‘"character"
db <- dbConnect(odbc::odbc(),
driver = 'Simba',
server = '192.168.69.212',
database = 'NYCFLIGHTS',
uid = 'userR',
pwd = 'userR',
port = 5480)