Re: list fieldnames in table? (from PHP)
От | GreyGeek |
---|---|
Тема | Re: list fieldnames in table? (from PHP) |
Дата | |
Msg-id | g5Ffd.12092$T02.2334@twister.rdc-kc.rr.com обсуждение исходный текст |
Ответ на | list fieldnames in table? (from PHP) (Miles Keaton <mileskeaton@gmail.com>) |
Список | pgsql-general |
Miles Keaton wrote: > Is there a simple way to list fieldnames in a table, from PHP? > > When on the command-line, I just do \d tablename > > But how to get the fieldnames from PHP commands? > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly Here is one way Python can do it through ODBC: # fetch descriptions to create field name dictionaries try: ci = db.cursor() ci.execute("select * from PERSINFO where 1 = 0") column = 0 for d in ci.description: # key : value PersFields[d[0]] = column # field name : position PersPos[column] = d[0] # position : field name d[0] PersTypes[d[0]] = d[1] # field name : data type d[1] PersPrec[d[0]] = d[4] # field name : precision d[4] PersScale[d[0]] = d[5] # field name : scale d[5] PersVals[column] = None # position : value (init=None) column += 1 ci.close() ci = None -- -- GreyGeek
В списке pgsql-general по дате отправления: