RSQLite & targets in R

21 views Asked by At

I want to create a database for efficient queries, but using with targets. Is there a better alternative to open and close connection?

  tar_target(database, format = "file", command = {
    db_file_name <- Sys.getenv("DB_PATH", "database.sqlite")
    db <- dbConnect(SQLite(), db_file_name)
    
    dta_to_db(db, crsp_daily, "crsp_daily")
    dta_to_db(db, crsp_monthly, "crsp_monthly")
    dta_to_db(db, analist_coverage, "analist_coverage")
    dbwriteTable(db, industry_classification, "industry_classification")
    
    dbDisconnect(db)
    db_file_name
  })
0

There are 0 answers