连接数据库
con1<-dbConnect(MySQL(),host='localhost',dbname="mysqlexample01",
port=3306,user = 'xyy',password="xyy19940428")
sel1 <-"SELECT Dates ,user_id,pay_price,avg_online_minutes,pvp_battle_count,pvp_lanch_count,
pvp_win_count,pve_battle_count FROM tapfun ;"
tib1 <- dbGetQuery(con1,sel1) %>% as_tibble()
head(tib1,6)
dbConnect :传入链接数据库的参数
dbGetQuery: 两个参数,分别是链接,查询语句
- host :服务器名称
- port : 服务器端口
- dbname :数据库名称
- user :用户名
- password :用户密码
![](https://img.haomeiwen.com/i10153870/453e318753c09ffc.png)
网友评论