我正在开发一个闪亮的应用程序,用户可以上传csv文件然后将其推送到mysql数据库。我正在使用RMysql包来执行此任务。
db <- dbConnect(MySQL(), dbname = databaseName, host = host,
port = port, user = user, password = password)
dbSendQuery(db,"CREATE TABLE IF NOT EXISTS web_domain (
domain_name VARCHAR(60) DEFAULT NULL,
create_date DATE DEFAULT NULL,
expiry_date DATE DEFAULT NULL,
registrant_name VARCHAR(70) DEFAULT NULL,
registrant_company VARCHAR(100) DEFAULT NULL,
registrant_address VARCHAR(200) DEFAULT NULL,
registrant_city VARCHAR(70) DEFAULT NULL,
registrant_state VARCHAR(70) DEFAULT NULL,
registrant_zip VARCHAR(70) DEFAULT NULL,
registrant_country VARCHAR(70) DEFAULT NULL,
registrant_email VARCHAR(30) DEFAULT NULL,
registrant_phone VARCHAR(12) DEFAULT NULL,
email VARCHAR(70) DEFAULT NULL,
domain VARCHAR(20) DEFAULT NULL,
domain_company VARCHAR(30) DEFAULT NULL,
reg_years VARCHAR(12) DEFAULT NULL
)"
)
首先我在mysql中创建一个表结构。我的csv文件也具有与表模式完全相同的列名。当我尝试上传csv文件时,它会给我以下错误。
Warning: Closing open result sets
Listening on http://127.0.0.1:5044
Warning in if (!is.na(attribValue)) { :
the condition has length > 1 and only the first element will be used
Warning in charToRaw(enc2utf8(text)) :
argument should be a character vector of length 1
all but the first element will be ignored
Warning in if (!is.na(attribValue)) { :
the condition has length > 1 and only the first element will be used
Warning in charToRaw(enc2utf8(text)) :
argument should be a character vector of length 1
all but the first element will be ignored
Warning: Closing open result sets
Warning: Error in .local: could not run statement: Unknown column 'row_names' in 'field list'
Stack trace (innermost first):
74: .local
73: dbSendQuery
72: dbSendQuery
71: dbGetQuery
70: dbGetQuery
69: .local
68: dbWriteTable
67: dbWriteTable
66: saveData [functions.R#109]
65: observeEventHandler [E:\R Project\TITBIT\Titbit_Dash/server.R#61]
1: runApp
ERROR: [on_request_read] connection reset by peer
我无法弄清楚unknown column row_names
中field_list
的含义是什么,我想在每次用户上传新的csv文件时附加来自csv文件的数据。
请帮忙。