Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
adkinsrs committed Aug 13, 2024
1 parent a7c1f06 commit cd10e4a
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions bin/remove_duplicate_layout_displays.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@
conn = geardb.Connection()
cursor = conn.get_cursor()

# print row count
qry = "SELECT COUNT(*) FROM layout_displays"
cursor.execute(qry)
row_count = cursor.fetchone()[0]
print("Row count before deletion: {}".format(row_count))

# https://www.tutorialspoint.com/mysql/mysql-delete-duplicate-records.htm
qry = """
DELETE FROM layout_displays ld1
DELETE ld1 FROM layout_displays ld1
INNER JOIN layout_displays ld2
WHERE ld1.layout_id = ld2.layout_id
AND ld1.display_id = ld2.display_id
Expand All @@ -27,4 +33,15 @@
AND ld1.grid_height = ld2.grid_height
AND ld1.id > ld2.id
"""
cursor.execute(qry)
cursor.execute(qry)

cursor.commit()

# print row count
qry = "SELECT COUNT(*) FROM layout_displays"
cursor.execute(qry)
row_count = cursor.fetchone()[0]
print("Row count after deletion: {}".format(row_count))

cursor.close()
conn.close()

0 comments on commit cd10e4a

Please sign in to comment.