You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using this package as a dependency for a personal project and I am struggling with how to incorperate this package dependency without having to put library(RPostgreSQL) in the function code.
For some context, the code that I uses connects to a PostgreSQL database hosted on the cloud and proceeds to preform some relevant queries.
My code:
database_func<-function(
dsn_database,
dsn_hostname,
dsn_port,
dsn_uid,
dsn_pwd,
...) {
tryCatch({
drv<- dbDriver("PostgreSQL")
print("Connecting to Database…")
connec<- dbConnect(drv,
dbname=dsn_database,
host=dsn_hostname,
port=dsn_port,
user=dsn_uid,
password=dsn_pwd)
print("Database Connected!")
},
error=function(cond) {
print("Unable to connect to Database.")
})
# REST OF CODE ....
}
If I don't call library(RPostgreSQL) before I utilize this function, the code breaks as the argument for dbDriver() is invalid.
I tried having RPostGreSQL listed in my package dependencies in my DESCRIPTION file but the problem still persists.
The text was updated successfully, but these errors were encountered:
benyamindsmith
changed the title
Incorperating this dependency in an R package
Incorperating this package as a dependency in another R package
Dec 31, 2023
I am using this package as a dependency for a personal project and I am struggling with how to incorperate this package dependency without having to put
library(RPostgreSQL)
in the function code.For some context, the code that I uses connects to a PostgreSQL database hosted on the cloud and proceeds to preform some relevant queries.
My code:
If I don't call
library(RPostgreSQL)
before I utilize this function, the code breaks as the argument fordbDriver()
is invalid.I tried having
RPostGreSQL
listed in my package dependencies in my DESCRIPTION file but the problem still persists.The text was updated successfully, but these errors were encountered: