我的data表位于MariaDB实例下的AWS中,如下所示:
| id | first | second | third | fourth | fifth | sixth |
|----|-------|--------|-------|--------|-------|-------|
| 3 | foo | foo | foo | foo | 1 | foo |
| 4 | foo | foo | foo | foo | 2 | foo |
| 5 | bar | foo | bar | foo | 3 | bar |
| 6 | bar | bar | bar | bar | 4 | bar |
| 7 | bar | bar | bar | bar | 5 | bar |更新或删除查询无法生成所需的输出,而不返回任何错误:
con <- dbConnect(RMariaDB::MariaDB(), group = "aws-rds")
dbSendQuery(con, statement = "UPDATE data SET second = 'bar' WHERE id = 4;")
dbDisconnect(con)返回:
SQL更新数据集第二= 'bar‘,其中id = 4;行取:0完全更改:1
但是,该表似乎没有变化,因为在其中读取它会返回原始表:
con <- dbConnect(RMariaDB::MariaDB(), group = "aws-rds")
data.tbl <- dbReadTable(con, "data") %>% as_tibble()
dbDisconnect(con)
data.tbl返回:
| id | first | second | third | fourth | fifth | sixth |
|----|-------|--------|-------|--------|-------|-------|
| 3 | foo | foo | foo | foo | 1 | foo |
| 4 | foo | foo | foo | foo | 2 | foo |
| 5 | bar | foo | bar | foo | 3 | bar |
| 6 | bar | bar | bar | bar | 4 | bar |
| 7 | bar | bar | bar | bar | 5 | bar |我遗漏了什么?
发布于 2019-09-19 17:01:46
来自?dbSendQuery
此方法仅用于SELECT查询。出于兼容性原因,某些后端可能通过此方法支持数据操作查询。但是,强烈鼓励调用者使用dbSendStatement()来处理数据操作语句。
尝试使用dbSendStatement。
https://stackoverflow.com/questions/50190675
复制相似问题