Last active
March 24, 2016 13:39
-
-
Save patperu/3015b657c026cd94bd77 to your computer and use it in GitHub Desktop.
Read/Write Access .accdb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Works only with 32bit | |
library('RODBC') | |
options(stringsAsFactors = FALSE) | |
WriteAccess <- function(xdf, xtable) { | |
channel <- odbcConnectAccess2007("E:/mytest.accdb") | |
sqlSave(channel, tablename = xtable, xdf, safer = FALSE) | |
odbcClose(channel) | |
} | |
ReadAccess <- function(xtable) { | |
channel <- odbcConnectAccess2007("E:/mytest.accdb") | |
x <- sqlFetch(channel, xtable) | |
odbcClose(channel) | |
return(x) | |
} | |
WriteAccess(cars, "tblcars") | |
x <- ReadAccess("tblcars") | |
str(x) | |
devtools::session_info() | |
#Session info ------------------------------------------------------------------- | |
# setting value | |
# version R version 3.2.3 Patched (2015-12-19 r69791) | |
# system i386, mingw32 | |
# ui Rgui | |
# language (EN) | |
# collate German_Germany.1252 | |
# tz Europe/Berlin | |
# date 2016-03-24 | |
#Packages ----------------------------------------------------------------------- | |
# package * version date source | |
# devtools 1.10.0 2016-01-23 CRAN (R 3.2.4) | |
# digest 0.6.9 2016-01-08 CRAN (R 3.2.3) | |
# memoise 1.0.0 2016-01-29 CRAN (R 3.2.3) | |
# RODBC * 1.3-12 2015-06-29 CRAN (R 3.2.3) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment