我正在尝试使用sf包中的函数st_write将数据写入非公开模式
我无法更改连接数据库的以下方式,因为它将破坏所有其他功能-
create_db_connection <- function(host, dbuser, dbpassword){
drv = RPostgreSQL::PostgreSQL()
DBuser = dbuser
DBhost = host
DBport = "5432"
DBpassword = dbpassword
db = RPostgreSQL::dbConnect(drv, dbname = "DIFM", user = DBuser, host = DBhost, port = DBport, password = DBpassword)
return(db)
}
使用以上连接,我尝试了以下操作-
1. sf::st_write(obj = obj_geom, dsn = db, layer = c(schema_name, "temp_geometrytable"), row.names = FALSE, append = TRUE)
2. sf::st_write(obj = obj_geom, dsn = db, DBI::Id(schema=schema_name, table = "temp_geometrytable"), row.names = FALSE, append = TRUE)
但是所有这些都不断添加到公共模式中,但是我想动态提供模式名称,然后将对象添加到数据库中成为非公共模式