handle different cursors for SQLAlchemy 0.5.* and 0.9.6

@ticoann @hufnagel : Would you please review the PR? Please let @geneguvo  know when you have a new tag for this PR so the HTTP group can deploy on slc6?