1

我正在使用包中的in_schema()函数dbplyr在 R 的 postgresql 数据库的命名模式中创建一个表。

它不是一段新代码,它曾经按预期工作=在模式“my_schema”中创建一个名为“my_table”的表。

con <- dbConnect(odbc::odbc(), 
                 driver = "PostgreSQL Unicode", 
                 server = "server", 
                 port = 5432, 
                 uid = "user name", 
                 password = "password", 
                 database = "dbase")

dbWriteTable(con,
             in_schema('my_schema', 'my_table'),
             value = whatever) # assume that 'whatever' is a data frame...

这段代码现在出现了问题,并且意外地开始在我的数据库的默认公共方案中创建一个名为“my_scheme.my_table”的表,而不是预期的 my_schema.my_table。

有没有其他人注意到这种行为,是否有解决方案(使用默认的 postgresql 方案除外,这在我的情况下不实用)?

4

1 回答 1

0

为此,我建议使用copy_to()而不是dbWriteTable()copy_to(con, iris, in_schema("production", "iris"))

于 2018-09-22T21:22:11.463 回答