SQLite Forum

Can DEFAULT be the only possible value?
datetime('now', 'localtime') is non-deterministic and not permitted in a GENERATED ALWAYS clause.

Get rid of the parameters and the error will vanish.

SQLite version 3.34.0 2020-10-11 17:33:45
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> create table log(dt text as (datetime()) stored, event text not null);
sqlite> insert into log values ('xxx');
sqlite> select * from log;
│         dt          │ event │
│ 2020-10-11 19:06:00 │ xxx   │

All the datetime functions are "weird" with respect to whether or not they are supported in GENERATED ALWAYS expressions or index expressions and the support decisions are arbitrary.  (The default builtin datetime functions include date, time, datetime, strftime and julianday)

For example, you can use datetime() in a GENERATED ALWAYS but not datetime('now') even though they are 100% identical.

This is generally so that the SQL syntactic sugar CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP will work.

If you want to use 'localtime' you must convert it at retrieval time.  This is because the 'localtime' is subject to the whim of politicians and sorcerers and what you think of as the localtime now may not be the same tomorrow.