'How to connect SQL Server with Rstudio?
I have downloaded Microsoft SQL Server on my Mac with the Docker image as described here, and also I have downloaded the database AdventureWorks2019 as an example which I found it here.
So far so good. Everything works fine.
Now I want to import this database in my RStudio.
I followed the instructions which I found here.
So I opened RStudio and I typed the following:
con <- DBI::dbConnect(odbc::odbc(),
Driver = "SQL Server",
Server = "localhost",
Database = "AdventureWorks2019",
uid = "sa",
pwd = "<YourStrong@Passw0rd>",
port = 1433,
Trusted_Connection = "True")
I get an error
Error: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found
Meanwhile the container in Docker is active and the localhost is active (green) in MS SQL. I searched on the web for similar errors on Mac and I am more confused.
Any help? Someone?
Solution 1:[1]
This works for me:
con <- DBI::dbConnect(
odbc::odbc(),
Driver = "SQL Server",
Server = "server",
Database = "database",
UID = "uid",
PWD = "pwd"
)
I don't think you need Port
and Trusted_Connection
?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Dmitry Ishutin |