【发布时间】:2022-01-13 04:51:57
【问题描述】:
我正在尝试在 R 中使用 PostgreSQL 的大对象 (https://www.postgresql.org/docs/10/largeobjects.html) 功能,但在使用 {DBI}/{RPostgres} 进行读写时遇到了一些问题。
这是我迄今为止尝试过的:
# Getting the db
docker run --rm --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5433:5432 postgres
library(DBI)
con <- dbConnect(
RPostgres::Postgres(),
dbname = "postgres",
host = "localhost",
port = 5433,
user = "postgres",
password = "mysecretpassword"
)
创作作品:
> dbGetQuery(con, "SELECT lo_create(1234);")
lo_create
1 1234
但是我很难弄清楚如何将 R 对象写入这个大对象。
例如,如何在 Postgres 中使用 {DBI} 和 {RPostgres} 将 mtcars 写为大对象?
然后,我如何在 R 中再次读回它?
【问题讨论】:
标签: r postgresql rpostgresql