0

我正在尝试执行代码:

连接到服务器

library('RPostgreSQL', quietly = TRUE)
kHostName  <- '...'
kPort      <- '5432'
kDBName    <- '...'
kUser      <- '...'
kPassword  <- '...'

drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv,
                 host      = kHostName,
                 port      = kPort,
                 dbname    = kDBName,
                 user      = kUser,
                 password  = kPassword)

以下部分代码取自https://groups.google.com/forum/#!topic/rpostgresql-dev/lPPmS8yeP9whttps://github.com/codeinthehole/rpostgresql/blob/master/RPostgreSQL/tests /bytea.R

dbGetQuery(con,"CREATE TABLE byteatable (name text NOT NULL, val bytea, 
PRIMARY KEY (name))") 
sample.object <- list("one","two"); 
ser <- serialize(sample.object,NULL,ascii=F); 
postgresqlEscapeBytea(con, ser) 
iq <- sprintf("INSERT INTO byteatable values('%s',E'%s');","name1", postgresqlEscapeBytea(con, ser)) 
dbGetQuery(con, iq) 
rows<-dbGetQuery(con, "SELECT * from byteatable") 
ser2<-postgresqlUnescapeBytea(rows[[2]])

它返回:

Error: could not find function "postgresqlEscapeBytea"

我怎样才能让它工作?

我用:

> version
               _                           
platform       x86_64-apple-darwin13.4.0   
arch           x86_64                      
os             darwin13.4.0                
system         x86_64, darwin13.4.0        
status                                     
major          3                           
minor          3.0                         
year           2016                        
month          05                          
day            03                          
svn rev        70573                       
language       R                           
version.string R version 3.3.0 (2016-05-03)
nickname       Supposedly Educational
4

1 回答 1

0

据我所知,该功能postgresqlUnescapeBytea仅在包的开发版本中可用,可以在这里下载: https ://github.com/codeinthehole/rpostgresqlRpostgreSQL

于 2017-02-28T12:11:47.987 回答