mxODBC question

Steve Holden sholden at holdenweb.com
Mon Feb 12 07:45:07 EST 2001


"Scott Hathaway" <slhath at home.com> wrote in message
news:nTDh6.66287$bb.1038987 at news1.rdc1.tx.home.com...
> I am using mxODBC to access db's with no problem, but I have a question.
If
> I use a sql call as follows:
>
> select username from users;
>
> Then, I make a call as follows:
>
> data = c.fetchall()
>
> Then, to access the first value of the first (and only) field, I have to
> use:
>
> theValue = data[0][0]
>
> This is ugly.  Is there a way to do something like:
>
> theValue = data[0]['firstname']
>
> Or anything more easy to discern for code readability?
>
> Thanks,
> Scott
>
The best tool I've come across for this is at

    http://www.lyra.org/greg/python/dtuple.py

It has worked in a number of such contexts for me, allowing access by
attribute name or index, with a well-thought-out set of methods..

regards
 Steve





More information about the Python-list mailing list