I have some tables in my database that i am trying to populate with data that i have stored in R using library(RmySQL). I am trying to send a dataframe of courses to a table named courses in the column course_names. Here is the code and mySQL functions I have been trying but none seem to work, although using dbWriteTable worked for a new table i called 'test', i want to send the data to a table that already exists.
ieCourses <- read.csv('IECourses.csv')
query <- "INSERT INTO courses(course_name) VALUES(ieCourses);" # This is wrong
rs <- dbSendQuery(mydb, query) # I feel this is the function to use but getting errors
dbWriteTable(mydb, 'courses', ieCourses,overwrite=TRUE)
This is one of the errors i keep getting ... Error in .local(conn, statement, ...) : could not run statement: Cannot delete or update a parent row: a foreign key constraint fails