library(RMySQL)
## Loading required package: DBI
con<-(dbConnect(MySQL(), user="root", password="1234", dbname="flights", host="35.225.71.0"))
dbListFields(con, 'Ratings')
## [1] "Person" "TheLionKing"
## [3] "Avengers_Endgame" "Aladdin"
## [5] "Toy_Story_5" "Spiderman_Homecoming"
## [7] "Godzilla_King_of_the_Monsters"
Mysql<-"Select * from Ratings"
movie_ratings<-dbGetQuery(con, Mysql)
movie_ratings
## Person TheLionKing Avengers_Endgame Aladdin Toy_Story_5
## 1 Tony 5 5 4 4
## 2 Dana 5 5 4 5
## 3 Jimmy 5 5 5 5
## 4 Daniel 3 4 4 4
## 5 Johnny 4 5 4 5
## 6 Lin 4 5 4 5
## Spiderman_Homecoming Godzilla_King_of_the_Monsters
## 1 4 4
## 2 4 3
## 3 5 5
## 4 3 3
## 5 2 5
## 6 4 2
#disconnect from the database
dbDisconnect(con)
## [1] TRUE