library(RMySQL)
## Warning: package 'RMySQL' was built under R version 4.0.3
## Loading required package: DBI
mysqlconnection = dbConnect(MySQL(), user = 'root', password = 'root', dbname = 'student', host = 'localhost')
dbListTables(mysqlconnection)
## [1] "student_table"
result = dbSendQuery(mysqlconnection, "select * from student_table")
data.frame = fetch(result)
print(data.frame)
## SID Firstname Lastname score gpa probability
## 1 1 Ben Hebbel 91 3.1 0.2
## 2 2 Dylan Nasser 93 3.1 0.3
## 3 3 Bob Smith 83 3.5 0.5
## 4 4 John Doe 95 3.1 1.0
## 5 5 Jane Doe 98 3.7 0.3
## 6 6 Jack Ryan 98 3.7 0.7
## 7 7 John Wick 98 3.7 0.4
## 8 8 Bruce Wayne 93 3.5 0.5
## 9 9 Bruce Willis 85 3.4 0.6
## 10 10 Brad Pit 80 2.7 0.6
## 11 11 Clark Kent 84 2.8 0.6
result = dbSendQuery(mysqlconnection, "select * from student_table where score > 90")
data.frame = fetch(result)
print(data.frame)
## SID Firstname Lastname score gpa probability
## 1 1 Ben Hebbel 91 3.1 0.2
## 2 2 Dylan Nasser 93 3.1 0.3
## 3 4 John Doe 95 3.1 1.0
## 4 5 Jane Doe 98 3.7 0.3
## 5 6 Jack Ryan 98 3.7 0.7
## 6 7 John Wick 98 3.7 0.4
## 7 8 Bruce Wayne 93 3.5 0.5
#result = dbSendQuery(mysqlconnection, "insert into student_table(SID, Firstname, Lastname, score, gpa, probability) values(11, 'Clark', 'Kent', 84, 2.8, 0.6)")
#data.frame = fetch(result)
#print(data.frame)
result = dbSendQuery(mysqlconnection, "select * from student_table")
data.frame = fetch(result)
print(data.frame)
## SID Firstname Lastname score gpa probability
## 1 1 Ben Hebbel 91 3.1 0.2
## 2 2 Dylan Nasser 93 3.1 0.3
## 3 3 Bob Smith 83 3.5 0.5
## 4 4 John Doe 95 3.1 1.0
## 5 5 Jane Doe 98 3.7 0.3
## 6 6 Jack Ryan 98 3.7 0.7
## 7 7 John Wick 98 3.7 0.4
## 8 8 Bruce Wayne 93 3.5 0.5
## 9 9 Bruce Willis 85 3.4 0.6
## 10 10 Brad Pit 80 2.7 0.6
## 11 11 Clark Kent 84 2.8 0.6
result = dbSendQuery(mysqlconnection, "select * from student_table where probability > 0.5")
data.frame = fetch(result)
print(data.frame)
## SID Firstname Lastname score gpa probability
## 1 4 John Doe 95 3.1 1.0
## 2 6 Jack Ryan 98 3.7 0.7
## 3 9 Bruce Willis 85 3.4 0.6
## 4 10 Brad Pit 80 2.7 0.6
## 5 11 Clark Kent 84 2.8 0.6
#This finds the most likely candidates that will find a job.