class MySQLAlchemySessionMiddleware(object):

    def process_request(self, request):
        request.db_session = settings.Session()

def process_response(self, request, response):
    pass
Best way to integrate SqlAlchemy into a Django project