R Markdown

Reference: https://www.r-bloggers.com/accessing-mysql-through-r/

#install.packages("RMySQL")
library(RMySQL)
## Warning: package 'RMySQL' was built under R version 3.5.3
## Loading required package: DBI
## Warning: package 'DBI' was built under R version 3.5.3
mydb = dbConnect(MySQL(), user='ajmovieuser', password='', dbname='AjayMovies', host='localhost')

rs = dbSendQuery(mydb, "select m.MovieId, m.MovieName, m.RankingPersonName, m.RankingPersonRelation, m.MovieRank, mr.MovieRankDescription from Movies m inner join MovieRanking mr on (m.MovieRank = mr.MovieRankId) ")

movieranking = fetch(rs, n=-1)
movieranking
##    MovieId         MovieName RankingPersonName RankingPersonRelation
## 1        1          Avengers             Aiden                Nephew
## 2        2           Endgame               Lia                 Neice
## 3        3          The Mule            Lauren                  <NA>
## 4        4            A-Team              Anju                Sister
## 5        5             IpMan              Bill        Brother-in-law
## 6        6           Aquaman             Brian                Friend
## 7        7   Die Another Day             Happy               Brother
## 8        8    Batman & Robin             Bryan                  <NA>
## 9        9    Wild Wild West               Dan        Brother-in-law
## 10      10          Godzilla               Tom        Brother-in-law
## 11      11 Welcome to Marwen            Lauren                Friend
##    MovieRank  MovieRankDescription
## 1          1              Must see
## 2          1              Must see
## 3          3          Passing time
## 4          2                  Good
## 5          2                  Good
## 6          4 Not worth the popcorn
## 7          4 Not worth the popcorn
## 8          5       Save your money
## 9          5       Save your money
## 10         4 Not worth the popcorn
## 11         4 Not worth the popcorn