Connecting to MS SQL Server from R on Mac/Linux

前端 未结 6 941
北海茫月
北海茫月 2020-12-31 08:26

I\'m trying to connect to a Microsoft SQL Server from R on Mac/Linux, and I have problems with RJDBC. When I\'ve downloaded both Microsoft\'s driver and JTDS, but none of th

6条回答
  •  一整个雨季
    2020-12-31 08:57

    The following code achieves your goal of connecting to R from Mac OS x. Download the Microsoft JDBC driver from Microsoft here

    Link to Gist / Code in Github

    # install.packages("RJDBC",dep=TRUE)
    library(RJDBC)
    drv <- JDBC("com.microsoft.sqlserver.jdbc.SQLServerDriver" , "/Users/johndacosta/Downloads/sqljdbc_4.0/enu/sqljdbc4.jar" ,identifier.quote="`")
    conn <- dbConnect(drv, "jdbc:sqlserver://192.172.1.210:55158;databaseName=master", "sa", "password")
    d <- dbGetQuery(conn, "select * from sys.databases where database_id <= 4 ")
    summary(d)
    

提交回复
热议问题