odbc icon indicating copy to clipboard operation
odbc copied to clipboard

Password character escaping

Open galachad opened this issue 4 years ago • 2 comments

Issue Description and Expected Result

dbConnect(..., PWD = ";fsdafasd;fasd")` is not escaping some character in password and it throwing the error:

Error: nanodbc/nanodbc.cpp:950: HY000: [unixODBC][RStudio][ODBC] (10360) Invalid connection string.

and

Error: nanodbc/nanodbc.cpp:950: 28000: [unixODBC][RStudio][DSI] (20032) Required setting 'PWD' is not present in the connection settings.

Database

All.

Reproducible Example

Example:

library(odbc)
library(DBI)
con <- dbConnect(
           odbc::odbc(),
           Driver = "PostgreSQL",
           Server = "host_server",,
           Database = "databse",
           Port = 5432,
           UID = "user_name",
           PWD = ";%={&$>#" # password with special characters
         )

It's probably bug in nanodbc lib but i'm putting the first issue here.

Let me know if you can reproduce the bug on your system.

Session Info
devtools::session_info()
#> ─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.6.1 (2019-07-05)
 os       Ubuntu 18.04.3 LTS          
 system   x86_64, linux-gnu           
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       Etc/UTC                     
 date     2020-05-21      

galachad avatar May 21 '20 07:05 galachad

Hi @jimhester or @krlmlr could you take a look on the issue and confirm if it's nanodbc or R package issue.

Thank you.

galachad avatar Jun 05 '20 12:06 galachad

From https://www.connectionstrings.com/formating-rules-for-connection-strings/

f a semicolon (;) is part of a value it must be delimited by quotation marks (")

So you could try PWD = "\"%={&$>#\"" in the above.

jimhester avatar Jun 05 '20 14:06 jimhester

Addressed in https://github.com/r-dbi/odbc/pull/656!

simonpcouch avatar Jan 17 '24 18:01 simonpcouch