RSQLite odbc dbDataType date format different










0















Why is the representation of the POSIXct date format different on the same SQLite DB depending on the used driver?
The ODBC driver version 0.9996 for Windows is from:
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:UserszfgbeDesktopRtest.db]
idx date
<dbl> <dbl>
1 1 1542198732.
dfOdbc %>% collect()
# Source: table<dfOdbc> [?? x 2]
# Database: SQLite
# 3.22.0[@C:UserszfgbeDesktopRdbtest.db/C:UserszfgbeDesktopRdbtest.db]
idx date
<dbl> <dbl>
1 1 2018
td <- now()
dbDataType(conFile, td)
[1] "REAL"
dbDataType(conOdbc, td)
[1] "NUMERIC"









share|improve this question
























  • The two drivers serialize time values in different ways. Remember, there is no such thing as a date or time type in sqlite. The file one looks like it uses Unix time, the odbc one... Not sure unless the output of that table was truncated by the display code. sqlite.org/datatype3.html is essential reading about sqlite types and column affinities, though.

    – Shawn
    Nov 14 '18 at 13:25











  • Thx Shawn, I also found this link about the ODBC driver ch-werner.de/sqliteodbc/html/index.html I run into a problem by this different representation of the date format. What is the best way to represent dates in SQLite, as character?

    – Guido Berning
    Nov 14 '18 at 13:41











  • It seams that the Windows ODBC driver converts to single quoted string for the date format. By changing the configuration inside the Windows ODBC DNS for the test.db to use 'Julian Day conv.' this behaviour changes. But the values still differ. There for I send a mail to the developer of the driver it it's possible to add another configuration parameter to do a conversion from POSIXct representation as type real. (see value 1542198732 in the question).

    – Guido Berning
    Nov 14 '18 at 14:46
















0















Why is the representation of the POSIXct date format different on the same SQLite DB depending on the used driver?
The ODBC driver version 0.9996 for Windows is from:
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:UserszfgbeDesktopRtest.db]
idx date
<dbl> <dbl>
1 1 1542198732.
dfOdbc %>% collect()
# Source: table<dfOdbc> [?? x 2]
# Database: SQLite
# 3.22.0[@C:UserszfgbeDesktopRdbtest.db/C:UserszfgbeDesktopRdbtest.db]
idx date
<dbl> <dbl>
1 1 2018
td <- now()
dbDataType(conFile, td)
[1] "REAL"
dbDataType(conOdbc, td)
[1] "NUMERIC"









share|improve this question
























  • The two drivers serialize time values in different ways. Remember, there is no such thing as a date or time type in sqlite. The file one looks like it uses Unix time, the odbc one... Not sure unless the output of that table was truncated by the display code. sqlite.org/datatype3.html is essential reading about sqlite types and column affinities, though.

    – Shawn
    Nov 14 '18 at 13:25











  • Thx Shawn, I also found this link about the ODBC driver ch-werner.de/sqliteodbc/html/index.html I run into a problem by this different representation of the date format. What is the best way to represent dates in SQLite, as character?

    – Guido Berning
    Nov 14 '18 at 13:41











  • It seams that the Windows ODBC driver converts to single quoted string for the date format. By changing the configuration inside the Windows ODBC DNS for the test.db to use 'Julian Day conv.' this behaviour changes. But the values still differ. There for I send a mail to the developer of the driver it it's possible to add another configuration parameter to do a conversion from POSIXct representation as type real. (see value 1542198732 in the question).

    – Guido Berning
    Nov 14 '18 at 14:46














0












0








0








Why is the representation of the POSIXct date format different on the same SQLite DB depending on the used driver?
The ODBC driver version 0.9996 for Windows is from:
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:UserszfgbeDesktopRtest.db]
idx date
<dbl> <dbl>
1 1 1542198732.
dfOdbc %>% collect()
# Source: table<dfOdbc> [?? x 2]
# Database: SQLite
# 3.22.0[@C:UserszfgbeDesktopRdbtest.db/C:UserszfgbeDesktopRdbtest.db]
idx date
<dbl> <dbl>
1 1 2018
td <- now()
dbDataType(conFile, td)
[1] "REAL"
dbDataType(conOdbc, td)
[1] "NUMERIC"









share|improve this question
















Why is the representation of the POSIXct date format different on the same SQLite DB depending on the used driver?
The ODBC driver version 0.9996 for Windows is from:
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:UserszfgbeDesktopRtest.db]
idx date
<dbl> <dbl>
1 1 1542198732.
dfOdbc %>% collect()
# Source: table<dfOdbc> [?? x 2]
# Database: SQLite
# 3.22.0[@C:UserszfgbeDesktopRdbtest.db/C:UserszfgbeDesktopRdbtest.db]
idx date
<dbl> <dbl>
1 1 2018
td <- now()
dbDataType(conFile, td)
[1] "REAL"
dbDataType(conOdbc, td)
[1] "NUMERIC"






