ai_member_xiaoxi/scripts/check_tables.py
2026-04-23 08:00:02 +08:00

31 lines
789 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import psycopg2
# 读取密码
DB_PASSWORD = ""
with open('/root/.openclaw/workspace/secrets.env', 'r') as f:
for line in f:
if line.startswith('PG_ONLINE_PASSWORD='):
DB_PASSWORD = line.strip().split('=', 1)[1].strip('"\'')
break
# 数据库连接
conn = psycopg2.connect(
host='bj-postgres-16pob4sg.sql.tencentcdb.com',
port=28591,
user='ai_member',
password=DB_PASSWORD,
database='vala_bi'
)
cur = conn.cursor()
# 查询所有表
cur.execute("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'")
tables = cur.fetchall()
print("vala_bi库public模式下的表")
for table in tables:
if 'seasonal' in table[0] or 'ticket' in table[0]:
print(f"{table[0]}")
cur.close()
conn.close()