为什么在同一SQLite DB上POSIXct日期格式的表示形式取决于所使用的驱动程序而不同? Windows的ODBC驱动程序0.9996版本来自: 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"