[Tutor] Proper SQLite cursor handling?

Cameron Simpson cs at cskk.id.au
Tue Jul 13 19:38:34 EDT 2021


On 13Jul2021 15:01, Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:
>On Mon, 12 Jul 2021 15:53:48 -0400, Dennis Lee Bieber
><wlfraed at ix.netcom.com> declaimed the following:
>	For the OP... DateTime handling is going to be tricky between 
>	SQLite3
>and Python.
>
>	SQLite3 documentation states that something declared "date" or
>"datetime" as data type is mapped to SQLite3 NUMERIC
>https://www.sqlite.org/datatype3.html section 2.2 and 3.1.1.
>
>	However... CURRENT_TIMESTAMP returns a formatted ISO date/time string,
>which SQLite3 will happily store in a nominally numeric field (SQLite3 will
>store anything in any field, possibly doing some conversions... string
>"123" in a numeric/integer field becomes actual integer 123).
>
>	The only way to get a UNIX type value is to use
>		strftime('%s', date/time value)
>and that is not allowed in DEFAULT or GENERATED AS clause in a table
>definition (something about dynamic clauses )

Personally I like to use UNIX timestamps. They're integers (or floats 
for higher precision) and are unambiguous. I can always render a date or 
date time string for them for presentation purposes.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Tutor mailing list