美文网首页
R语言驱动Mysql

R语言驱动Mysql

作者: Mylonely | 来源:发表于2020-09-29 07:40 被阅读0次

连接数据库

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 :用户密码
image.png

相关文章

网友评论

      本文标题:R语言驱动Mysql

      本文链接:https://www.haomeiwen.com/subject/vpiduktx.html