简体   繁体   English

如何在OSX 10.10.2上将R与PostgreSQL连接?

[英]How to connect R with PostgreSQL on OSX 10.10.2?

I have the following setup: 我有以下设置:

  • OSX 10.10.2 OSX 10.10.2
  • PostgreSQL 9.4.1 PostgreSQL 9.4.1
  • R 3.1.3 R 3.1.3

This answer as of 2011 says that the easiest approach is to use RpgSQL package. 截至2011年, 此答案表示最简单的方法是使用RpgSQL包。 But it is removed from the CRAN repository. 但是它已从 CRAN存储库中删除 RODBC mentioned there is available as source , but it fails to configure: RODBC提到那里可以作为source ,但是它无法配置:

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: 我还找到了另一个可以帮助我的软件包RPostgreSQL ,但无法编译:

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? 还有其他方法可以连接R和PostgreSQL吗?

See RODBC to connect to SQL Server on Mavericks 查看RODBC以在Mavericks上连接到SQL Server

RODBC isn't really supported on OSX. OSX上确实不支持RODBC。 What I ended up doing is to use RJDBC, which is in CRAN. 我最终要做的是使用CRAN中的RJDBC。
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 但是可以做到: Postgres DB无法使用RJDBC连接到R

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM