Getting column names from a cursor using ODBC module?

Michael Mabin d3vvnull at gmail.com
Sun Jun 22 11:38:23 EDT 2008


The pyodb module doesn't implement this behavior.  You would have to create
a dictionary of column positions and column names in advance.

On Sat, Jun 21, 2008 at 3:52 PM, Chris <cwitts at gmail.com> wrote:

> On Jun 21, 3:58 pm, dana... at yahoo.com wrote:
> > Is there any way to retrieve column names from a cursor using the ODBC
> > module? Or must I, in advance, create a dictionary of column position
> > and column names for a particular table before I can access column
> > values by column names? I'd prefer sticking with the ODBC module for
> > now because it comes standard in Python.
> >
> > I'm using Python 2.4 at the moment.
> >
> > Thanks.
>
> You should be able to do
>
> column_names = [d[0] for d in cursor.description]
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
| _ | * | _ |
| _ | _ | * |
| * | * | * |
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080622/28084d9a/attachment-0001.html>


More information about the Python-list mailing list