[Tutor] Proper SQLite cursor handling?
Cameron Simpson
cs at cskk.id.au
Thu Jul 15 20:05:09 EDT 2021
On 14Jul2021 12:28, Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:
>On Wed, 14 Jul 2021 09:38:34 +1000, Cameron Simpson <cs at cskk.id.au>
>declaimed the following:
>>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.
>>
> That's what I was expecting, especially as SQLite associates "datetime"
>as a NUMERIC type...
>
> But to get a UNIX timestamp in SQLite requires something like
>
> strftime("%s", 'now', 'unixepoch')
>
>(which, technically, is still returning a string, but as "seconds" is all
>numeric, should convert it to integer storage).
>
> That can't be specified in "default" or "generated as" clauses, meaning
>having to create triggers to set a value.
Can it not? From https://sqlite.org/lang_createtable.html under "The
DEFAULT clause":
If the default value of a column is an expression in parentheses,
then the expression is evaluated once for each row inserted and the
results used in the new row.
You may be better off than you thought.
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Tutor
mailing list