我正在尝试使用DBI和RPostgres从Rstudio连接到外部数据库(PostgresSQL)。我定义了所有参数:
con <- DBI::dbConnect(RPostgres::Postgres(),
dbname = 'name',
host = 'http://bi-warehouse.cngdka9w0zww.us-east-1.rds.amazonaws.com/',
port = 5432,
user = 'user',
password = 'passwd')但是仍然得到了错误:
Error in connection_create(names(opts), as.vector(opts)) :
could not translate host name "http://bi-warehouse.cngdka9w0zww.us-east-1.rds.amazonaws.com/" to address: Name or service not known发布于 2019-06-26 18:05:17
试用包RPostgreSQL
示例:-
library(RPostgreSQL)
library(dplyr)
library(dbplyr)
psql <- DBI::dbDriver("PostgreSQL")
con <- DBI::dbConnect(psql,
dbname = "machine_db",
host = "192.168.13.213",
port = 5432,
user = "user",
password = 'user123')
machine_data <- dbGetQuery(con, "SELECT * from machine_db")发布于 2020-08-01 13:14:27
使用RPostgres包的
有关更多信息- https://github.com/r-dbi/RPostgres
library(DBI)
library(RPostgres)
conn <- dbConnect(RPostgres::Postgres(),
host = "xyz-db-postgresql.postgres.database.aws.com",
port = 5432,
dbname = "xyz",
user = "xyz",
password = "password"
)
#==== Top 100 Records Of CommodityTable ====
qr<- paste0('SELECT * from "Cxtable " LIMIT 100')
Cxtable <- dbGetQuery(conn, qr)
Cxtablehttps://stackoverflow.com/questions/54785170
复制相似问题