On Oct 22, 2012, at 5:06 PM, Mike B wrote:

> Hello everyone,
> 
> Has anyone successfully run SQLAlchemy 0.7.8 or .9 with MySQL 5.5? How about 
> in Ubuntu 12.04? ...with MySQL-python 1.2.3 or a 1.2.4beta?
> 
> I ask because Ubuntu 12.04 rescinds package manager support for MySQL 5.1, 
> forcing us to upgrade to 5.5. Last week I experimentally upgraded a very 
> stable server from {Ubuntu 11.10, MySQL 5.1, InnoDB, Python 2.7.2} to {Ubuntu 
> 12.04, MySQL 5.5, InnoDB, Python 2.7.3}. Unfortunately, ever since the 
> upgrade I have seen sporadic errors like this one:
> 
> Module sqlalchemy.engine.default:606 in create_cursor view 
> Module MySQLdb.connections:243 in cursor view 
> StatementError: 'Connection' object has no attribute 'cursorclass' (original 
> cause: AttributeError: 'Connection' object has no attribute 'cursorclass') 
> 'SELECT DATABASE()' [] 
> (Python 2.7.3, SQLAlchemy 0.7.8, MySQL-python 1.2.3, MySQL 5.5, Pylons 1.0, 
> mod-wsgi, apache2)


That stack trace is in MySQLdb, and that's likely where the bug is here.   
Often when MySQLdb has an issue like this, its connection object also becomes 
invalid, but the error it raises here doesn't tell SQLAlchemy that this is the 
case, so SQLAlchemy keeps this now-broken connection pooled.  So subsequent 
usages fail.   

However, one possibility here is that your code might not be using the 
connection in a threadsafe manner.  I say this because you describe the errors 
as "sporadic", and I'm assuming you can't come up with a simple reproduction 
case.   The MySQLdb connection object cannot be used by more than one thread at 
the same time, without synchronization being in place.  When using the 
SQLAlchemy ORM, this implies that access to the Session must also be entirely 
local to a thread or synchronized, as well as access to *all objects that are 
associated with that Session*, as all those objects are proxies to the 
Session's, and therefore to the MySQLdb connection object's, state.   It's not 
impossible that some subtle synchronization issue is only brought to light when 
used in conjunction with some quirk of MySQL 5.5.   

If thread safety is not a factor here and you're sure connections are used in a 
thread-safe manner, and you can come up with a determining case for it, you'd 
ideally want to produce a MySQLdb test case for this and report to MySQLdb: 
http://sourceforge.net/p/mysql-python/bugs/ .

Alternatives include using some of the other MySQL drivers, such as OurSQL or 
PyMySQL.  MySQL Connector/Python is said to be the "official" DBAPI for MySQL 
but I've still been having issues with it.


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to