"JZ" <jr*******@jngpugbjreQBGbet.cy> wrote in message
news:hc********************************@4ax.com...
import odbc
conn = odbc.odbc('mydsn')
c = conn.cursor()
c.execute('SELECT TOP 10 field1, field2 FROM TABLE')
rows = c.fetchall()
c.close()
conn.close()
I am using MSSQL2000. My problem is:
Instead of row[0], rows[1]
I would like to use row['field1], row['field']
Is it possible for odbc module?
I cannot find any comprehensive documentation :(
Well, I've been using oledb, but it should be fairly similar.
I just wrote a small wrapper class for the ADODB.Recordset object, that when
its Open() method is called, (as well as MoveNext, MovePrev, etc.) it copies
the current field names and their values into self.__dict__, so I can access
them via r.Field1, r.Field2, etc.
Another route I've gone (since OS/400 allows field names like TEST#REC@,
which python pukes on, is to over-ride __call__ to handle field data. (i.e.
c('test') = somevalue, etc.).
Anyways, a couple of ideas.