I'm attempting to start off a database (testing with sqlite3), but I seem to be unable to do a SET
inside a trigger. I get the following error: OperationalError: near "SET": syntax error
.
An insert from inside the trigger works, so I'm just curious what I'm doing wrong here?
import sqlite3
conn = sqlite3.connect(':memory:')
c = conn.cursor()
c.execute("""CREATE TABLE Programs (
id INTEGER PRIMARY KEY,
name VARCHAR(64) NOT NULL,
time_added INTEGER
);""")
c.execute("""CREATE TRIGGER program_time_added AFTER INSERT ON Programs
FOR EACH ROW
BEGIN
SET new.time_added = UNIX_TIMESTAMP(NOW());
END;""")
c.execute('INSERT INTO Programs (name) VALUES (?)', ['name'])