import pymysql
c=pymysql.connect(host="10.0.0.11",port=3306,user="java_osc",password="56Wp96Z6bS3kBpBf",database="oscdb",connect_timeout=4,read_timeout=20,write_timeout=20,charset="utf8mb4")
cur=c.cursor()
def tryq(label,sql):
    try:
        cur.execute(sql); rows=cur.fetchall(); print("=====",label,"ROWS",len(rows))
        for r in rows: print(" R",str(r)[:800])
    except Exception as e: print("=====",label,"ERR",str(e)[:200])
tryq("drafts_count","SELECT COUNT(*) FROM osc_drafts")
tryq("drafts_recent","SELECT id,space,title,LEFT(content,300),save_time FROM osc_drafts ORDER BY id DESC LIMIT 20")
tryq("drafts_flag","SELECT id,space,title,LEFT(content,300),save_time FROM osc_drafts WHERE content LIKE '%flag{%' OR title LIKE '%flag%' LIMIT 10")
tryq("blogs_recent","SELECT id,space,title,LEFT(content,200),create_time FROM osc_blogs ORDER BY id DESC LIMIT 10")
tryq("news_recent","SELECT id,title,LEFT(detail,200),create_time FROM osc_news ORDER BY id DESC LIMIT 10")
tryq("spaces_recent","SELECT id,ident,name,LEFT(detail,200),create_time FROM osc_spaces ORDER BY id DESC LIMIT 10")
c.close()
