odbc icon indicating copy to clipboard operation
odbc copied to clipboard

Oracle Connection Names Set as "Default" in RStudio Connection Panel

Open woodtho opened this issue 1 year ago • 1 comments

Issue Description and Expected Result

The current implementation of the odbc package sets the name of every database connection to "Default" when connecting to Oracle databases at work. This behavior limits the ability to distinguish between multiple Oracle connections within RStudio, which can cause confusion and make it challenging to manage and identify connections effectively.

Connection Panel

I suggested that the behavior of the computeDisplayName function be adjusted so that if dsn matches "Default", that the first if statment returns FALSE and the function continues on computing a display name from the other details in the info slot of the connection. Alternatively, allowing users to specify a custom display name as an argument during the dbconnect call would provide more flexibility and control over connection naming.

Database

Oracle 19.00.0000

Reproducible Example

library(DBI)
library(odbc)
library(rstudioapi)

con <- dbConnect(odbc::odbc(),
                 Driver = "Oracle in OraClient19Home1",
                 DBQ = "prod_c",
                 UID =  Sys.getenv("USERNAME"),
                 PWD = rstudioapi::askForPassword("Enter your password for the prod_c database: "))

str(con)
#> Formal class 'Oracle' [package ".GlobalEnv"] with 4 slots
#>   ..@ ptr     :<externalptr> 
#>   ..@ quote   : chr "\""
#>   ..@ info    :List of 15
#>   .. ..$ dbname                       : chr ""
#>   .. ..$ dbms.name                    : chr "Oracle"
#>   .. ..$ db.version                   : chr "19.00.0000"
#>   .. ..$ username                     : chr "woodtho"
#>   .. ..$ host                         : chr ""
#>   .. ..$ port                         : chr ""
#>   .. ..$ sourcename                   : chr "Default"
#>   .. ..$ servername                   : chr "prod_c"
#>   .. ..$ drivername                   : chr "SQORA32.DLL"
#>   .. ..$ odbc.version                 : chr "03.80.0000"
#>   .. ..$ driver.version               : chr "19.03.0000"
#>   .. ..$ odbcdriver.version           : chr "03.52"
#>   .. ..$ supports.transactions        : logi TRUE
#>   .. ..$ getdata.extensions.any_column: logi TRUE
#>   .. ..$ getdata.extensions.any_order : logi TRUE
#>   .. ..- attr(*, "class")= chr [1:3] "Oracle" "driver_info" "list"
#>   ..@ encoding: chr ""


Session Info

devtools::session_info()

#> - Session info --------------------------------------
#>  setting  value
#>  version  R version 4.1.3 (2022-03-10)
#>  os       Windows 10 x64 (build 19042)
#>  system   x86_64, mingw32
#>  ui       RStudio
#>  language (EN)
#>  collate  English_United States.1252
#>  ctype    English_United States.1252
#>  tz       America/New_York
#>  date     2023-05-25
#>  rstudio  1.4.1106 Tiger Daylily (desktop)
#>  pandoc   NA
#> 
#> - Packages ------------------------------------------
#>  package     * version date (UTC) lib source
#>  bit           4.0.5   2022-11-15 [1] CRAN (R 4.1.3)
#>  bit64         4.0.5   2020-08-30 [1] CRAN (R 4.1.3)
#>  blob          1.2.4   2023-03-17 [1] CRAN (R 4.1.3)
#>  cachem        1.0.7   2023-02-24 [1] CRAN (R 4.1.3)
#>  callr         3.7.3   2022-11-02 [1] CRAN (R 4.1.3)
#>  cli           3.6.1   2023-03-23 [1] CRAN (R 4.1.3)
#>  crayon        1.5.2   2022-09-29 [1] CRAN (R 4.1.3)
#>  DBI         * 1.1.3   2022-06-18 [1] CRAN (R 4.1.3)
#>  devtools      2.4.5   2022-10-11 [1] CRAN (R 4.1.3)
#>  digest        0.6.31  2022-12-11 [1] CRAN (R 4.1.3)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.1.3)
#>  fastmap       1.1.1   2023-02-24 [1] CRAN (R 4.1.3)
#>  fortunes      1.5-4   2016-12-29 [1] CRAN (R 4.1.1)
#>  fs            1.5.2   2021-12-08 [1] CRAN (R 4.1.3)
#>  glue          1.6.2   2022-02-24 [1] CRAN (R 4.1.3)
#>  hms           1.1.3   2023-03-21 [1] CRAN (R 4.1.3)
#>  htmltools     0.5.5   2023-03-23 [1] CRAN (R 4.1.3)
#>  htmlwidgets   1.6.2   2023-03-17 [1] CRAN (R 4.1.3)
#>  httpuv        1.6.9   2023-02-14 [1] CRAN (R 4.1.3)
#>  knitr         1.42    2023-01-25 [1] CRAN (R 4.1.3)
#>  later         1.3.0   2021-08-18 [1] CRAN (R 4.1.3)
#>  lifecycle     1.0.3   2022-10-07 [1] CRAN (R 4.1.3)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.1.3)
#>  memoise       2.0.1   2021-11-26 [1] CRAN (R 4.1.3)
#>  mime          0.12    2021-09-28 [1] CRAN (R 4.1.1)
#>  miniUI        0.1.1.1 2018-05-18 [1] CRAN (R 4.1.3)
#>  odbc        * 1.3.4   2023-01-17 [1] CRAN (R 4.1.3)
#>  pkgbuild      1.4.0   2022-11-27 [1] CRAN (R 4.1.3)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.1.3)
#>  pkgload       1.3.2   2022-11-16 [1] CRAN (R 4.1.3)
#>  prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.1.3)
#>  processx      3.8.1   2023-04-18 [1] CRAN (R 4.1.3)
#>  profvis       0.3.7   2020-11-02 [1] CRAN (R 4.1.3)
#>  promises      1.2.0.1 2021-02-11 [1] CRAN (R 4.1.3)
#>  ps            1.7.5   2023-04-18 [1] CRAN (R 4.1.3)
#>  purrr         1.0.1   2023-01-10 [1] CRAN (R 4.1.3)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.1.3)
#>  Rcpp          1.0.10  2023-01-22 [1] CRAN (R 4.1.3)
#>  remotes       2.4.2   2021-11-30 [1] CRAN (R 4.1.3)
#>  rlang         1.1.0   2023-03-14 [1] CRAN (R 4.1.3)
#>  rstudioapi  * 0.14    2022-08-22 [1] CRAN (R 4.1.3)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.1.3)
#>  shiny         1.7.4   2022-12-15 [1] CRAN (R 4.1.3)
#>  stringi       1.7.12  2023-01-11 [1] CRAN (R 4.1.3)
#>  stringr       1.5.0   2022-12-02 [1] CRAN (R 4.1.3)
#>  urlchecker    1.0.1   2021-11-30 [1] CRAN (R 4.1.3)
#>  usethis       2.1.6   2022-05-25 [1] CRAN (R 4.1.3)
#>  vctrs         0.6.1   2023-03-22 [1] CRAN (R 4.1.3)
#>  xfun          0.38    2023-03-24 [1] CRAN (R 4.1.3)
#>  xtable        1.8-4   2019-04-21 [1] CRAN (R 4.1.3)
#>  yaml          2.3.7   2023-01-23 [1] CRAN (R 4.1.3)
#> 
#>  [1] C:/Users/woodtho/Documents/R/win-library/4.1
#>  [2] C:/Program Files/R/R-4.1.3/library
#> 
#> ----------------------------------------------------

woodtho avatar May 25 '23 15:05 woodtho