user7454972
user7454972

Reputation: 218

R connect to database

Sorry but I am failing at a very simple task right now.

I have the following database information:

I want to build a connection with the RODBC package. According to the results of my google search i should do

conn<-odbcConnect(dsn, uid=***, pwd=***) 

what is "dsn"? is this even the right way?

Upvotes: 0

Views: 128

Answers (1)

Benjamin
Benjamin

Reputation: 17359

dsn is Data Source Name, which is a shortcut you may define on your machine to store key information about the connection. How you set up a DSN varies depending on your operating system.

I write scripts that run on multiple machines, so rather than use a DSN, I use odbcDriverConnect, via something like

odbcDriverConnect(connection="driver=[driver]; server=[server]; database=[database]; uid = [User ID]; pwd = [password]")

You'll need to know your driver name to make this work. Where to find this will depend on your operating system, as well as the flavor of SQL you are using.

Upvotes: 1

Related Questions