Load CSV file data to database(Mysql) in R

Hello All,

This may be quite Insane question to ask here, I am very new to R programming.

I have a csv file named rules.csv , I need to load this into Mysql database. I would like to perform this sql operation in R

Create table Rules as
Data from CSV file;

Hi,

Assuming you are using RMySQL library

mydb = dbConnect(MySQL(),
user=‘user’,
password=’*******’,
dbname=‘somedatabase’,
host=‘127.0.0.1’) #Replace host with your hosted ip

dbWriteTable(mydb,name = “name”,Data1,overwrite=F)

#name is with what name you want to save it
#Data 1 is your csv file loaded as data.frame
#overwrite is used to overwrite an existing file(T for overwrite,F for the opposite)

hope it helps

© Copyright 2013-2020 Analytics Vidhya