I have a Shiny app in RStudio, which works with data I retrieve from a mysql database.
The connection to mysql and the queries are in a file outside the app, so I can create dataframes.
But when I copy the connection to mysql and the sql queries into server.R of the Shiny app, the app skips the queries and gives an error that the dataframe does not exist (Error : object 'tickets' not found).
So the mysql query works from outside server.R, but not from server.R. What am I doing wrong?
Here's a sample of my server.R and ui.R :
server.R
library(shiny) library(RMySQL) library(ggplot2) #library(ggiraph) library(lubridate) ##Connect to Redmine db con <- dbConnect(MySQL(), user = '#', password = '#', host = '#', dbname='#') tickets<-dbGetQuery(con, "Select * from table") issues_speed_unique<-unique(na.omit(dbGetQuery(con,"Select * from table2"))) dbDisconnect (con) some aggregations.... shinyServer( function(input,output){ output$tickets_week<-renderPlot( ggplot(data = subset(tickets, ui.R
library(shiny) library(ggplot2) #library(ggiraph) #library(htmltools) library(lubridate) shinyUI(fluidPage(
print(tickets)under the query and run the app, does the data frame print to console?shinyServer( function(input,output){.