| Server IP : 119.195.102.159 / Your IP : 216.73.217.134 Web Server : nginx/1.18.0 System : Linux picell 5.15.0-181-generic #191-Ubuntu SMP Fri May 22 19:09:02 UTC 2026 x86_64 User : altablue ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /tmp/ |
Upload File : |
import mysql.connector
try:
conn = mysql.connector.connect(
host="localhost",
user="haeyul2",
password="Yx3(Tq!Q5qr9YQer",
database="haeyul2",
charset='utf8'
)
cursor = conn.cursor(dictionary=True)
print("=== 1. DB Charset / Collation Info ===")
cursor.execute("SHOW VARIABLES LIKE 'character_set%';")
for r in cursor.fetchall():
print(f" {r['Variable_name']}: {r['Value']}")
print("\n=== 2. koweb_blog_section Contents ===")
cursor.execute("SELECT * FROM koweb_blog_section ORDER BY no ASC;")
sections = cursor.fetchall()
for s in sections:
print(s)
print("\n=== 3. Total Posts in koweb_blog ===")
cursor.execute("SELECT COUNT(*) as cnt FROM koweb_blog;")
print("Total count in koweb_blog:", cursor.fetchone()['cnt'])
print("\n=== 4. Counts grouped by no_section (JOIN koweb_blog_section s.no) ===")
cursor.execute('''
SELECT
s.no as sec_no,
s.title as sec_title,
COUNT(b.no) as cnt_by_no_section
FROM koweb_blog_section s
LEFT JOIN koweb_blog b ON b.no_section = s.no
GROUP BY s.no, s.title
ORDER BY s.no ASC;
''')
for r in cursor.fetchall():
print(r)
print("\n=== 5. Counts grouped by b.section string column in koweb_blog ===")
cursor.execute('''
SELECT
section,
COUNT(*) as cnt_by_section_str
FROM koweb_blog
GROUP BY section;
''')
for r in cursor.fetchall():
print(r)
print("\n=== 6. Posts where no_section is NULL, 0, or invalid ===")
cursor.execute('''
SELECT no, title, section, no_section, reg_date
FROM koweb_blog
WHERE no_section IS NULL OR no_section = 0 OR no_section NOT IN (SELECT no FROM koweb_blog_section);
''')
orphan_posts = cursor.fetchall()
print(f"Orphan posts count: {len(orphan_posts)}")
for p in orphan_posts[:10]:
print(p)
print("\n=== 7. Comparing section string vs section ID in koweb_blog ===")
cursor.execute('''
SELECT
b.no, b.title, b.section as b_section_str, b.no_section, s.title as sec_title_from_id
FROM koweb_blog b
LEFT JOIN koweb_blog_section s ON b.no_section = s.no
WHERE b.section != s.title OR (b.section IS NOT NULL AND s.title IS NULL);
''')
mismatches = cursor.fetchall()
print(f"Mismatched count: {len(mismatches)}")
for m in mismatches[:15]:
print(m)
cursor.close()
conn.close()
except Exception as e:
print("MySQL Error:", e)