import io, sys sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') import pymysql conn = pymysql.connect(host='8.129.84.155', port=3306, user='root', password='Itc@123456', database='crm', charset='utf8mb4', autocommit=True) cur = conn.cursor() cur.execute("SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema='crm' AND table_name LIKE '%customer%'") for r in cur.fetchall(): print('TABLE:', r) cur.execute("SELECT table_name FROM information_schema.tables WHERE table_schema='crm' ORDER BY table_name") print('ALL TABLES:', [r[0] for r in cur.fetchall()]) conn.close()