Connection Pooling _CursorFairy proxy is not fully transparent; iteration broken

Issue #1632 resolved
Former user created an issue
#!/usr/bin/python

import MySQLdb, MySQLdb.cursors
import sqlalchemy as sa
import sqlalchemy.pool
import sys

try:
  if sys.argv[1](1) == '--pool':
    MySQLdb = sa.pool.manage(MySQLdb, echo=True)
except IndexError: pass

db = MySQLdb.connect(host='localhost',user='...',passwd='...',db='...',cursorclass=MySQLdb.cursors.DictCursor)
c  = db.cursor()
c.execute(**SELECT * FROM ...**)
for r in c:
  print r['id']('id')



$ ./test.py
1
2
3

$ ./test.py --pool
2009-12-03 00:48:56,912 INFO sqlalchemy.pool.QueuePool.0x...6ccL Created new 
connection <_mysql.connection open to 'localhost' at 9ac2e64>
2009-12-03 00:48:56,912 INFO sqlalchemy.pool.QueuePool.0x...6ccL Connection 
<_mysql.connection open to 'localhost' at 9ac2e64> checked out from pool
Traceback (most recent call last):
  File "./test.py", line 16, in <module>
    for r in c:
TypeError: '_CursorFairy' object is not iterable
2009-12-03 00:48:56,924 INFO sqlalchemy.pool.QueuePool.0x...6ccL Connection 
<_mysql.connection open to 'localhost' at 9ac2e64> being returned to pool

Comments (2)

  1. Log in to comment