Skip to content

Instantly share code, notes, and snippets.

@lxneng
Last active August 24, 2021 03:22

Revisions

  1. lxneng revised this gist Aug 24, 2021. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion mysql-big-deletes.py
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,14 @@

    if __name__ == '__main__':
    ret = 1
    conn = pymysql.connect(host='tidb-cluster.dm', port=4000, user='dm', password=os.getenv('DBPW'), db='dm', charset='utf8mb4', autocommit=True)
    conn = pymysql.connect(
    host='tidb-cluster.dm',
    port=4000,
    user='dm',
    password=os.getenv('DBPW'),
    db='dm',
    charset='utf8mb4',
    autocommit=True)
    with conn.cursor() as cur:
    while ret:
    ret = cur.execute("delete from <bigdatatable> where <conditions> limit 200000")
  2. lxneng created this gist Aug 24, 2021.
    11 changes: 11 additions & 0 deletions mysql-big-deletes.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    import os
    import pymysql


    if __name__ == '__main__':
    ret = 1
    conn = pymysql.connect(host='tidb-cluster.dm', port=4000, user='dm', password=os.getenv('DBPW'), db='dm', charset='utf8mb4', autocommit=True)
    with conn.cursor() as cur:
    while ret:
    ret = cur.execute("delete from <bigdatatable> where <conditions> limit 200000")
    print(ret)