[R] Connecting R to PostgreSQL via RODBC, on Windows

elw at stderr.org elw at stderr.org
Thu Sep 27 03:24:36 CEST 2007


> I feel like I must be missing something rather plain, but I don't get 
> it. how is one supposed to use R as a PgSQL client on Windows?  Assume 
> my windows desktop is on the same network as a PgSQL server, and I just 
> need to use R to connect and pull down some data.
>
> The thing that is confusing me is that RODBC doesn't seem to know 
> anything about PgSQL, in that odbcDataSources(type = "all") only returns 
> info about MS/Excell/Access/dBase stuff.  What does it take to get RODBC 
> to deal with PgSQL?


There's an odbc-to-pgsql driver for windows that will need to be 
installed.  You can find that here:

http://www.postgresql.org/ftp/odbc/versions/

Then, you set up your connection to postgresql via the Control Panel, 
under Administrative Tools, then Data Sources.

Then connect to that with R.

[I have mostly done this under Linux - it has been quite a while since 
I've needed to do it on Windows, but this is a broadly correct outline of 
the necessary steps.]

--e



More information about the R-help mailing list