MySQL: AttributeError: cursor

Discussion in 'Python' started by Kevin Murphy, Feb 11, 2012.

  1. Kevin Murphy

    Kevin Murphy Guest

    Hi All,
    I'm using Python 2.7 and having a problem creating the cursor below.
    Any suggestions would be appreciated!

    import sys
    import _mysql

    print "cursor test"

    db =
    _mysql.connect(host="localhost",user="root",passwd="mypw",db="python-
    test")

    cursor = db.cursor()

    >>>

    cursor test

    Traceback (most recent call last):
    File "C:\Python27\dbconnect.py", line 8, in <module>
    cursor = db.cursor()
    AttributeError: cursor
     
    Kevin Murphy, Feb 11, 2012
    #1
    1. Advertising

  2. On Sat, 2012-02-11 at 09:40 -0800, Kevin Murphy wrote:
    > Hi All,
    > I'm using Python 2.7 and having a problem creating the cursor below.
    > Any suggestions would be appreciated!
    >
    > import sys
    > import _mysql
    >
    > print "cursor test"
    >
    > db =
    > _mysql.connect(host="localhost",user="root",passwd="mypw",db="python-
    > test")
    >
    > cursor = db.cursor()
    >
    > >>>

    > cursor test
    >
    > Traceback (most recent call last):
    > File "C:\Python27\dbconnect.py", line 8, in <module>
    > cursor = db.cursor()
    > AttributeError: cursor


    You are using the low-level C API wrapper (not sure why). Most people,
    I believe, would use the pythonic API:

    >>> import MySQLdb
    >>> db = MySQLdb.connect(host='localhost', user='root', passwd='mypw',

    db='python-test')
    >>> cursor = db.cursor()


    The low-level API is... well.. for when you want to do low-level stuff.
    You probably want the pythonic API.

    -a
     
    Albert W. Hopkins, Feb 11, 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,323
    Bruce Barker
    Apr 5, 2005
  2. William Gill

    help with mysql cursor.execute()

    William Gill, Aug 14, 2005, in forum: Python
    Replies:
    7
    Views:
    613
    Dennis Lee Bieber
    Aug 16, 2005
  3. invy
    Replies:
    4
    Views:
    391
    CBFalconer
    Dec 28, 2006
  4. Florian Lindner

    Problem with MySQL cursor

    Florian Lindner, Oct 11, 2007, in forum: Python
    Replies:
    6
    Views:
    425
    Florian Lindner
    Oct 12, 2007
  5. dmaziuk
    Replies:
    3
    Views:
    581
    Chris Gonnerman
    Jan 25, 2011
Loading...

Share This Page