Rmysql has just been difficult to install in windows. For details, see
How to install rmysql in Windows
I can't wait to test it.
References: http://www.biosino.org/R/R-doc/R-data_cn/DBI-_002f-RMySQL.html
1. Connect to the database
> Library (rmysql) # load package> con <-dbconnect (dbdriver ("MySQL"), dbname = "eswp", user = "root", password = "root ") # To connect to the database, you must enter the user name and password through user and password. Otherwise, the database cannot be connected.
2. List tables and databases
dbListTables(con) [1] "2008yearnew" "agent" "artifact" [4] "cancer_data" "chinese_drug" "conceptnum"
3. read Table
> Dbreadtable (con, "foreign_drug") [,] # too much data, read only part of the URL register_no3 http://app1.sfda.gov.cn/datasearch/face3/content.jsp? Tableid = 36 & tablename = table36 & tableview = ???? & Id = 10987 h201201974 http://app1.sfda.gov.cn/datasearch/face3/content.jsp? Tableid = 36 & tablename = table36 & tableview = ???? & Id = 10990 h201201965 http://app1.sfda.gov.cn/datasearch/face3/content.jsp? Tableid = 36 & tablename = table36 & tableview = ???? & Id = 10984 h201201816 http://app1.sfda.gov.cn/datasearch/face3/content.jsp? Tableid = 36 & tablename = table36 & tableview = ???? & Id = 10993 h201201847 http://app1.sfda.gov.cn/datasearch/face3/content.jsp? Tableid = 36 & tablename = table36 & tableview = ???? & Amp; id = 10978 h20120182
4. query a table
> dbGetQuery(con, paste("select URL,register_no from foreign_drug where register_no ='H20120197' or register_no ='H20120196'")) URL register_no1 http://app1.sfda.gov.cn/datasearch/face3/content.jsp?tableId=36&tableName=TABLE36&tableView=????&Id=10987 H201201972 http://app1.sfda.gov.cn/datasearch/face3/content.jsp?tableId=36&tableName=TABLE36&tableView=????&Id=10990 H20120196
5. Delete tables and disconnect
> dbRemoveTable(con, "foreign_drug")[1] TRUE> dbDisconnect(con)[1] TRUE
Go back first, and study tomorrow.
Life is endless, learning is endless.