Created
April 14, 2017 20:48
-
-
Save ibombonato/fc88f5d5418e42abf3be3449c9893a01 to your computer and use it in GitHub Desktop.
Dockerfile for Rstudio with SQL Driver 13 and RODBC package
This file contains 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
FROM rocker/tidyverse | |
RUN echo "deb http://ftp.debian.org/debian sid main" | tee -a /etc/apt/sources.list.d/sid.list | |
RUN apt-get update -qq && apt-get -y --no-install-recommends install \ | |
apt-transport-https \ | |
libssl-dev \ | |
libsasl2-dev \ | |
openssl \ | |
curl \ | |
unixodbc \ | |
unixodbc-dev libmyodbc odbcinst \ | |
gnupg \ | |
libc6 libc6-dev libc6-dbg | |
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \ | |
&& curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list \ | |
&& apt-get update \ | |
&& ACCEPT_EULA=Y apt-get -y install msodbcsql=13.1.4.0-1 mssql-tools=14.0.4.0-1 \ | |
&& ln -sfn /opt/mssql-tools/bin/sqlcmd-13.1.4.0 /usr/bin/sqlcmd \ | |
&& ln -sfn /opt/mssql-tools/bin/bcp-13.1.4.0 /usr/bin/bcp | |
RUN rm /etc/apt/sources.list.d/sid.list | |
RUN R -e "install.packages('RODBC', repos='http://cran.rstudio.com/')" | |
# After you start the container, open it on port 8787, the default user/pwd is rstudio |
This file contains 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
# Example of a SQL query inside your R script file with the RODBC package: | |
driver.name <- "{ODBC Driver 13 for SQL Server}" | |
db.name <- "DB_NAME" | |
server.address <- "SERVER_ADDRESS" | |
user.name <- "SQL_USER" | |
pwd <- "SQL_PASSWORD" | |
con.text <- paste("DRIVER=",driver.name, | |
";Database=",db.name, | |
";Server=",server.address, | |
";UID=", user.name, | |
";PWD=",pwd,sep="") | |
con <- RODBC::odbcDriverConnect(con.text) | |
sql_text <- "Select * FROM TABLE" | |
results <- RODBC::sqlQuery(con, sql_text, as.is = TRUE) | |
RODBC::odbcClose(con) | |
results |
Hi, libmyodbc might not be available, but if you exclude it, the image still works for me.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello. Just 2 cents: won't work for me as of today. error is
Package libmyodbc is not available, but is referred to by another package.