Files
feiqiu-ETL/tmp/list_all_tables.py

18 lines
451 B
Python

import psycopg2
dsn = 'postgresql://local-Python:Neo-local-1991125@100.64.0.4:5432/LLZQ-test'
conn = psycopg2.connect(dsn)
cur = conn.cursor()
cur.execute("""
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'billiards_dwd'
ORDER BY table_name
""")
tables = [row[0] for row in cur.fetchall()]
print('Tables in billiards_dwd:')
for t in tables:
print(t)
print(f'\nTotal: {len(tables)} tables')
conn.close()