查询postgresql数据库:
代码:
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, dbname="BDDMeteo", user=user, password="zina",host='localhost', port='5432')
#selection
cluster1=dbGetQuery(con,"select station.lon,station.lat from station where station.cluster=1")
#insertion
req=paste("INSERT INTO important (num_cluster,type,indicateur_imp) VALUES (1,'temperature',2)")
resultat=sqlQuery(con,req)
如何选择好,但是对于插入,他向我发送了以下错误:
Error in sqlQuery(con, req) : first argument is not an open RODBC channel
请帮忙吗?
答案 0 :(得分:1)
您在VALUES Clause
req=paste("INSERT INTO Important (Num_cluster,Type,Indicateur_impt) VALUES (1,'temperature','Imp1')")
resultat=sqlQuery(con,req)