Hello,
Well it seems I can't create a cursor. Based on what I have read on this forum, here is what I try:
import _mysql sql = _mysql oDB = sql.connection( host='xxx.xxx.x.x', user='myclient', passwd='mypassword', db='mydatabase' ) oCursor = oDB.cursor()
I know that I'm connected, because if I run oDB I get <_mysql.connection open to 'xxx.xxx.x.x' at d3f768>
When I run the above code, I get: Traceback (most recent call last): File "<interactive input>", line 4, in ? AttributeError: cursor
Any suggestion?
Thanks Bernard
Been hunting this myself- I am not sure which fixed it but try this and see if it works for you...
change your import statement to read:
import MySQLdb
<and then change to>
sql = MySQLdb
oDB = sql.connect( host='xxx.xxx.x.x', user='myclient', passwd='mypassword', db='mydatabase' )
<I have seen "connection" too but it always causes problems for me.>
-Paul
Sheesh.
You're supposed to do this:
import MySQLdb oDB = MySQLdb.Connection( host='xxx.xxx.x.x', user='myclient', passwd='mypassword', db='mydatabase' ) oCursor = oDB.cursor()
Don't go screwing around with _mysql directly.
Log in to post a comment.
Hello,
Well it seems I can't create a cursor. Based on what I have read on this forum, here is what I try:
import _mysql
sql = _mysql
oDB = sql.connection( host='xxx.xxx.x.x', user='myclient', passwd='mypassword', db='mydatabase' )
oCursor = oDB.cursor()
I know that I'm connected, because if I run
oDB
I get
<_mysql.connection open to 'xxx.xxx.x.x' at d3f768>
When I run the above code, I get:
Traceback (most recent call last):
File "<interactive input>", line 4, in ?
AttributeError: cursor
Any suggestion?
Thanks
Bernard
Been hunting this myself- I am not sure which fixed it but try this and see if it works for you...
change your import statement to read:
import MySQLdb
<and then change to>
sql = MySQLdb
<and then change to>
oDB = sql.connect( host='xxx.xxx.x.x', user='myclient', passwd='mypassword', db='mydatabase' )
<I have seen "connection" too but it always causes problems for me.>
-Paul
Sheesh.
You're supposed to do this:
import MySQLdb
oDB = MySQLdb.Connection( host='xxx.xxx.x.x', user='myclient', passwd='mypassword', db='mydatabase' )
oCursor = oDB.cursor()
Don't go screwing around with _mysql directly.