[R] RMySQL valid field names

Luis Torgo ltorgo at liacc.up.pt
Mon Nov 24 20:45:56 CET 2003

I'm having some problems with valid field names when using RMySQL to interface 
R (version 1.7.0, under RedHat9.0), to MySQL (4.1.0-alpha). I think I've 
spotted the problem and a solution (which is working for me), but I wanted to 
share this with you as I may be missing something.
(Note: I'm aware that this is an old R version, but I've checked the code of 
the lastest version of the RMySQL package at CRAN, and my comments still 

I have a data frame which has among others three columns with names 
('DateTime', 'Open' and 'Close'). When I use dbWriteTable to dump the data 
frame into a MySQL database everything works fine except the names of these 
three columns which are slightly different (e.g. 'DateTime_9'). 

This only occurs with these 3 columns because their names are reserved words 
of MySQL. The change of names is occurring in the function mysqlWriteTable, 
namely in the call:
names(field.types) <- make.db.names(con,names(field.types),allow.keywords=F)
If I change the parameter allow.keywords into T, everything works fine for me. 
Given that MySQL allows all characters to be part of field names (section 
6.1.2 of MySQL reference manual), I do not understand what is the reason for 
calling make.db.names with this value of parameter allow.keywords.

In resume, my question is: Is there any reason for this that I am missing, or 
the change I've done is pretty safe and could possibly be done in future 
versions of the package?

Thank you for any help.

Luis Torgo
    FEP/LIACC, University of Porto   Phone : (+351) 22 607 88 30
    Machine Learning Group           Fax   : (+351) 22 600 36 54
    R. Campo Alegre, 823             email : ltorgo at liacc.up.pt
    4150 PORTO   -  PORTUGAL         WWW   : http://www.liacc.up.pt/~ltorgo

More information about the R-help mailing list