我正在尝试执行代码:
连接到服务器
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/lPPmS8yeP9w和https://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
答案 0 :(得分:0)
根据我所知,函数postgresqlUnescapeBytea
仅适用于RpostgreSQL
软件包的开发版本,可在此处下载:https://github.com/codeinthehole/rpostgresql