Reputation: 387
queries a postgresql database:
code:
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)
for how to select good, but for the insertion he sends me the following error:
Error in sqlQuery(con, req) : first argument is not an open RODBC channel
help please?
Upvotes: 0
Views: 758
Reputation: 8517
You missed brackets after VALUES Clause
req=paste("INSERT INTO Important (Num_cluster,Type,Indicateur_impt) VALUES (1,'temperature','Imp1')")
resultat=sqlQuery(con,req)
Upvotes: 1