# -*- coding: utf-8 -*- import pymysql, io, sys sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', line_buffering=True) conn = pymysql.connect(host='8.129.84.155', port=3306, user='root', password='Itc@123456', database='crm', charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) cur = conn.cursor() cur.execute("SELECT id, customer_name, archive_status, owner_user_id FROM customer WHERE customer_name LIKE 'e2c-dr-imp%'") for r in cur.fetchall(): print(r) print('---- oplog of e2c-dr-imp% customers ----') cur.execute("SELECT customer_id, action, detail FROM customer_oplog WHERE customer_id IN (SELECT id FROM customer WHERE customer_name LIKE %s) ORDER BY id DESC LIMIT 8", ('e2c-dr-imp%',)) for r in cur.fetchall(): print(r) print('---- transfer bills (recent) ----') cur.execute("SELECT id, transfer_no, status, reason, to_director_id, total_count, assigned_count, create_time FROM customer_transfer ORDER BY id DESC LIMIT 3") for r in cur.fetchall(): print(r) conn.close()