user3601202
user3601202

Reputation: 1

Error Trying to Connect R to MySQL using RODBC

I am attempting to connect R to a MySQL database via RODBC (in Win 7 environment), but cannot get past the following error:

[RODBC] ERROR: state IM014, code 0, message [Microsoft][ODBC Driver Manager] The specified     DSN contains an architecture mismatch between the Driver and Application

After entering the following command:

odbcConnect(dsn,uid="My_UID",pwd="My_PWD")

I have successfully created a driver for the database by following the odbc wizard, and have installed the RODBC package into RStudio (ver 0.98.490). The MySQL is running on 32bit, I have the 32bit driver installed and working, and my RStudio is also 32bit. I know that the driver is working since both the test connection in config. works, as do queries run on excel using the driver.

What can I do to get the connection to work in R?

(Previous responses to this question seem to have been removed.)

Thanks in advance!

Upvotes: 0

Views: 2074

Answers (1)

user3724889
user3724889

Reputation: 11

I faced a similar RODBC connectivity issue using DSN, where R was crashing abruptly without any logs/error trace. I tried with DSN-less ODBC connection API, it works fine.

odbcDriverConnect("SERVERNAME=;DRIVER={};DATABASE=;UID=;PWD=;")

Steps: 1. Install ODBC driver 2. Define VNode (host, listen address, protocol) 3. Use the odbcDriverConnect API

Docs: http://cran.r-project.org/web/packages/RODBC/RODBC.pdf http://cran.r-project.org/web/packages/RODBC/vignettes/RODBC.pdf

Hope this helps.

Upvotes: 1

Related Questions