PYODBC Print Cursor Output Question

Discussion in 'Python' started by james simpson, Sep 10, 2012.

  1. 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?)
     
    james simpson, Sep 10, 2012
    #1
    1. Advertising

  2. james simpson

    MRAB Guest

    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
     
    MRAB, Sep 10, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VG9tYXMgS2VwaWM=?=

    Changing DEFAULT cursor to WAIT cursor in ASP

    =?Utf-8?B?VG9tYXMgS2VwaWM=?=, Apr 5, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,376
    Bruce Barker
    Apr 5, 2005
  2. invy
    Replies:
    4
    Views:
    422
    CBFalconer
    Dec 28, 2006
  3. keto
    Replies:
    0
    Views:
    1,045
  4. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    400
    David Cournapeau
    Dec 30, 2008
  5. dmaziuk
    Replies:
    3
    Views:
    628
    Chris Gonnerman
    Jan 25, 2011
Loading...

Share This Page