Home:ALL Converter>Connecting to postgresql by R using connecting string

Connecting to postgresql by R using connecting string

Ask Time:2020-11-27T21:35:37         Author:tomsu

Json Formatter

I would like to connect to postgresql database by R using connecting string. So far I used the standard method, where I separately define the user, password, server, etc. However, attempts to connect using the connecting string end in failure.

When I use:

  dbConnect(
    RPostgres::Postgres(),
    host = "test_server_address",
    port = 12345,
    dbname = "test_db_name",
    user = "test_user",
    password = "test_password"
  )

It works fine, connection has been established, but when I use:

dbConnect(RPostgres::Postgres(), .connection_string = "Uid=test_user;Pwd=test_password;Host=test_server_address;Port=12345;Database=test_db_name;")

I get error: Error: invalid connection option ".connection_string"

How to repair code which contain connection string to make it works?

Author:tomsu,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/65038297/connecting-to-postgresql-by-r-using-connecting-string
yy