PYODBC Print Cursor Output Question

MRAB python at mrabarnett.plus.com
Mon Sep 10 12:19:09 EDT 2012


On 10/09/2012 15:55, james simpson wrote:
> I think there's a simple answer but displaying my ignorance here.
> I'm
> using Python 2.7.3 IDLW with pydoc 3x
>
> I think I've connected to my SQL Server 2005 and my SQL is good.
>
> How do I display the actual data returned from my fetch?  Been
> searching for several hours but no joy...
>
> Thanks. Jamie
>
> ===============================================
>>>> cursor.execute("select * from project")
>
> row = cursor.fetchone()
> if row:
>      print row
>
> <pyodbc.Cursor object at 0x0167D678>   I'd like to actually see SQL
> output here?)
>
>
Try this:

 >>> results = cursor.execute("select * from project")
 >>> row = results.fetchone()
 >>> print row




More information about the Python-list mailing list