Default connection when opening a SQL file

Is there any way in the IDE to specify the default connection you'd like to establish for SQL file? Currently the default is:

-- !preview conn=DBI::dbConnect(RSQLite::SQLite())

SELECT 1

Is there anywhere in the ID to change it to something like:

-- !preview conn=DBI::dbConnect(RPostgres::Postgres())

SELECT 1

Couldn't find anything here: https://db.rstudio.com/

There is a support article on this new feature on which you may find answers

1 Like

Great this is definitely helpful and is a really nice feature. Do you have any thoughts on changing the default?

Thanks!

Sam

looking at the source tree it looks like that's coming from a template:

but on my machine I could not find that file. So I'm not sure if that ends up inside something else or what, exactly. But, I think @javierluraschi was the last one to touch that file so let's send up the bat signal and maybe Javier will drop by to educate us on where the templates end up and whether editing them is possible.

There is no way to customize this default template from RStudio's user interface; however, for OS X (similar in Windows) the file is located under:

/Applications/RStudio.app/Contents/Resources/resources/templates/query.sql

So you could potentially modify that file to fit your needs. Notice that I wouldn't encourage to tweak RStudio internal files, but if you really want to or need to, that's one way. I would also encourage you to open a GitHub issue for us to consider adding a proper file-template editing tool within the UI.

1 Like

thanks for the response. much appreciated.

@boshek keep in mind that when you install the next version of R Studio it will likely clobber that file, so be prepared for that.

Issue submitted here: https://github.com/rstudio/rstudio/issues/3569

Thanks for the feedback/input @jdlong

2 Likes