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 [EMAIL PROTECTED] 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

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to