Files
2026-06-20 15:50:24 +08:00

39 lines
1.3 KiB
Python

import psycopg2
c = psycopg2.connect(host='47.92.216.173', port=7654, user='postgres', password='zhangsan', database='xian_new')
cur = c.cursor()
tables = ['lifeline_outfall', 'lifeline_pipe', 'risk_census_population', 'hazard_waterlogging', 'sx_street', 'sx_xa_county']
print("=== qgis schema ===")
for t in tables:
try:
cur.execute(f'SELECT COUNT(*) FROM qgis."{t}"')
count = cur.fetchone()[0]
cur.execute(f"SELECT GeometryType(geom) FROM qgis.\"{t}\" LIMIT 1")
g = cur.fetchone()
print(f" qgis.{t}: {count} 行, geom={g[0] if g else 'N/A'}")
except Exception as e:
print(f" qgis.{t}: 不存在")
print("\n=== base schema (检查积水点原始表) ===")
for t in ['hazard_waterlogging']:
try:
cur.execute(f'SELECT COUNT(*) FROM base."{t}"')
print(f" base.{t}: {cur.fetchone()[0]}")
except:
print(f" base.{t}: 不存在")
# 查找所有含 water 或 hazard 的表
print("\n=== 搜索含 water/hazard 的表 ===")
cur.execute("""
SELECT table_schema, table_name
FROM information_schema.tables
WHERE (table_name LIKE '%water%' OR table_name LIKE '%hazard%')
AND table_schema IN ('qgis', 'base', 'public')
ORDER BY table_schema, table_name
""")
for r in cur.fetchall():
print(f" {r[0]}.{r[1]}")
c.close()