1

I have the following setup:

  • OSX 10.10.2
  • PostgreSQL 9.4.1
  • R 3.1.3

This answer as of 2011 says that the easiest approach is to use RpgSQL package. But it is removed from the CRAN repository. RODBC mentioned there is available as source, but it fails to configure:

configure: error: "ODBC headers sql.h and sqlext.h not found"
ERROR: configuration failed for package ‘RODBC’

I've also found another package, which could help me - RPostgreSQL, but it fails to compile:

In file included from RS-PQescape.c:7:
./RS-PostgreSQL.h:23:14: fatal error: 'libpq-fe.h' file not found
#    include "libpq-fe.h"
             ^
1 error generated.
make: *** [RS-PQescape.o] Error 1
ERROR: compilation failed for package ‘RPostgreSQL’

Is there any other way to connect R and PostgreSQL?

Community
  • 1
  • 1
LA_
  • 19,823
  • 58
  • 172
  • 308
  • How did you install PostgreSQL? `RPostgreSQL` compiles fine on my OS X 10.10.2 system. I use the Homebrew version of PostgreSQL. – hrbrmstr Mar 28 '15 at 12:47
  • @hrbrmstr, I've downloaded the package http://get.enterprisedb.com/postgresql/postgresql-9.4.1-3-osx.dmg and installed it. Btw, installation fails (like described there - http://www.postgresql.org/message-id/201107190838.p6J8cwgf039126@wwwmaster.postgresql.org), but I've created user `postgres` manually as described there - http://www.giannakidis.info/post/51891050503/installing-postgresql-9-2-on-mac-os-x – LA_ Mar 28 '15 at 12:53
  • And, `include` folder of PostgreSQL contains that `libpq-fe.h` file. – LA_ Mar 28 '15 at 13:03
  • @hrbrmstr, installation of PostgreSQL thru Homebrew helped to resolve the problem with RPostgreSQL. Please post it as the answer, so I will be able to accept it. – LA_ Mar 31 '15 at 15:45

1 Answers1

0

See RODBC to connect to SQL Server on Mavericks

RODBC isn't really supported on OSX. What I ended up doing is to use RJDBC, which is in CRAN.
Setting up the connection to your data base isn't always easy. But it can be done: Postgres DB can't connect to R with RJDBC

Community
  • 1
  • 1
PeterK
  • 1,185
  • 1
  • 9
  • 23