dbplyr copy_to不将表保存到数据库 [英] dbplyr copy_to not saving table to database

查看:79
本文介绍了dbplyr copy_to不将表保存到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将本地数据帧从R复制到我的db2数据库.我有权写入该表,并且我已验证连接是否正常工作.

I am trying to copy a local dataframe from R to my db2 database. I have permissions to write to the table and I have verified the connection is working.

我正在使用:

copy_to(connection, data.frame, name = my_table_name)

我收到以下错误,对我来说这没有意义.它说不存在的对象就是我要创建的对象.我在做什么错了?

I am getting the following error and it doesnt make sense to me. The object it says does not exist is the very object I am trying to create. What am I doing wrong?

typeof(x)中的错误:找不到对象"my_table_name"

Error in typeof(x) : object 'my_table_name' not found

推荐答案

默认情况下, copy_to()尝试创建一个临时表.一种选择是添加参数 temporary = FALSE ,以克服 TEMPORARY 令牌错误.更好的解决方案是用于连接的软件包,希望它是 odbc 软件包,用于为其添加对DB2数据库的支持.换句话说, odbc 将需要知道正确创建临时表所需的特定命令是什么.一旦解决, copy_to()将起作用.如果确实使用的是 odbc 软件包,我建议您在该软件包的仓库中打开GitHub问题.

by default, copy_to() tries to create a temporary table. An option is to add the argument temporary = FALSE, to overcome the TEMPORARY token error. A better solution is for the package that you are using to connect, which is hopefully the odbc package, is for it to add support for DB2 databases. In other words, odbc will need to know what is the specific command needed to properly create a temporary table. Once that's fixed, copy_to() will work. If it's indeed the odbc package that you are using, I would recommend that you open a GitHub issue in the package's repo.

这篇关于dbplyr copy_to不将表保存到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