[Tutor] Avoiding MySQLdb Warnings

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Tue Jan 13 14:29:19 EST 2004



On Tue, 13 Jan 2004, [ISO-8859-1] "H=E9ctor Villafuerte D." wrote:

> Hi all,
> I'm using this piece of code to connect to a MySQL database:
> loc_db =3D MySQLdb.connect(host =3D "localhost", user =3D "villaf", passw=
d =3D
> "hvillaf", db =3D "traffic", \
>                          cursorclass=3DMySQLdb.BaseCursor)
>
> But it raises the following exception:
> AttributeError: 'module' object has no attribute 'BaseCursor'
>
> I'm trying to use the BaseCursor, because it doesn't raises warnings
> from MySQL.


Hi Hector,


Ah!  Try:

###
loc_db =3D MySQLdb.connect(host =3D "localhost", user =3D "villaf",
                         passwd =3D "hvillaf",
                         db =3D "traffic",
                         cursorclass=3DMySQLdb.cursors.BaseCursor)
###

All of MySQLdb's specialized cursor classes should live in
MySQLdb.cursors.  You may need to do a:

###
import MySQLdb.cursors
###

at the head of your script.



Good luck to you!




More information about the Tutor mailing list