Aerik
Aerik

Reputation: 2317

How to use sqlSave function with existing table in R

I can use sqlSave to create a new table and to append data to that table, but I want the tablet to have some additional columns (for instance, an "ID" autoincrementing column - I am manually adding these columns after creating the table and testing that I can save to it and append to it). As soon as I try to use sqlSave after adding those columns I get an error when trying to use sqlSave to append more data

Error in odbcUpdate... missing columns in 'data'

So I added an ID column to my data frame (so its columns would match my database table) and tried setting it to "NULL", NULL, and "". I keep getting the same error.

Any ideas?

Thanks, Aerik

P.S. I'm using RODBC with MySQL OOBC driver version 5.1

Upvotes: 2

Views: 3914

Answers (2)

André le Blond
André le Blond

Reputation: 368

Try the case="nochange" argument in odbcConnect. I'm using RODBC (1.3-10) with MySQL ODBC driver version 5.2 and it works for me.

Upvotes: 0

Aerik
Aerik

Reputation: 2317

Ah, I got it. The sqlSave function seems to lowercase everything. I'm not sure what checks it's doing behind the scenes, but if I make an "id" column it works, but an "ID" column does not.

Upvotes: 1

Related Questions