| 12345678910111213141516171819202122232425262728 |
- """Check table columns"""
- import psycopg2
- conn = psycopg2.connect(
- host="192.168.3.143",
- port=5432,
- database="dataops",
- user="postgres",
- password="dataOps",
- )
- cur = conn.cursor()
- tables = ["test_sales_data", "test_user_statistics", "test_product_inventory"]
- for table in tables:
- cur.execute(
- """
- SELECT column_name FROM information_schema.columns
- WHERE table_name = %s ORDER BY ordinal_position
- """,
- (table,),
- )
- columns = [r[0] for r in cur.fetchall()]
- print(f"{table}: {columns}")
- cur.close()
- conn.close()
|