gaoluyang
11 小时以前 e40a608ef9bf51db294d8eefada6a8e2e80cebca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from read_log_times import connect
import json
 
with connect() as c:
    with c.cursor() as q:
        queries = [
            "SHOW COLUMNS FROM crm_customer LIKE 'auto_pool_enabled'",
            "SELECT COUNT(*) total, SUM(owner_user_id IS NULL) no_owner, SUM(owner_user_id=0) zero_owner, SUM(auto_pool_enabled=1) enabled, SUM(auto_pool_enabled=0) disabled, SUM(auto_pool_enabled IS NULL) unset FROM crm_customer WHERE deleted=0",
            "SELECT owner_user_id IS NULL no_owner, auto_pool_enabled+0 enabled, COUNT(*) count FROM crm_customer WHERE deleted=0 GROUP BY owner_user_id IS NULL, auto_pool_enabled",
            "SELECT id,code,status FROM system_role WHERE code IN ('super_admin','crm_admin') AND deleted=0",
        ]
        for sql in queries:
            q.execute(sql)
            print(json.dumps({'sql': sql, 'rows': q.fetchall()}, ensure_ascii=False, default=str))