I want to move data from MySQL to PostgreSQL. I am using mysql.connector and psycopg2 for querying the two databases. When I run
WHERE NOT EXISTS for my PostgreSQL DB, it's doesn't insert the data from MySQL.
The subject table doesn't have a unique column so I am using
WHERE NOT EXISTS instead of
curr_msql.execute('''SELECT scode, sname sunits FROM subject_table''') for row in curr_msql: curr_pgsql.execute('''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 = code) ''', (row['scode'], row['sname'], row['sunits']))
I am not getting any error when running the query but the data are not getting inserted.