KentonWhite / ProjectTemplate

A template utility for R projects that provides a skeletal project.
http://projecttemplate.net
GNU General Public License v3.0
622 stars 159 forks source link

Quotes used to wrap the path for dbname value in sql file returns error #299

Closed mkrasmus closed 2 years ago

mkrasmus commented 4 years ago

Report an Issue / Request a Feature

I'm submitting a (Check one with "x") :


Issue Severity Classification -

(Check one with "x") :

Expected Behavior

When following the guide to add a path to the philapd.db file I created in PhilaPD/database I expected the quoted string "database/philapd.db" to be a reasonable value for the dbname argument to locate the database, as this is the convention for most path-to-object scripts in R. Instead I needed to unquote the string to database/philapd.db.

Current Behavior

With the path in quotes the load.project() functions ends with:

Error: Could not connect to database:
unable to open database file
Steps to Reproduce Behavior

Follow guide, create a folder called database and place the database file in there. Create the same sql file but with dbname as "database/philapd.db".

type: sqlite
dbname: "database/philapd.db"
table: *
Version Information

R 3.6.2 R studio 1.2.5.034 ProjectTemplate 0.9

Possible Solution

If escape keys a required to unquote the quotes can a grepl assist for the sql reader function?

KentonWhite commented 4 years ago

Should be an easy fix. Will queue it up.

KentonWhite commented 2 years ago

Closing. The convention in project template is that path names are unquoted in the sql file The reason is that these are treaded as dcf files and not normal R connections.

Hugovdberg commented 2 years ago

@KentonWhite it might be helpful to change the error message to something like

Error: Could not connect to database:
unable to open database file ""database/philapd.db"". 

The outer quotes would then come from the error message and the inner quotes from the dbname configuration option if present. Also, we could make it more explicit in the documentation that all strings inside the file should be unquoted.

KentonWhite commented 2 years ago

@Hugovdberg Think this might be a rabbit hole. I'm not sure but I think the errors are thrown by the dcf package and not ProjectTemplate. And the documentation is very clear that quotes are not used in the examples.