I would like to pass some parameter keywords (specifically keepalives
, keepalives_idle
, keepalives_count
, or connect_timeout
) using the R package RPostgreQSL to connect to my DB.
I have searched the docs and stackoverflow for an implementation, but haven't found a solution.
Is there a way to pass these parameter keywords using RPostgresSQL?
What I have tried:
- Through the dbConnect function as additional arguments
conn <- RPostgreSQL::dbConnect(driver,
host = Sys.getenv("DBHOST"),
dbname = Sys.getenv("DBNAME"),
user = Sys.getenv("DBUSER"),
password = Sys.getenv("DBPASSWORD"),
port = Sys.getenv("DBPORT"),
# Parameter Keywords
connect_timeout = 2,
keepalives = 0,
keepalives_idle = 0,
keepalives_count = 1,
)
This results in:
Error in postgresqlNewConnection(drv, ...) :
unused arguments (connect_timeout = 2, keepalives = 0, keepalives_idle = 0, keepalives_count = 1)
- As additional command line options:
conn <- RPostgreSQL::dbConnect(driver,
host = Sys.getenv("DBHOST"),
dbname = Sys.getenv("DBNAME"),
user = Sys.getenv("DBUSER"),
password = Sys.getenv("DBPASSWORD"),
port = Sys.getenv("DBPORT"),
options = "-c connect_timeout=2"
)
This results in:
Error in postgresqlNewConnection(drv, ...) :
RPosgreSQL error: could not connect <omitted>@<omitted>:<omitted> on dbname "<omitted>" FATAL: unrecognized configuration parameter "connect_timeout"
- Through the dbSendQuery function:
RPostgreSQL::dbSendQuery(conn, "SET statement_timeout to 1; SET connect_timeout to 2 ")
This results in
Error in postgresqlExecStatement(conn, statement, ...) :
RPosgreSQL error: could not Retrieve the result : ERROR: unrecognized configuration parameter "connect_timeout"