I am trying deploy a flexdashboard where I am extracting the data from database and then publishing my results. But since the database is not one of the professional drivers I need to config.yml file to define my connection details. Can you help me to understand how should I create this config.yml file? Is it using Rmarkdown.I have installed packages 'config' and 'configr' and also referred to this article https://db.rstudio.com/best-practices/portable-code/ . I am stuck in this first step of creating the configuration file.
What did you try for now from the website you found ?
You can follow the advice here : https://db.rstudio.com/best-practices/portable-code/#deploying-with-the-config-package-and-credentials
A yaml file is just a text file with extension
yml. So you can create a
config.yml file as any other text file. (with an editor or with R using
file.create("config.yml") to get an empty file to complete).
Then you write in the file with yaml syntax, following the example in the db website, and also from the config doc: https://cran.r-project.org/web/packages/config/vignettes/introduction.html
For database, I would avdvice to follow the recommandion in db website and use environment variable to store credential outside of the
Hope it helps
Thanks for the reply.
I could create the config.yml file using file.create and in the config.yml store all the connection details as below
Now I am creating another .Rmd file to load this file which shows error. Attaching the snapshot. Can you please suggest what should be done
You need to use
: everywhere not
Take care at the indentation in the yaml syntax also. The examples should help you.
Ya changed that.
Still the error is same. How can I call my connection parameters?
My R version is the latest R 4.0
Are you indenting correctly this ? Can you share the file content with proper code formatting ?
Also please read the documentation from the links above. You should use the
get() function from the config package. See the doc.
Attaching the config.yml file. Please let me know if it is correct
Masked few details!!
I tried with get() also in R script with
but getting the same error:
Error in yaml.load(readLines(con), error.label = error.label, ...) :
(/home/rstudio-user/config.yml) Scanner error: while scanning a simple key at line 6, column 3 could not find expected ':' at line 7, column 3
In your screenprint the editor indicates that there is something wrong in line6:
line2-line5 are rendered in blue but line6 is not recognized as correct yaml.
When I inserted a blank after the
: in all lines everything was read correctly.
If you read the configuration parameters in variable
config you should also use
Driver=config$driver etc. Therefore it less typing to read the configuration parameter in
dw <- config::get(file="config.yml")
Thanks a lot for the help. It worked
Glad it finally works !
You are also missing a level of indentation for all field after
If would then be
Or you don’t need this line 3 at all maybe.
Thanks a lot for all the help. Now I am able to publish the flexdashboard by extracting the data from datawarehouse.
If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.