Declare self.cursor

Dani Valverde dani.valverde at
Tue Aug 24 19:15:11 CEST 2010

I am working on a GUI to connect to a MySQL database using MySQLdb (code 
in attached file). I define the cursor in lines 55-66 in the OnLogin 
function within the LoginDlg class.

/db= MySQLdb.connect(host='localhost', user=Username , passwd=pwd, 
self.cursor = db.cursor()/

When I try to use the cursor on another part of the code (EditUser 
class, line 176)

/sql = 'select substring_index(CURRENT_USER(),"@",1)'

I get this error:

/AttributeError: 'LoginDlg' object has no attribute 'cursor'/

You can check the code for details, I think is better.


Daniel Valverde Saubí
c/Joan Maragall 37 4 2
17002 Girona
Telèfon mòbil: +34651987662
e-mail: dani.valverde at

Si no és del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudaràs a estalviar aigua, energia i recursos forestals.  GRÀCIES!

Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU!

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: OrnithobaseGUI.txt
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dani_valverde.vcf
Type: text/x-vcard
Size: 296 bytes
Desc: not available
URL: <>

More information about the Python-list mailing list