views:

57

answers:

3

I'm trying out the Concurrence framework for Stackless Python. It includes a MySQL driver and when running some code that previously ran fine with MySQLdb it fails.

What I am doing:

  1. Connecting to the MySQL database using dbapi with username/password/port/database.

  2. Executing SELECT * FROM INFORMATION_SCHEMA.COLUMNS

This fails with message:

Table 'mydatabase.columns' doesn't exist

"mydatabase" is the database I specified in step 1.

When doing the same query in the MySQL console after issuing "USE mydatabase", it works perfectly.

Checking the network communication yields something like this:

>>>myusername
>>>scrambled password
>>>mydatabase

>>>CMD 3 SET AUTOCOMMIT = 0
<<<0

>>>CMD 3 SELECT * FROM INFORMATION_SCHEMA.COLUMNS
<<<255
<<<Table 'mydatabase.columns' doesn't exist

Is this a driver issue (since it works in MySQLdb)? Or am I not supposed to be able to query INFORMATION_SCHEMA this way?

If I send a specific "USE INFORMATION_SCHEMA" before trying to query it, I get the expected result. But, I do not want to have to sprinkle my code all over with "USE" queries.

+1  A: 

It definitely looks like a driver issue. Maybe the python driver don't support the DB prefix.

Just to be sure, try the other way around: first use INFORMATION_SCHEMA and then SELECT * FROM mydatabase.sometable

Jorge Bernal
Thanks, trying the other way around yielded the same error, telling me it has nothing to do with INFORMATION_SCHEMA specifically.
truppo
+1  A: 

I finally found the reason.

The driver just echoed the server capability flags back in the protocol handshake, with the exception of compression:

## concurrence/database/mysql/client.py ##

client_caps = server_caps 

#always turn off compression
client_caps &= ~CAPS.COMPRESS

As the server has the capability...

CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */

...that was echoed back to the server, telling it not to allow that syntax.

Adding client_caps &= ~CAPS.NO_SCHEMA did the trick.

truppo
A: 

Hi, I am the author of Concurrence. I just committed your fix to my development branch at GitHub

Toymachine