[R-sig-DB] adding to a MySQL database from within R?

Spencer Graves spencer.graves at structuremonitoring.com
Sat Oct 9 06:00:13 CEST 2010

  Hello, All:

       How can I add rows to a MySQL database?

       I can do it manually within MySQL server 5.1.50-community.  I can 
connect to it using the RMySQL package.  When I tried "dbReadTable 
{DBI}", I got a warning that "table headers exists:

 > MySQL. <- MySQL()
 > MySQLcon <- dbConnect(MySQL., user=User, password=pw, dbname=myDB)
 > dbWriteTable(MySQLcon, 'headers', a.data.frame)
Warning message:
In mysqlWriteTable(conn, name, value, ...) :
   table headers exists in database: aborting mysqlWriteTable

       I know that table "headers" exists:  I want to add to it, not 
create the entire table from scratch at once.

R version 2.11.1 (2010-05-31)

[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
  [1] SIM_1.1-5            RCurl_1.4-3          bitops_1.0-4.1
  [4] R2HTML_2.1           oce_0.1-80           TSMySQL_2010.5-1
  [7] RMySQL_0.7-5         DBI_0.2-5            TSdbi_2010.5-1
[10] tframePlus_2009.10-2 tframe_2009.10-1

loaded via a namespace (and not attached):
[1] tools_2.11.1

Spencer Graves, PE, PhD
President and Chief Operating Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567

More information about the R-sig-DB mailing list