Tuesday, September 4, 2012

Re: DB-API Field Type Codes in mysql-python

I think this is just an oversight.  We're returning the JDBC integers instead of the mysqldb integers.  I'll file a bug.

Ken


On Sat, Sep 1, 2012 at 2:31 AM, ahroth <avivroth@gmail.com> wrote:
I am using Google App Engine with the Google Cloud SQL module "rdbms".  According to the documentation, rdbms uses DB-API 2.0.  What I've been trying to do is take advantage of the cursor.description attribute, which is a sequence of 7 item sequences (name, type_code,  display_size, internal_size,  precision,  scale, null_ok).  "type_code" is what I'm trying to get at , because I need to pass the data to Google Visualizations, which require types to be declared for each column.

Here's the problem:

"type_code" is returned as an integer.  Different integers represent different types.  I searched madly on the internet for mappings for these codes, and found them for MySQLdb.  The problem is that the ones returned from the Google Cloud SQL rdbms module (for Google App Engine) are different codes!  An integer gets a different code on my local machine than an integer returned from Google Cloud SQL in GAE.

So my questions:
1. Does anyone know where I can get a mapping for the type_codes returned from the rdbms module to GAE?  Or am I going to have to manually test each type in the database?
2. Are there any constants for FIELD_TYPE that I can use with rdbms?  MySQLdb defines these constants in human-readable form, so it would be great if rdbms had the same constant names, so that I wouldn't have to worry about coding for two type mappings.

Can anyone help?  Thanks!

No comments:

Post a Comment