无法使用R连接到pgadmin中的数据库

时间:2017-04-06 05:08:24

标签: r pgadmin

想要尝试一件简单的事情。我在pgadmin中创建了空数据库。我使用R连接到该数据库,但它无法正常工作。我在线搜索了它,但即使我安装了所有软件包也无法使其正常工作。

我使用的代码是我从网站上获得的。

# install.packages("RPostgreSQL")
require("RPostgreSQL")

# create a connection
# save the password that we can "hide" it as best as we can by collapsing it
pw <- {
  "new_user_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 = "postgres",
                 host = "localhost", port = 5432,
                 user = "******", password =******)
rm(pw) # removes the password`enter code here`

我错过了什么吗?

0 个答案:

没有答案