if (FALSE) { # rlang::is_installed("RSQLite")
# Connect to a database
con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
DBI::dbWriteTable(con, "mtcars", mtcars)
# Create a DBI source
db_source <- DBISource$new(con, "mtcars")
# Get database type
db_source$get_db_type() # Returns "SQLite"
# Execute a query
result <- db_source$execute_query("SELECT * FROM mtcars WHERE mpg > 25")
# Note: cleanup() will disconnect the connection
# If you want to keep the connection open, don't call cleanup()
db_source$cleanup()
}
Run the code above in your browser using DataLab