No data inserted with this WHERE NOT EXISTS expression?
Your condition compares the column value to itself:

WHERE NOT EXISTS(SELECT code FROM subject WHERE code = code)


Boils down to:

WHERE NOT EXISTS(SELECT FROM subject WHERE code IS NOT NULL)


IOW, it's always true as soon as there is a single row in the table with code IS NOT NULL. I don't think that's intended.

Guess you want something like:

'''INSERT INTO subject (created, modified, code, name, units)
   SELECT current_timestamp, current_timestamp, %s, %s, %s
   WHERE NOT EXISTS(SELECT code FROM subject WHERE code = %s)'''
, (row['scode'], row['sname'], row['sunits'], row['scode']))

And that's not fit for concurrent write load. I suggest to create the missing UNIQUE constraint on (code) and use INSERT .. ON CONFLICT ... DO NOTHING if at all possible. If the table is big, you'll want an index on code for performance, anyway.