473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Python/MySQL problem on Windows

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

Sep 20 '06 #1
5 2068
On Wed, 2006-09-20 at 16:37, Eric Smith wrote:
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
Sep 20 '06 #2
Carsten Haese <ca*****@uniqsys.comwrites:
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
Sep 20 '06 #3
At Wednesday 20/9/2006 21:30, Ted Zeng wrote:
>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

Sep 21 '06 #4
Ted Zeng wrote:
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
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Sep 21 '06 #5
In message <qh************@ruckus.brouhaha.com>, Eric Smith wrote:
I could have sworn that I got the use of connection() from published
sample code, but I must be mistaken.
If all else fails, read the documentation
<http://www.python.org/dev/peps/pep-0249/>,
Sep 27 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Achim Domma | last post by:
Hello, I need mysql-python for python 2.3 on windows. I downloaded the source and tried to build it myself, but I get linker errors: mysqlclient.lib(password.obj) : error LNK2001: unresolved...
19
by: Patrick Useldinger | last post by:
Hi all, after my unsuccessful try to run Apache 2 with mod_python and Python 2.3, I am looking for an alternative approach. My aim is to write a small web-based application: Python - the...
5
by: Zunbeltz Izaola | last post by:
Hi! I am planning a program and I need some advice about what tool to use. Basically my program will deal with a object A. A is a list like object with same attributtes and a list of objects...
10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
10
by: callmebill | last post by:
I'm getting my feet wet with making Python talk to MySQL via ODBC. I started on Windows, and it went smoothly enough due to the ODBC stuff that apparently is native to Python at least on windows...
1
by: el chupacabra | last post by:
I'm using mysqldb module and python 2.4. I'm a newbie. Thanks in advance. 1. Output desired: "hello" "world" I know that MySQL takes \n and \t and what not. But my python script, it...
16
by: bobrik | last post by:
Hello, I am using the Python DB API for access to MySQL. But it is not platform-independent - I need a module not included in Python by default - python-mysql, and it uses a compiled binary...
13
by: Chris Seymour | last post by:
HI All, Does such a beast exist? Have been looking but haven't seen any. Any insight would be appreciated. Thanks. Chris
13
by: Steven Bethard | last post by:
Jean-Paul Calderone <exarkun@divmod.comwrote: Interesting. Could you give a few illustrations of this? (I didn't run into the same problem at all, so I'm curious.) Steve
15
by: kyosohma | last post by:
Hi, I am trying to get a small group of volunteers together to create Windows binaries for any Python extension developer that needs them, much like the package/extension builders who volunteer...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.