Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative to credentials file #7

Open
statzhero opened this issue May 9, 2021 · 3 comments
Open

Alternative to credentials file #7

statzhero opened this issue May 9, 2021 · 3 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@statzhero
Copy link
Contributor

It is possible to add a user prompt instead of a credentials file, for those who feel queasy about storing any passwords in plain text.

This method can be achieved with the RStudio API.

For example,

user <- rstudioapi::askForPassword(prompt="Enter your WRDS login")
pw   <- rstudioapi::askForPassword()
@joachim-gassen
Copy link
Member

I like this very much as a fallback if config.csv is not available. I will implement at some point (If not somebody beats me to it. Which timewise should be easy... ;-)

@joachim-gassen joachim-gassen added good first issue Good for newcomers help wanted Extra attention is needed labels Sep 28, 2021
@arndtupb
Copy link
Member

arndtupb commented Dec 4, 2021

@joachim-gassen, one could insert a section on WRDS Credentials in pull_wrds_data.R just before the WRDS Connection and get entirely rid of read_config.R by a simple if else scenario:

if(file.exists("config.csv")){
  df <- readr::read_csv("config.csv", col_type = readr::cols(), comment = "#")
  cfg <- as.list(df$value)
  names(cfg) <- df$variable
  rm(df) 
  wrds_user <- cfg$wrds_user
  wrds_pwd <- cfg$wrds_pwd
  rm(cfg)
} else {
  wrds_user <- rstudioapi::askForPassword(prompt="Enter your WRDS login")
  wrds_pwd   <- rstudioapi::askForPassword()
}

(...)

wrds <- dbConnect(
  Postgres(),
  host = 'wrds-pgdata.wharton.upenn.edu',
  port = 9737,
  user = wrds_user,
  password = wrds_pwd,
  sslmode = 'require',
  dbname = 'wrds'
)
rm(wrds_user)
rm(wrds_pwd)

thoughts on this? I could create a pull request

@arndtupb
Copy link
Member

arndtupb commented Dec 9, 2021

see #15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants