RSQLite odbc dbDataType формат даты другой - PullRequest
0 голосов
/ 14 ноября 2018

Почему представление формата даты POSIXct отличается в одной и той же БД SQLite в зависимости от используемого драйвера? Версия драйвера ODBC 0.9996 для Windows: http://www.ch -werner.de / sqliteodbc /

library(tidyverse)
library(lubridate)
library(RSQLite)
library(odbc)
df <- tribble(~idx, ~date, 1, now())
df
# A tibble: 1 x 2
    idx date               
  <dbl> <dttm>             
1     1 2018-11-14 13:32:12
conFile <- dbConnect(RSQLite::SQLite(), "test.db")
# ODBC source test_db to be defined on the same file test.db with ODBC diver for Windows please
conOdbc <- dbConnect(odbc::odbc(), "test_db")
dbWriteTable(conFile, "dfFile", df)
dbWriteTable(conOdbc, "dfOdbc", df)
dfFile <- tbl(conFile, "dfFile")
dfOdbc <- tbl(conOdbc, "dfOdbc")
dfFile %>% collect()
# Source:   table<dfFile> [?? x 2]
# Database: sqlite 3.22.0 [C:\Users\zfgbe\Desktop\R\test.db]
    idx        date
  <dbl>       <dbl>
1     1 1542198732.
dfOdbc %>% collect()
# Source:   table<dfOdbc> [?? x 2]
# Database: SQLite
#   3.22.0[@C:\Users\zfgbe\Desktop\R\db\test.db/C:\Users\zfgbe\Desktop\R\db\test.db]
    idx     date
  <dbl>    <dbl>
1     1 2018
td <- now()
dbDataType(conFile, td)
[1] "REAL"
dbDataType(conOdbc, td)
[1] "NUMERIC"
...