python - Meta commands in Psycopg2 - \d not working -


i wish list column names of table using psycopg2 package of python (2.7). unable execute following query -

cur.execute("\d my_table"); psycopg2.programmingerror: syntax error @ or near "\" 

is there alternate how can list column names of table using psycopg2 ? please point out duplicates. !

command line psql has shortcuts \d it's not part of sql. need query information_schema:

select column_name information_schema.columns table_name = 'my_table'; 

edit: it's important information command line psql -e echo sql queries used implement \d , other backslash commands (whenever use 1 of them in psql prompt) @piro has written in comment. way want easily.
thanks @piro!


Comments