我正在尝试将R连接到PostgreSQL数据库。以下是我在R中尝试过的内容:
require("RPostgreSQL")
pw<- {
"password"
}
# loads the PostgreSQL driver
drv <- dbDriver("PostgreSQL")
# creates a connection to the postgres database
# note that "con" will be used later in each connection to the database
con <- dbConnect(drv, dbname = "DBname",
host = "localhost", port = 5432,
user = "user", password = pw)
rm(pw) # removes the password
# check for the test_table
dbExistsTable(con, "test_table")
# FALSE >>> Should be true
我无法弄清楚为什么它没有正确连接到我的数据库。我知道数据库在我的电脑上,因为我可以在终端和pgAdmin4中连接它。非常感谢任何帮助。
谢谢
dbListTables(con)时,会得到什么结果? - vagabondSys.getenv加载它们。 - BulatdbListTables()中输出,如 @vagabond 所建议的?请注意:Postgres 区分大小写。 - Parfait