                              Package ‘sqliteutils’
                                          October 14, 2022
Title Utility Functions for 'SQLite'
Version 0.1.0
Description A tool for working with 'SQLite' databases. 'SQLite' has some idiosyncrasies and limita-
      tions that impose some hurdles to the R developer who is using this database as a repository. For in-
      stance, 'SQLite' doesn't have a date type and 'sqliteutils' has some functions to deal with that.
License MIT + file LICENSE
Suggests testthat (>= 3.0.0)
Config/testthat/edition 3
Encoding UTF-8
RoxygenNote 7.1.2
Imports RSQLite, DBI, dplyr, dbplyr, magrittr
NeedsCompilation no
Author Bruno Crotman [aut, cre]
Maintainer Bruno Crotman <crotman@gmail.com>
Repository CRAN
Date/Publication 2021-09-21 14:10:02 UTC
R topics documented:
         slu_date_to_r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .    2
         slu_date_to_sqlite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   2
Index                                                                                                     4
                                                    1
2                                                                                     slu_date_to_sqlite
  slu_date_to_r                Converts dates stored on ’SQLite’ to their original values
Description
    Converts dates stored on ’SQLite’ to their original values
Usage
    slu_date_to_r(date_sqlite)
Arguments
    date_sqlite         the numbers that result from inserting dates on ’SQLite’
Value
    the dates that were originally inserted
Examples
    data <- data.frame(date = as.Date("2021-09-18"))
    con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
    DBI::dbWriteTable(conn = con, name = "dates", value = data )
    data_from_bd <- DBI::dbReadTable(conn = con, name = "dates")
    original_date <- slu_date_to_r(data_from_bd$date)
    DBI::dbDisconnect(con)
  slu_date_to_sqlite           Converts dates to the numeric values as which they would be stored on
                               SQLite
Description
    Converts dates to the numeric values as which they would be stored on SQLite
Usage
    slu_date_to_sqlite(date_r)
Arguments
    date_r              dates as returned by as.Date() in R
slu_date_to_sqlite                                                                                3
Value
    integers that correspond to the numbers that are stored on SQLite when DBI:dbWriteTable is used
Examples
    con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
    data <- data.frame(
         date = as.Date("2021-09-19")
    )
    DBI::dbWriteTable(conn = con, name = "dates", value = data )
    data_from_bd <- dplyr::tbl(src = con, "dates") %>% dplyr::collect()
    data_with_sqlite_dates <- data %>%
    dplyr::mutate(
         date = slu_date_to_sqlite(date)
    )
    print(data_from_bd)
    print(data_with_sqlite_dates)
    DBI::dbDisconnect(con)
Index
slu_date_to_r, 2
slu_date_to_sqlite, 2
                      4
