On Feb 14, 2009, at 5:28 PM, Ricardo Aráoz wrote:

> conint = dabo.db.dConnectInfo(DbType='MySQL')
> conint.Host = "dabodev.com"
> conint.Database = 'daboconsult'
> conint.User = 'dabotutorial'
> conint.Password = 'PEDW3EH09S84P45DF9QE9SDA'


        You could do this all in one line, FWIW:

conint = dabo.db.dConnectInfo(DbType='MySQL', Host="dabodev.com",
        Database='daboconsult', User='dabotutorial',
        Password='PEDW3EH09S84P45DF9QE9SDA')

> conn = dabo.db.dConnection(conint).getConnection()

        Here's where you get into trouble. Instead of using the Dabo  
dConnection object, you drop down to the native MySQLdb cursor. If  
you're working in Dabo, it's always best to use the Dabo objects, and  
only use the non-Dabo classes when necessary.

> cur = conn.cursor()

        Now 'cur' is a MySQLdb cursor, and not a Dabo cursor. What would have  
been better is:

conn = dabo.db.dConnection(conint)
cur = conn.getDaboCursor()

> cur.execute('select * from clients')
> dabo.ui.browse(cur.fetchall())

        With the Dabo cursor, you'd do the execute, and then call:

dabo.ui.browse(cur)

> So I guess it works ok. But the browse will show the following error :
> -----------------------------------------------------------------------------------------------------------
> Traceback (most recent call last):
> File "<input>", line 1, in <module>
> File "C:\Python25\lib\site-packages\dabo\ui\uiwx\__init__.py", line
> 1366, in browse
>   colTypes=colTypes, autoSizeCols=autoSizeCols)
> File "C:\Python25\lib\site-packages\dabo\ui\uiwx\dGrid.py", line 2198,
> in buildFromDataSet
>   colKeys = [key for key in firstRec.keys()
> AttributeError: 'tuple' object has no attribute 'keys'

        That's because records in a plain MySQLdb cursor are tuples, whereas  
in a Dabo cursor they are dicts.

> worked ok in PythonWin and in Idle, but not in PyCrust (guess  
> because wx
> loop already running).

        Exactly. Mixing environments is never a good idea. Even Idle messes a  
lot of things up for Dabo and wx.


-- Ed Leafe




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to