30 lines
737 B
Python
30 lines
737 B
Python
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 column_name FROM information_schema.columns WHERE table_name = 'bi_vala_seasonal_ticket'")
|
||
columns = cur.fetchall()
|
||
print("bi_vala_seasonal_ticket表字段:")
|
||
for col in columns:
|
||
print(col[0])
|
||
|
||
cur.close()
|
||
conn.close()
|