sql = ''' CREATE TABLE IF NOT EXISTS sites.hist_id_site ( id serial4 NOT NULL, id_site_old varchar(10) NOT NULL, id_site_new varchar(10) NOT NULL, "date" timestamp NOT NULL DEFAULT NOW(), CONSTRAINT hist_id_site_pkey PRIMARY KEY (id), CONSTRAINT hist_id_site_un UNIQUE (id_site_old, id_site_new) );''' with con.begin() as cnx: cnx.execute(sql)