find_tables.py 768 Bytes
# -*- coding: utf-8 -*-
import pyodbc

conn_str = 'DRIVER={ODBC Driver 17 for SQL Server};SERVER=192.168.1.91,1433;DATABASE=wms4_global;UID=sa;PWD=HHrobot123.'
conn = pyodbc.connect(conn_str)
cursor = conn.cursor()

# 查看所有表
print("=" * 80)
print("所有表名:")
print("=" * 80)
cursor.execute("""
    SELECT TABLE_NAME
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_TYPE = 'BASE TABLE'
    ORDER BY TABLE_NAME
""")
tables = [row[0] for row in cursor.fetchall()]
for t in tables:
    print(f"  {t}")

# 重点查看与组盘、容器相关的表
print("\n" + "=" * 80)
print("组盘/容器相关表:")
print("=" * 80)
for t in tables:
    if 'container' in t.lower() or 'group' in t.lower() or 'inout' in t.lower():
        print(f"  {t}")

conn.close()