为什么不能将dbWriteTable用于SQL Server? [英] Why can I not use dbWriteTable for SQL Server?
本文介绍了为什么不能将dbWriteTable用于SQL Server?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道如果要改变某些东西可以破坏它吗?还是我想念什么?
Does anyone know if something would have changed to break it? or am I missing something?
data <- data.frame(x = rnorm(10), y = rnorm(10))
cxn <- DBI::dbConnect(odbc::odbc(),
driver = 'ODBC Driver 17 for SQL Server',
server = dbServer,
database = dbName,
trusted_connection = 'yes',
port = port)
DBI::dbWriteTable(cxn, tblName, data, append = T)
我遇到以下错误:
错误(函数(类,fdef,mtable)):无法找到签名" Microsoft的函数"dbWriteTable"的继承方法SQL Server",字符",列表""
Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘dbWriteTable’ for signature ‘"Microsoft SQL Server", "character", "list"’
这是我的会话信息:
R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] DBI_1.0.0 magrittr_1.5 lubridate_1.7.4 data.table_1.12.2
[5] sloop_1.0.1 forcats_0.4.0 stringr_1.4.0 dplyr_0.8.3
[9] purrr_0.3.2 readr_1.3.1 tidyr_0.8.3 tibble_2.1.3
[13] ggplot2_3.1.1 tidyverse_1.2.1 vctrs_0.2.0 devtools_2.0.2
[17] usethis_1.5.1 conflicted_1.0.4
loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 lattice_0.20-38 prettyunits_1.0.2 ps_1.3.0
[5] assertthat_0.2.1 zeallot_0.1.0 rprojroot_1.3-2 digest_0.6.20
[9] R6_2.4.0 cellranger_1.1.0 plyr_1.8.4 odbc_1.1.6
[13] backports_1.1.4 httr_1.4.0 pillar_1.4.2 rlang_0.4.0
[17] lazyeval_0.2.2 readxl_1.3.1 rstudioapi_0.10 callr_3.2.0
[21] blob_1.1.1 desc_1.2.0 bit_1.1-14 munsell_0.5.0
[25] broom_0.5.2 compiler_3.6.2 modelr_0.1.4 pkgconfig_2.0.2
[29] pkgbuild_1.0.3 tidyselect_0.2.5 audio_0.1-6 crayon_1.3.4
[33] withr_2.1.2 grid_3.6.2 nlme_3.1-142 jsonlite_1.6
[37] gtable_0.3.0 scales_1.0.0 cli_1.1.0 stringi_1.4.3
[41] fs_1.3.1 remotes_2.0.4 testthat_2.1.1 xml2_1.2.0
[45] generics_0.0.2 tools_3.6.2 bit64_0.9-7 glue_1.3.1
[49] hms_0.4.2 processx_3.3.1 pkgload_1.0.2 colorspace_1.4-1
[53] sessioninfo_1.1.1 rvest_0.3.3 memoise_1.1.0 beepr_1.3
[57] haven_2.1.0
推荐答案
最近我遇到了类似的问题.
Recently I had similar issue.
问题描述:MS Server数据库带有方案.任务是将R data.frame对象保存到预定义的数据库表,而不会删除.
Problem description: MS Server data base with scheme. The task is to save an R data.frame object to a predefined data base table without dropping it.
我遇到的问题:
- 某些软件包功能不支持方案或需要安装github开发版本
- 您只能在 drop (删除表)操作(我只需要清除表"操作)之后保存data.frame
- Some packages functions does not support schemes or require github development version installation
- You can save data.frame only after drop (delete table) operation (I needed just "clear table" operation)
我如何解决此问题
- Using simple RODBC::sqlQuery, writing a data.frame row by row.
- The solution (couple of functions) is available here or here
这篇关于为什么不能将dbWriteTable用于SQL Server?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文