Categories
日常应用

ODBC(Teradata)和R连接常见问题

以前总结了一些R、SAS和TD彼此之间数据导入导出的办法,可是实际使用中还是会碰到各种各样的问题...问的人多了,就多少攒出一些FAQ放在了内部的wiki上。

还有一些问题估计大家都会遇到,所以也摘到blog上来好了。一开始用英文写的,简单翻译一下,不全翻译了。首先是通过RODBC连TD的一些常见问题,不知道是不是通用于其他ODBC driver...

  • Q: I cannot load RODBC on my own computer (not on R servers)... what can I do?
    A: Try to debug in these steps -1)  Check if you have installed the 64-bit version of Teradata ODBC driver on your 64-bit OS. If not, download and install these three packages here: http://downloads.teradata.com/download/connectivity/odbc-driver/windows(保证R、操作系统和ODBC driver位数一致,如果是64位的操作系统就装一套儿64位的吧...上面那个link是64位TD ODBC Driver的下载地址)。2)  Open your 64-bit ODBC administrator and configure the TD server DNS. (在新的ODBC中配置server地址) 

    3)  Close and re-open R again. (重启R,这步一定不能省)
    4)  If you still have problems, use R 2.*** instead of R 3.0+ (R 3.0以上版本有时候会莫名其妙报错,如是,改用2.15+版本吧。)

  • Q: How can I call R in the command line (to schedule a recurring job)? (怎么run batch job?)
    A: You can call RScript directly in your command line. If failure, you need to add R's path to your system environment variable - PATH. e.g. C:\Program Files\R\R-2.15.2\bin (设一下环境变量)
    Pay attention to its parameters. Also, you can save the log. A sample command is as follows - (命令行类似如下)

    Rscript --no-save --no-restore --verbose "/home/Liyun.Chen/R/recurring/recurring_dashboard_by_week.r" > outputFile.log 2>&1

    (记得存个log)

暂时就是这些...做个存档好了。