# \donttest{
# Create an in-memory database and connection
conn <- kuzu_connection(":memory:")
# Create or connect to an on-disk database
temp_db_dir <- file.path(tempdir(), "kuzu_disk_example_db")
db_path <- file.path(temp_db_dir, "kuzu_db")
dir.create(temp_db_dir, recursive = TRUE, showWarnings = FALSE)
# Establish connection
conn_disk <- kuzu_connection(db_path)
# Ensure the database is shut down and removed on exit
on.exit({
# Access the 'db' object from the reticulate main module
main <- reticulate::import_main()
if (!is.null(main$db)) {
main$db$shutdown()
}
unlink(temp_db_dir, recursive = TRUE)
})
# }
Run the code above in your browser using DataLab