You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

21 lines
946 B

# -*- 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("SHOW TABLES")
tabs = [r[list(r)[0]] for r in cur.fetchall()]
print('all tables:', tabs)
utabs = [t for t in tabs if 'user' in t.lower()]
for t in utabs:
try:
cur.execute("SHOW COLUMNS FROM " + t)
print(t, 'cols:', [r['Field'] for r in cur.fetchall()])
except Exception as e: print(t, 'ERR', e)
for t in utabs:
try:
cur.execute("SELECT * FROM " + t + " WHERE user_id IN (739564171091247104, 744842318024015872) OR id IN (739564171091247104, 744842318024015872)")
for r in cur.fetchall(): print(t, r)
except Exception as e: pass
conn.close()