3 # SPDX-FileCopyrightText: 2023 Andrew Engelbrecht
5 # SPDX-License-Identifier: GPL-3.0-or-later
10 mydb
= mysql
.connector
.connect(
17 mycursor0
= mydb
.cursor(buffered
=True)
18 mycursor1
= mydb
.cursor(buffered
=True)
19 mycursor2
= mydb
.cursor(buffered
=True)
23 select c.id, c.external_identifier, x.*
24 from civicrm_contact c inner join civicrm_email e on c.id = e.contact_id
26 select i.id, i.external_identifier, j.email, count(*) as qty
27 from civicrm_contact i inner join civicrm_email j on i.id = j.contact_id
30 ) x on e.email = x.email and c.external_identifier is not NULL and x.external_identifier is not NULL and c.external_identifier != x.external_identifier;
38 mycursor1
.execute("select count(*) from civicrm_dedupe_exception where (contact_id1 = %s and contact_id2 = %s) or (contact_id1 = %s and contact_id2 = %s);", (id1
, id2
, id2
, id1
))
40 count
= mycursor1
.fetchone()[0]
42 print('inserting:', id1
, id2
)
43 mycursor2
.execute("INSERT INTO civicrm_dedupe_exception (contact_id1, contact_id2) VALUES (%s, %s)", (id1
, id2
))
45 #print("only do one for now, for debugging purposes")