douyinWEB/scripts/_schema_check.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-04 22:42:40 -05:00

48 lines
1.4 KiB
Python

import paramiko
HOST = "107.173.30.245"
USER = "root"
PASSWORD = "Xiao4669805"
DB_PATH = "/opt/douyinWEB/backend/data/monitor.db"
SCHEMA_PY = r"""
import sqlite3
conn = sqlite3.connect('/opt/douyinWEB/backend/data/monitor.db')
for tbl in ['rooms','sessions','events','channel_groups']:
print(f'\n--- {tbl} columns ---')
for r in conn.execute(f'PRAGMA table_info({tbl})'):
print(f' {r[0]} {r[1]} {r[2]}')
# rooms sample
print('\n--- rooms sample (first 5) ---')
cols = [r[1] for r in conn.execute('PRAGMA table_info(rooms)')]
print('cols:', cols)
for r in conn.execute('SELECT * FROM rooms LIMIT 5'):
print(dict(zip(cols, r)))
# channel_groups
print('\n--- channel_groups all ---')
cols = [r[1] for r in conn.execute('PRAGMA table_info(channel_groups)')]
print('cols:', cols)
for r in conn.execute('SELECT * FROM channel_groups'):
print(dict(zip(cols, r)))
"""
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(HOST, 22, USER, PASSWORD, timeout=30, allow_agent=False, look_for_keys=False)
sftp = c.open_sftp()
with sftp.open("/tmp/_schema.py", "w") as f:
f.write(SCHEMA_PY)
sftp.close()
_s, out, err = c.exec_command("python3 /tmp/_schema.py", timeout=30)
import sys
sys.stdout.buffer.write(out.read())
sys.stdout.buffer.write(b"\n")
if err.read().decode().strip():
print("ERR:", err.read().decode().strip()[:300])
c.close()