Jaymon / prom

A PostgreSQL or SQLite orm for Python
MIT License
22 stars 4 forks source link

Better way to list columns in Postgres #153

Open Jaymon opened 1 year ago

Jaymon commented 1 year ago

via

SELECT column_name FROM information_schema.columns where table_name = '<TABLE NAME>'

This seems way better than the horrible query I'm using right now

Search

Jaymon commented 1 year ago
Jaymon commented 1 year ago

Looks like information_schema.columns doesn't give primary key information. I could combine the output of information_schema.columns with information_schema.table_constraints to make this work but I'm not sure it's worth it.

This is the postgres wiki solution on getting primary key