0

I am having trouble with the dbWriteTable command from the RMySQL package. I have to append records to a table name which is called 'order', a reserved word in MySQL.

dbWriteTable(connection, "`order`", df, append = T)

Give as error:

Warning message: In mysqlWriteTable(conn, name, value, ...) : could not create table: aborting mysqlWriteTable

Other queries like SELECT work fine as long as I put order between back ticks.

Any ideas how the execute the dbWriteTable command? And renaming the table is unfortunately no option.

jeroen81
  • 2,305
  • 5
  • 29
  • 41

2 Answers2

0

Try to write it as a qualified name, example: mydb.order (without backticks).

agstudy
  • 119,832
  • 17
  • 199
  • 261
  • Unfortunately this doesn't work either. It works for table names that aren't reserved bij MySQL. – jeroen81 Dec 05 '12 at 19:53
  • do you have the same message? – agstudy Dec 05 '12 at 22:02
  • Error in mysqlExecStatement(conn, statement, ...) : RS-DBI driver: (could not run statement: Table 'order' already exists) I used 'append = T' – jeroen81 Dec 05 '12 at 22:04
  • row.names = F doesn't work either. I created a workaround. I created made a copy of the ORDER table and named this table temp_ORDER. And now I can update the ORDER tables with the values from the temp_ORDER table via the dbSendQuery command. So it seems only the dbWriteTable command creates errors with a reserved name as table name. – jeroen81 Dec 06 '12 at 11:26
0

Try the following

dbWriteTable(connection, "`order`", df, append = 1)
Cricketer
  • 399
  • 1
  • 3
  • 20