tmolomby / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

row object acessing fields by name #282

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When using "select *" the fields cannot be accesses by name in the row object. 
this will be a very handy feature as already is in trhe other cases.

Using sql server 2000 and 2008 express, python 2.7

Original issue reported on code.google.com by alexandr...@gmail.com on 14 Aug 2012 at 9:47

GoogleCodeExporter commented 9 years ago
There must be more to this - I use this feature daily.  The names don't 
actually come from the SQL statement.  They are actually requested from the 
results, so there is no reason for it not to work.

Can you post an example?

Original comment by mkleehammer on 17 Aug 2012 at 2:07

GoogleCodeExporter commented 9 years ago
Sorry when doing the example, below I saw it was a case error in fieldname.
Uses to sqlserver and delphi c++ that was not an issue before

import pyodbc

con = pyodbc.connect('DRIVER={SQL 
Server};SERVER=srv-sql;DATABASE=ina;UID=sa;PWD=jfk')
c = con.cursor()

print [r.column_name for r in c.columns('terceiro')]

for r in c.execute('select top 100 * from terceiro'):
    print r.Nome

con.close()    

Original comment by alexandr...@gmail.com on 17 Aug 2012 at 8:15

GoogleCodeExporter commented 9 years ago
By the way thank you for pyodbc, I'm changing a lot of stuff to it, and will do 
more.
Will try do run django width it.

Original comment by alexandr...@gmail.com on 17 Aug 2012 at 8:17

GoogleCodeExporter commented 9 years ago

Original comment by mkleehammer on 26 Sep 2012 at 9:14