mysql-tutorial.R

Uploaded by:fwild

              library(RMySQL)

db = MySQL()
mycon = dbConnect(db, user='yourusername', dbname='yourusername', host='localhost', password='yourpassword')
rs = dbSendQuery( mycon, "CREATE TABLE terms ( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id), name VARCHAR(255), cluster INT)")
rs = dbSendQuery( mycon, "INSERT into terms(name, cluster) values ('dog', NULL)" )
rs = dbSendQuery( mycon, "INSERT into terms(name, cluster) values ('cat', NULL)" )
rs = dbSendQuery( mycon, "SELECT * from terms") 
data = fetch(rs)

data