Using DictCursors

875 views
Skip to first unread message

Santiago Lizardo Oscares

unread,
Oct 31, 2011, 6:22:16 PM10/31/11
to google-cloud...@googlegroups.com
Hi there. I was able to develop a complete application using Google Cloud SQL and GAE, but the former limited to regular Python DB Cursors. If I try to use DictCursors (importing a MySQLdb module) then the application complaints about a missing C file.

I know we can't use C modules in the Google App Engine infrastructure, then what can I do to start using DictCursors in my app?
conn = rdbms.connect( instance = instanceName, database = dbName, cursorclass = MySQLdb.cursors.DictCursor, charset = 'UTF8' )
Thanks!

Ken Ashcraft

unread,
Oct 31, 2011, 7:27:59 PM10/31/11
to google-cloud...@googlegroups.com
Hi Santiago,

This should be fixed in the next GAE SDK release.  It will look like:
  conn = rdbms.connect(...)
  cursor = conn.cursor(use_dict_cursor=True)

Watch the App Engine list for a prerelease announcement so you can get the fix faster.

Ken

Santiago Lizardo Oscares

unread,
Oct 31, 2011, 8:30:26 PM10/31/11
to google-cloud...@googlegroups.com
Thanks a lot for the feedback, Ken! Until get that fix you mentioned, I'll be using a comprehension list to pack column names and values. See ya, :)

Sarfaraz Farooqui

unread,
Mar 11, 2012, 10:42:15 AM3/11/12
to google-cloud...@googlegroups.com
Hi,
 
I am using sdk 1.6.3 on python 2.7
I checked the file rdbms.py and saw the implementation of use_dict_cursor. however
when i try to use it I get an exception
 
Usage:
conn = rdbms.connect(...)
cursor = conn.cursor(use_dict_cursor=True)
 
Exception:
cursor() got an unexpected keyword argument 'use_dict_cursor'
 
I guess its not usable yet.
 
Regards
 

Ken Ashcraft

unread,
Mar 13, 2012, 5:05:00 PM3/13/12
to google-cloud...@googlegroups.com
The code is there and the tests pass for us.  Can you give us more information?  A simple, complete app to reproduce the error would be helpful.

Thanks,
Ken

 
 
Regards
 

Reinaldo Aguiar

unread,
Mar 13, 2012, 5:35:52 PM3/13/12
to google-cloud...@googlegroups.com
I believe this is not a cloud-sql but an app engine issue. The problem is that dict cursor is not implemented in one or both of the app engine python sdk version (can't remember exactly).

I remember having the same exact issue and I what I did was to copy the implementation from dict cursor and kind of mock it that way. 

Spoiler alert: In my particular case, the performance was terrible because the dict cursor basically copies the data into a dictionary one result row at the time, while this happens the mysql connection remains open and the performance of the copy operation itself was terrible, at least for the result set I was working with (this might be different in your particular use case/dataset).

On Sun, Mar 11, 2012 at 7:42 AM, Sarfaraz Farooqui <sarfaraz...@gmail.com> wrote:

Sarfaraz

unread,
Mar 13, 2012, 6:46:12 PM3/13/12
to google-cloud...@googlegroups.com
Yes, Its an AppEngine issue, not cloud-sql.

I am using sdk 1.6.3 and using dict cursor works fine.

I get errors only in production code. I cannot recall the exact message, hopefully I will try to post it ASAP.

Thanks

Reinaldo Aguiar

unread,
Mar 13, 2012, 7:42:13 PM3/13/12
to google-cloud...@googlegroups.com
Correct, the dev. server has the dict cursor implemented but the production python doesn't. I copied the implementation from the SDK source code (which is open source) to my application and mocked it that way. This works but as I said before, the performance just wasn't doing it for me.

Sarfaraz

unread,
Mar 14, 2012, 11:09:44 AM3/14/12
to google-cloud...@googlegroups.com
Please star this in the issue tracker.

you can search by **dict cursor** or **dict_cursor**

Regards
Sarfaraz

Tom Peters

unread,
Jul 25, 2012, 6:29:13 PM7/25/12
to google-cloud...@googlegroups.com
Wanted to check in and see if this was still being worked on?  I've been working in development with the code below.  I just went and posted the app and now get the 'module' object has no attribute 'cursors' error.  I then tried the cursor = conn.cursor(use_dict_cursor=True) code and that did not work either.

conn = rdbms.connect(

instance='instance',

database='db',

cursorclass=rdbms.cursors.DictCursor) 
Reply all
Reply to author
Forward
0 new messages