Python/MySQL problem on Windows

E

Eric Smith

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
 
C

Carsten Haese

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")

What happens if you use connect(...) instead of connection(...)?

-Carsten
 
E

Eric Smith

Carsten Haese said:
What happens if you use connect(...) instead of connection(...)?

Then it works! :)

I could have sworn that I got the use of connection() from published
sample code, but I must be mistaken.

Thanks!!!!!
Eric
 
G

Gabriel Genellina

But if I use server's ip address instead of localhost in the client,
then it could not access the server.

Maybe you have a firewall blocking access?



Gabriel Genellina
Softlab SRL





__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
 
S

Steve Holden

Ted said:
HI,

I run a xml_rpc server like the following:(sample code from internet)

server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8000))
server.serve_forever()

If my client is on the same machine, I use :(also from internet sample
code)

server = xmlrpclib.Server('http://localhost:8000')
print server.chop_in_half('I am a confidant guy')

This works fine.

But if I use server's ip address instead of localhost in the client,
then it could not access the server.

server = xmlrpclib.Server('http://machine_ip_address:8000')
print server.chop_in_half('I am a confidant guy')


How can my client (runs on other machine) access the server? The server
runs on a machine with dynamic IP. But my client knows the IP address.

You are explicitly telling your server ONLY to listen on the loopback
interface. Try using an empty string as IP address instead:

server = SimpleXMLRPCServer.SimpleXMLRPCServer(("", 8000))

That will tell it to listen on all interfaces:

regards
Steve
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top