473,781 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.connect ion (db="database", user="user", passwd="passwor d")
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_inf o', 'errno', 'error', 'escape',
'escape_string' , 'field_count', 'get_host_info' , 'get_proto_info ',
'get_server_inf o', 'info', 'insert_id', 'kill', 'next_result', 'ping',
'query', 'rollback', 'select_db', 'set_server_opt ion', '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 2085
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.connect ion (db="database", user="user", passwd="passwor d")
What happens if you use connect(...) instead of connection(...) ?

-Carsten
Sep 20 '06 #2
Carsten Haese <ca*****@uniqsy s.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:(samp le code from internet)

server = SimpleXMLRPCSer ver.SimpleXMLRP CServer(("local host", 8000))
server.serve_fo rever()

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

server = xmlrpclib.Serve r('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.Serve r('http://machine_ip_addr ess: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 = SimpleXMLRPCSer ver.SimpleXMLRP CServer(("", 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.brouhah a.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
1787
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 external symbol __ftol2 The problem seems to be, that the mysql lib is build with VC7, but distutils tries to compile with VC6 (which are both on my machine). Can I force
19
3182
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 solution must be based / usable on Python 2.3 Portability Targeted plaforms are
5
1758
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 B. B is also a list like object with attributes and a list of object C. class A: Name = ""
10
3691
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. Andrew dalke@dalkescientific.com
10
3318
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 (I've been following ch. 13 of Mark Hammond's py on win32 book). But now I'm trying to do equivalent stuff on linux (Fedora Core 3) with python 2.3.5 and mysql. I'd like to stick with packages that are native to python, rather than relying on...
1
2025
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 takes that \n as literal. Meaning, when I retrieve the records, they show up like "hello \n world".
16
2473
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 _mysql.so. So it is not platform-independent because for each web-server on different platform, I would have to download it and extra compile it specifically for that platform. Do you know of any Python solution for MySQL access that is 100%...
13
6473
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
2160
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
3227
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 their time to create Linux RPMs. The main thing I need are people willing to test the binaries to make sure the extension is stable. This would require installing the binary and probably downloading the source too to get the developer's test
0
10308
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10143
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10076
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9939
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8964
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4040
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2870
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.