r sqlite odbc rsqlite






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 13:11







Guido Berning

















asked Nov 14 '18 at 12:52









Guido BerningGuido Berning

296




296












  • The two drivers serialize time values in different ways. Remember, there is no such thing as a date or time type in sqlite. The file one looks like it uses Unix time, the odbc one... Not sure unless the output of that table was truncated by the display code. sqlite.org/datatype3.html is essential reading about sqlite types and column affinities, though.

    – Shawn
    Nov 14 '18 at 13:25











  • Thx Shawn, I also found this link about the ODBC driver ch-werner.de/sqliteodbc/html/index.html I run into a problem by this different representation of the date format. What is the best way to represent dates in SQLite, as character?

    – Guido Berning
    Nov 14 '18 at 13:41











  • It seams that the Windows ODBC driver converts to single quoted string for the date format. By changing the configuration inside the Windows ODBC DNS for the test.db to use 'Julian Day conv.' this behaviour changes. But the values still differ. There for I send a mail to the developer of the driver it it's possible to add another configuration parameter to do a conversion from POSIXct representation as type real. (see value 1542198732 in the question).

    – Guido Berning
    Nov 14 '18 at 14:46


















  • The two drivers serialize time values in different ways. Remember, there is no such thing as a date or time type in sqlite. The file one looks like it uses Unix time, the odbc one... Not sure unless the output of that table was truncated by the display code. sqlite.org/datatype3.html is essential reading about sqlite types and column affinities, though.

    – Shawn
    Nov 14 '18 at 13:25











  • Thx Shawn, I also found this link about the ODBC driver ch-werner.de/sqliteodbc/html/index.html I run into a problem by this different representation of the date format. What is the best way to represent dates in SQLite, as character?

    – Guido Berning
    Nov 14 '18 at 13:41











  • It seams that the Windows ODBC driver converts to single quoted string for the date format. By changing the configuration inside the Windows ODBC DNS for the test.db to use 'Julian Day conv.' this behaviour changes. But the values still differ. There for I send a mail to the developer of the driver it it's possible to add another configuration parameter to do a conversion from POSIXct representation as type real. (see value 1542198732 in the question).

    – Guido Berning
    Nov 14 '18 at 14:46

















The two drivers serialize time values in different ways. Remember, there is no such thing as a date or time type in sqlite. The file one looks like it uses Unix time, the odbc one... Not sure unless the output of that table was truncated by the display code. sqlite.org/datatype3.html is essential reading about sqlite types and column affinities, though.

– Shawn
Nov 14 '18 at 13:25





The two drivers serialize time values in different ways. Remember, there is no such thing as a date or time type in sqlite. The file one looks like it uses Unix time, the odbc one... Not sure unless the output of that table was truncated by the display code. sqlite.org/datatype3.html is essential reading about sqlite types and column affinities, though.

– Shawn
Nov 14 '18 at 13:25













Thx Shawn, I also found this link about the ODBC driver ch-werner.de/sqliteodbc/html/index.html I run into a problem by this different representation of the date format. What is the best way to represent dates in SQLite, as character?

– Guido Berning
Nov 14 '18 at 13:41





Thx Shawn, I also found this link about the ODBC driver ch-werner.de/sqliteodbc/html/index.html I run into a problem by this different representation of the date format. What is the best way to represent dates in SQLite, as character?

– Guido Berning
Nov 14 '18 at 13:41













It seams that the Windows ODBC driver converts to single quoted string for the date format. By changing the configuration inside the Windows ODBC DNS for the test.db to use 'Julian Day conv.' this behaviour changes. But the values still differ. There for I send a mail to the developer of the driver it it's possible to add another configuration parameter to do a conversion from POSIXct representation as type real. (see value 1542198732 in the question).

– Guido Berning
Nov 14 '18 at 14:46






It seams that the Windows ODBC driver converts to single quoted string for the date format. By changing the configuration inside the Windows ODBC DNS for the test.db to use 'Julian Day conv.' this behaviour changes. But the values still differ. There for I send a mail to the developer of the driver it it's possible to add another configuration parameter to do a conversion from POSIXct representation as type real. (see value 1542198732 in the question).

– Guido Berning
Nov 14 '18 at 14:46













0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300706%2frsqlite-odbc-dbdatatype-date-format-different%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300706%2frsqlite-odbc-dbdatatype-date-format-different%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto