Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 202012

R's dbConnect fails with "DSN error" when executed by script called from batch file

$
0
0

I have 64 bit R, version 3.6.0, installed on my windows 10 machine.

I use the following code to establish a connection to the local MySQL database on my machine

library(DBI)
con <- dbConnect( odbc::odbc(),"my_dsn")

where my_dsn is the 64-bit System DSN to the MySQL database defined within the ODBC Data Source Administrator.

Executing this code within a fresh R Studio or R GUI session works and provides the expected connection object. So I save the code to an R script at C:/some_folder_location/my_script.R.

Now I wish to call the script from a batch file. The batch file contains the following code:

cd /d C:\some_folder\
"C:\Program Files\R\R-3.6.0\bin\i386\Rscript.exe"  my_script.R
pause

When I execute the batch file I get the following error:

Error: nanodbc/nanodbc.cpp:950: IM014: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application

Execution halted

So my question is, why does this code suddenly not work when executed by a batch file? The error message seems to be saying there's an issue with the DSN, but we know that isn't the case based on the fact that the script runs without issue from the console directly.


Viewing all articles
Browse latest Browse all 202012

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>