> install.packages("RMySQL")
also installing the dependency ‘DBI’ trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/DBI_0.6-1.zip'
Content type 'application/zip' length bytes ( KB)
downloaded KB trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/RMySQL_0.10.11.zip'
Content type 'application/zip' length bytes (2.2 MB)
downloaded 2.2 MB package ‘DBI’ successfully unpacked and MD5 sums checked
package ‘RMySQL’ successfully unpacked and MD5 sums checked The downloaded binary packages are in
C:\Users\fangping\AppData\Local\Temp\Rtmp4OKUkD\downloaded_packages
> library(RMySQL)
载入需要的程辑包:DBI
> help(package=”RMySQL”) #查看RMySQL的说明文档,里面有RMySQL所有可用的方法
Error: unexpected input in "help(package=?
> #创建数据库连接
> con <- dbConnect(MySQL(),host="localhost",dbname="test2",user="root",password="xinwei")
> #获取连接信息,查看database下所有表,以及删除testname表
> summary(con)
<MySQLConnection:,>
User: root
Host: localhost
Dbname: test2
Connection type: localhost via TCP/IP Results:
> dbGetInfo(con)
$host
[] "localhost" $user
[] "root" $dbname
[] "test2" $conType
[] "localhost via TCP/IP" $serverVersion
[] "5.6.36" $protocolVersion
[] $threadId
[] $rsId
list() > dbListTables(con)
[] "data_category_url" "demo" "tb_common_biz"
[] "tb_data_createtime" "tb_data_privilege" "test_event"
[] "xw_sequence"
>     #读数据库表(show tables);
       dbListTables(con)
    #读数据库表
    > dbReadTable(con,"xixi")
    #写数据库表  
    fruits <-data.frame(id=1:3,create_time=c("2017-05-03 16:11:40","2017-05-03 16:11:41","2017-05-03 16:11:42"),privilege_person=c(0,1,2),person_or_role=c(1,2,3),is_creator=c(1,2,3),data_id=c(20170512001,20170512002,2017051200))  
    dbListTables(con)  
    dbWriteTable(con,"fruits",fruits)  
    dbListTables(con)
> dbReadTable(con,"xixi")
id create_time privilege_person person_or_role is_creator data_id
1 1 2017-05-03 16:11:40 0 1 1 20170512001
2 2 2017-05-03 16:11:41 1 2 2 20170512002
3 3 2017-05-03 16:11:42 2 3 3 2017051200
> dbListTables(con)
[1] "data_category_url" "demo" "fruits" "tb_common_biz"
[5] "tb_data_createtime" "tb_data_privilege" "test_event" "xixi"
[9] "xw_sequence"

最新文章

  1. CLR和.Net对象生存周期
  2. 优化php代码 - 字符串echo输出 逗号也可作php连接符
  3. [DFNews] Fire-Eye与Fox IT联合推出Cryptolocker解锁网站
  4. GOF业务场景的设计模式-----责任链模式
  5. 基础向量运算-2D镜面反射
  6. mysql聚合函数
  7. scala-spark练手--dataframe数据可视化初稿
  8. C#中A a=new B()的意义
  9. c++,内联成员函数
  10. php 图片压缩处理
  11. 防止多个UIAlertView重叠弹出
  12. Firebug控制台详解,让调试js代码变得更简单
  13. STL sort函数的用法
  14. shiro权限控制(二):分布式架构中shiro的实现
  15. Linux显示工作路径
  16. 10. 搭配redis做文章缓存
  17. 如何在JSP中获得Cookie对象
  18. Eclipse导入别人的项目报错:Unable to load annotation processor factory &#39;xxxxx.jar&#39; for project
  19. 【转载】curl 模拟 GET\POST 请求,curl查看响应头 以及 curl post 上传文件
  20. 【Selenium2】【项目实战】

热门文章

  1. xCode 升级9.3之后巨卡
  2. MySQL服务器线程数的查看方法详解
  3. 免费SSL证书Let&#39;s Encrypt(certbot)安装使用教程
  4. 20165317 学习基础和C语言基础调查
  5. LeetCode 104 Maximum Depth of Binary Tree 解题报告
  6. 原声js,取消事件冒泡,点击按钮,显示box,点击屏幕其他地方,box隐藏
  7. linux popen()函数使用
  8. TZOJ:最大连续子序列
  9. knn/kmeans/kmeans++/Mini Batch K-means/Affinity Propagation/Mean Shift/层次聚类/DBSCAN 区别
  10. 解决采集知乎数据时由于账号被封遗漏的账号重爬问题(python代码)