I use R, MySQL, Sweave and LaTeX to create reports that query the database. My problem is that since the R code is embedded in the .Rnw file, where I don't seem to control the multi-line generation.
Paste the following R code:
library(RMySQL) con <- dbConnect(MySQL(), user='test_user', dbname='sakila', host='localhost', password='password') data <- dbReadTable(con, 'film_list') query <-(' SELECT category, count(FID) AS Number FROM film_list GROUP by category') Cat <- dbGetQuery(con, query) Cat
Then I get the following output in the PDF generated by Sweave:
> library(RMySQL) > con <- dbConnect(MySQL(), user = "test_user", dbname = "sakila", + host = "localhost", password = "password") > data <- dbReadTable(con, "film_list") > query <- ("\nSELECT category, count(FID) AS Number \nFROM film_list \nGROUP by category") > Cat <- dbGetQuery(con, query) > Cat
As a result, the SELECT query is executed from the page.
Is there a way for LaTeX output to represent the SQL query when it was written?
source share