Switch to using nose assertions, and remove assertion messages as they make the code less readable but don't help finding problems.
Refactor database usage to save on connections; do not use SQLAlchemy to generate SQL to ensure safe quoting and to drop reliance on more recent sqlalchemy version than is required for ckan; while there refactor controller a bit.