odbc
odbc copied to clipboard
Password character escaping
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
Hi @jimhester or @krlmlr could you take a look on the issue and confirm if it's nanodbc or R package issue.
Thank you.
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.
Addressed in https://github.com/r-dbi/odbc/pull/656!