I have a dataframe that I would like to upload to a cloud environment. Im already connected to the database and now would like to "write away" the records.
I have a dataframe that looks like this:
#df
a b
1 3 11
2 4 12
And try to add it to the table "team" on the server like this:
#connect to database (conection is called "con")
for (i in nrow(df)){
var1 <- df$a[i]
var2 <- df$b[i]
players_home <- dbGetQuery(con, "INSERT INTO team VALUES (var1, var2)")
}
This however gives me the following error:
Error in .local(conn, statement, ...) :
could not run statement: Unknown column 'var1' in 'field list'
Any thoughts on how I can get this working?