con <- dbConnect(SQLite(), ":memory:")
data(USArrests)
dbWriteTable(con, "arrests", USArrests)
res <- dbSendQuery(con, "SELECT * from arrests")
data <- fetch(res, n = 2)
data
dbClearResult(res)
dbGetQuery(con, "SELECT * from arrests limit 3")
tryCatch(dbGetQuery(con, "SELECT * FROM tableDoesNotExist"),
error=function(e) { print("caught") })
dbGetException(con)
Run the code above in your browser using DataCamp Workspace