Background
I have a function dbquery
that simplifies the process of querying a MySQL database from within R.
dbquery <- function(querystring) {
dvr <- dbDriver("MySQL")
con <- dbConnect(dvr, group = "databasename")
q <- dbSendQuery(con, querystring)
data <- fetch(q, n = -1)
return(data)
}
Thus I can send:
dbquery(querystring = "select field_1, field_2, field_3
from table_a join table_b on this = that
join table_c on that = something
where field_4 in (1,2,3);"
However, the variable querystring
must be contained within quotes. This makes it so that Emacs ESS will not nicely indent my queries like it would if it were in SQL mode - or even like it does if there are no quotes but just in ESS-R mode.
Question
Is it possible to get ESS to do this? Perhaps by writing the function so that it will accept the query without a quote (and add the quotes within the function), or perhaps adding something to .emacs or ess.el?