Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymysql
- conn = pymysql.connect(host="******", user="******", password="******", db="******")
- def test(table):
- print(f"SELECT * FROM {table} WHERE pid NOT IN (")
- pids = []
- with conn.cursor() as cur:
- cur.execute(f"SELECT pid FROM {table}")
- for r in cur:
- pids.append(r[0])
- cur.close()
- error_count = 0
- for pid in pids:
- with conn.cursor() as cur:
- try:
- cur.execute(f"SELECT * FROM {table} WHERE pid = %s", (pid,))
- r = cur.fetchone()
- except:
- print(f"{pid},", end="")
- error_count += 1
- if error_count == 20:
- print()
- finally:
- cur.close()
- print("-1);\n")
- try:
- test("student_photos")
- finally:
- conn.close()
Add Comment
Please, Sign In to add comment