如何解决此错误--dbWriteTable() [英] How to resolve this error--dbWriteTable()

查看:294
本文介绍了如何解决此错误--dbWriteTable()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已成功连接到MYSQL DB,并尝试将结果写回数据库:dbWriteTable(con,"predicted min",forecast$min),其中Forecast $ min仅是double的向量.

I successfully connected to MYSQL DB and tried to write my result back to the database: dbWriteTable(con,"predicted min",forecast$min) where forecast$min is just a vector of doubles.

我收到此错误消息:

错误(函数(类,fdef,mtable)): 无法为签名" MySQLConnection",字符",数字""的函数"dbWriteTable"找到继承的方法

Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘dbWriteTable’ for signature ‘"MySQLConnection", "character", "numeric"’

我想我的第三个参数需要一个数据框对象,因此我尝试了以下操作:dbWriteTable(con,"predicted min",data.frame(min=forecast0.1$min))

I guess I need a dataframe object for my third parameter, so then I tried this: dbWriteTable(con,"predicted min",data.frame(min=forecast0.1$min))

但是出现此错误:

.local(conn,statement,...)中的错误: 无法运行语句:您的SQL语法有错误;检查与您的MariaDB服务器版本相对应的手册,以获取在'(<row_names文本附近使用正确的语法, min双 )"位于第2行

Error in .local(conn, statement, ...) : could not run statement: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '( row_names text, min double )' at line 2

我正在使用SQLyog.我不知道这是否与此问题有关.有什么建议?预先感谢.

I'm using SQLyog. I don't know if that's related to this problem. Any suggestions? Thanks in advance.

苏菲

推荐答案

SQLyog与此问题无关.如果您的表只有一列(最小),则无需将数据帧的行名写入表中.试试:

SQLyog is not related to this issue. If your table only has one column (min), then you need not write the row names of the dataframe to the table. Try:

dbWriteTable(con,"predicted min",data.frame(min=forecast0.1$min), row.names = FALSE, append = TRUE)

否则,您正在将具有两个值的元组插入具有一列的表中.如果该表已经存在,并且您不想覆盖该表,则还应该具有append = TRUE.

Or else you're inserting a tuple with with two values into a table with one column. If the table already exists and you don't want to overwrite the table, you should also have append = TRUE.

编辑:表名中不能有空格.

edit: The table name should not have a space in it.

这篇关于如何解决此错误--dbWriteTable()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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