# NOT RUN {
con <- dbConnect(SQLite(), ":memory:")
dbWriteTable(con, "arrests", datasets::USArrests)
# Run query to get results as dataframe
dbGetQuery(con, "SELECT * FROM arrests limit 3")
# Send query to pull requests in batches
res <- dbSendQuery(con, "SELECT * FROM arrests")
data <- fetch(res, n = 2)
data
dbHasCompleted(res)
dbListResults(con)
dbClearResult(res)
# Use dbSendPreparedQuery/dbGetPreparedQuery for "prepared" queries
dbGetPreparedQuery(con, "SELECT * FROM arrests WHERE Murder < ?",
data.frame(x = 3))
dbGetPreparedQuery(con, "SELECT * FROM arrests WHERE Murder < (:x)",
data.frame(x = 3))
dbDisconnect(con)
# }
Run the code above in your browser using DataLab