Python/MySQL problem on Windows

Eric Smith eric at brouhaha.com
Wed Sep 20 16:37:43 EDT 2006


I'm trying to use Python 2.4.3 and pywin32-209 to access a MySQL
database on Windows Server 2003 Standard Edition, and not having much
luck. It seems like parts of the MySQLdb module are not getting loaded
correctly, but no error message is given during the import, even if I
give a "-vv" on the command line.

I'm trying to do:

    import MySQLdb
    db = MySQLdb.connection (db="database", user="user", passwd="password")
    cursor = db.cursor ()

It won't give me a cursor object, instead claiming "AttributeError: cursor".
Sure enough, if I do a

    dir (db)

I get:

    ['affected_rows', 'autocommit', 'change_user', 'character_set_name',
     'close', 'commit', 'dump_debug_info', 'errno', 'error', 'escape',
     'escape_string', 'field_count', 'get_host_info', 'get_proto_info',
     'get_server_info', 'info', 'insert_id', 'kill', 'next_result', 'ping',
     'query', 'rollback', 'select_db', 'set_server_option', 'shutdown',
     'sqlstate', 'stat', 'store_result', 'string_literal', 'thread_id',
     'use_result', 'warning_count']

There seem to be a lot of attributes missing, not just cursor.

But the database connection is live and works, as I can use the
undocumented db.query() function to do an insert into the database,
and that works fine.

I can run my same Python script on Fedora Core 5 and it works fine.

I'm at wit's end; can anyone suggest what might be wrong, or how to
debug it?  (Unfortunately replacing Windows with Linux on the server
machine is not currently a viable option.)

I can provide the "-vv" output if that's useful, but there didn't
appear to be anything unusual in it.

Thanks!
Eric Smith




More information about the Python-list mailing list