[R] remote database queries

Duncan Murdoch murdoch at stats.uwo.ca
Sat Jul 18 21:55:07 CEST 2009


On 18/07/2009 3:04 PM, David Lubbers wrote:
> With good and faithful python remote database queries look something
> like this:
> 
> url.urlopen("username/pssword at host",query)
> 
> where query is something like "select * from table where ...."
> 
> Does R support queries on remote hosts with username and password?
> 
> What does a simple example look like?

It depends on what kind of database you're connecting to.  If you have 
an ODBC connection set up they're pretty standardized, and it would be 
something like

library(RODBC)
channel <- odbcConnect("dsn", uid="username", pwd="password")
sqlQuery(channel, query)

Duncan Murdoch




More information about the R-help mailing list