By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,402 Members | 1,047 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,402 IT Pros & Developers. It's quick & easy.

mysql-python error "AttributeError: cursor"

P: 2
My OS: Ubuntu 7.04 distribution
Mysql: Server version: 5.0.38-Ubuntu_0ubuntu1.2-log Ubuntu 7.04 distribution
mysql-python:1.2.2
python:2.5

when I run the following script:
import MySQLdb
conn = MySQLdb.connection('localhost', 'root', '', 'books');
c=conn.cursor()
cur = conn.cursor();
cur.execute('select * from orders');
row = cur.fetchone();
print row;


I get error message:
Traceback (most recent call last):
File "mysql_demo.py", line 7, in <module>
c=conn.cursor()
AttributeError: cursor

Please help!!!!
Mar 13 '08 #1
Share this Question
Share on Google+
3 Replies


jlm699
100+
P: 314
I don't know alot about the MySQLdb module (only postgresql modules)... but a quick google of the documentation reveals the following...
http://dustman.net/andy/python/MySQL...3.html#MySQLdb
Read about the connect() function and how cursor is a member of an object returned by that function. I think you may not be actually establishing a connection when you use connection()
Mar 13 '08 #2

P: 2
But the script run correctly on the other machine
Mar 14 '08 #3

jlm699
100+
P: 314
But the script run correctly on the other machine
What is the difference between the two machines then? It can't be a problem with the code if it already runs.. it must be a problem with the machine itself.
Mar 14 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.