Skip to content

Commit

Permalink
fix: db_connect return
Browse files Browse the repository at this point in the history
  • Loading branch information
dnldelarosa committed Mar 21, 2024
1 parent 2fe2940 commit 3e41d61
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: Dmisc
Title: Daniel miscellaneous functions
Version: 0.3.10
Version: 0.3.11
Authors@R:
person(given = "Daniel E.",
family = "de la Rosa",
Expand Down
12 changes: 10 additions & 2 deletions R/db_connect.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,33 @@ db_connect <- function(db_user = NULL,

if (db_sys == 'SQL Server') {
rlang::check_installed("odbc")
DBI::dbConnect(odbc::odbc(),
conn <- DBI::dbConnect(odbc::odbc(),
Driver = "ODBC Driver 17 for SQL Server",
Server = db_host,
Database = db_name,
Trusted_Connection = trusted_connection,
...
)

return(conn)
}

if (db_sys == "PostgreSQL") {
rlang::check_installed("RPostgres")
DBI::dbConnect(RPostgres::Postgres(),
conn <- DBI::dbConnect(RPostgres::Postgres(),
dbname = db_name,
host = db_host,
port = db_port,
user = uname,
password = pass
)

return(conn)
}

stop(cli::cli_alert_error(
paste0("El sistema de base de datos '", db_sys, "' no está soportado.")
), call. = FALSE)
}


Expand Down

0 comments on commit 3e41d61

Please sign in to comment.