尝试使用DBI连接到Postgres,首次使用dbplyr。
问题:我试图在退出的odbc连接中使用dbplyr,但是dbplyr似乎无法处理这个问题,因此试图使用dbiE 215创建一个新连接,但是这个E 116dbiE 217连接提供了一个E 118错误E 219。因此,我期待修复dbi连接。
libs
library(odbc)
library(RODBC)
library(DBI)
library(dplyr)
library(dbplyr)# from: https://stackoverflow.com/questions/59413904/reading-data-from-a-sql-server-in-rstudio-dplyr
# from: /help/library/DBI/html/dbConnect.html
# from: https://github.com/r-dbi/odbc#odbc
dbicon <- DBI::dbConnect(
odbc::odbc(),
driver = "PostgreSQL Unicode",
database = "Postgres_xyz_db",
host = "some_xyz.amazonaws.com",
port = "5432",
uid = "user",
pwd = "users_password")
# connect with table
tbl_qry <- tbl(dbicon, "mydb_demo.demo_table")
tbl_qry %>% head()dbConnect步骤出错:
Error: nanodbc/nanodbc.cpp:1021: 00000: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
In addition: Warning message:
In for (i in seq_len(n)) { : closing unused RODBC handle 2localhost:8787 PS:PS: --我是在上运行的
。
libs
library(odbc)
library(RODBC)
library(dplyr)
library(dbplyr)现有工作连接:
## #################################################################
## Connection Para
## #################################################################
driver.name <- "PostgreSQL Unicode"
db.name <- "Postgres_xyz_db"
host.name <- "some_xyz.amazonaws.com"
port <-"5432"
user.name <-"user"
pwd <- "users_password"
## #################################################################
## connect to a database
## #################################################################
con.text <- paste("DRIVER=",driver.name,
";Database=",db.name,
";Server=",host.name,
";Port=",port,
";PROTOCOL=TCPIP",
";UID=", user.name,
";PWD=",pwd,sep="")
con1 <- odbcDriverConnect(con.text)但是dbplyr不适用于此连接
# connect with table
tbl_qry <- tbl(con1, "mydb_demo.demo_table")
tbl_qry %>% head() (我不是真正的技术人员,也不是管理员或管理员,所以如果它看起来充满了一些基本的错误,请原谅)。
发布于 2021-10-15 12:22:58
odbc连接更喜欢server=而不是host=,所以您的连接尝试应该是
dbicon <- DBI::dbConnect(
odbc::odbc(),
driver = "PostgreSQL Unicode",
database = "Postgres_xyz_db",
server = "some_xyz.amazonaws.com",
port = "5432",
uid = "user",
pwd = "users_password")https://stackoverflow.com/questions/69581884
复制相似问题