当我尝试通过dbWriteTable将数据从R输出到MySQL时收到以下错误消息:
library(RMySQL)
library(dplyr)
mydb = dbConnect(MySQL(), user='user', password='pass', dbname='testdb', host='localhost')
Tester1 <- dbGetQuery(conn = mydb, statement ="select * from testtable)
Result1 <- Tester1 %>%
group_by(A,B,C,D,E) %>%
mutate(RunningTotal=cumsum(MeasureValue))
dbWriteTable(con=mydb,"testtable2",Result1, row.names=T, overwrite=T)
我在R脚本中写的是:
class Window(Frame):
def load_config(self,obs,wav):
d = json.load(open('config.txt','r'))
self.conf_dict = d[obs][wav]
def save_callback(self,d):
for k,v in l.items():
print(k,v.get())
# save new config file with json
def __init__(self,master,observatory,wavelength):
Frame.__init__(self,master)
self.master = master
self.load_config(observatory,wavelength)
self.elements = {}
for k,v in self.conf_dict.items():
l = Label(master, text=k+':')
l.grid(row=len(self.elements),column=0,padx=10, pady=5)
if isinstance(v,bool):
self.elements[k] = IntVar()
self.elements[k].set(int(v))
c = Checkbutton(master, var=self.elements[k])
c.grid(row=len(self.elements)-1,column=1,padx=10,pady=5)
else:
self.elements[k] = Entry(master)
self.elements[k].insert(END,str(v))
self.elements[k].grid(row=len(self.elements)-1,column=1,padx=10,pady=5)
self.b = Button(master,text='Save',
command=(lambda new_dict=self.elements:self.save_callback(new_dict)))
self.b.grid(row=len(self.elements),column=1,padx=10,pady=5)
谢谢,